Obi Official Forum
"Edit Particles" NullReferenceException - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: "Edit Particles" NullReferenceException (/thread-100.html)



"Edit Particles" NullReferenceException - RoryMakarov - 05-09-2017

I am getting the following error when clicking "Edit Particles"

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiPinConstraints.OnDrawGizmosSelected () (at Assets/Obi/Scripts/Constraints/ObiPinConstraints.cs:52)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr)



NullReferenceException: Object reference not set to an instance of an object
Obi.ObiParticleActorEditor.DrawParticles () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:332)
Obi.ObiParticleActorEditor.DrawActorInfo () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:598)
Obi.ObiParticleActorEditor.OnSceneGUI () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:262)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.SceneView.CallOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2408)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1737)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1569)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:232)


RE: "Edit Particles" NullReferenceException - josemendez - 05-09-2017

(05-09-2017, 12:11 PM)RoryMakarov Wrote: I am getting the following error when clicking "Edit Particles"

NullReferenceException: Object reference not set to an instance of an object
Obi.ObiPinConstraints.OnDrawGizmosSelected () (at Assets/Obi/Scripts/Constraints/ObiPinConstraints.cs:52)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr)



NullReferenceException: Object reference not set to an instance of an object
Obi.ObiParticleActorEditor.DrawParticles () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:332)
Obi.ObiParticleActorEditor.DrawActorInfo () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:598)
Obi.ObiParticleActorEditor.OnSceneGUI () (at Assets/Obi/Editor/ObiParticleActorEditor.cs:262)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.SceneView.CallOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2408)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1737)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1569)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:272)
UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:265)
UnityEditor.HostView.InvokeOnGUI (Rect onGUIPosition) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:232)

Hi!

what Unity and Obi versions are you using?


RE: "Edit Particles" NullReferenceException - RoryMakarov - 05-09-2017

(05-09-2017, 03:54 PM)josemendez Wrote: Hi!

what Unity and Obi versions are you using?

2017.1.0p4 and the latest asset


RE: "Edit Particles" NullReferenceException - josemendez - 05-09-2017

(05-09-2017, 04:19 PM)RoryMakarov Wrote: 2017.1.0p4 and the latest asset

Could reproduce this. Thanks for reporting it! Wwll include the fix in the next update, for now replace the OnDrawGizmosSelected function in ObiPinConstraints.cs with this:

Code:
public void OnDrawGizmosSelected(){

        if (!visualize) return;

        Gizmos.color = Color.cyan;

        foreach (ObiPinConstraintBatch batch in batches){
            foreach(int i in batch.ActiveConstraints){

                if (batch.pinBodies[i] != null){
                    Vector3 pinPosition = batch.pinBodies[i].transform.TransformPoint(batch.pinOffsets[i]);
    
                    Gizmos.DrawLine(actor.GetParticlePosition(batch.pinIndices[i]),
                                    pinPosition);
                }
            }
        }

    }



RE: "Edit Particles" NullReferenceException - allenmarsh - 31-07-2018

A NullReferenceException exception is thrown when you try to access a member on a type whose value is null. A NullReferenceException exception typically reflects as developer error. To fully understand why a NullReferenceException is thrown, it is important to know the difference between value types and reference types.

So, if you're dealing with value types, NullReferenceExceptions can not occur. Though you need to keep alert when dealing with reference types!

Only reference types, as the name is suggesting, can hold references or point literally to nothing (or 'null'). Whereas value types always contain a value.

Reference types (these ones must be checked):
  • dynamic
  • object
  • string
Value types (you can simply ignore these ones):
  • Numeric types
  • Integral types
  • Floating-point types
  • decimal
  • bool
  • User defined structs