The question is answered, right answer was accepted
Problem with == Null
I have a problem
I have this script :
if (Vertices == null)
{
Vertices = d.Vertices;
Triangles = d.Triangles;
Uvs = d.Uvs;
Debug.Log ("activated Null in meshdata "+Vertices.Length);
}
My Problem is that Vertices isn't Null but gets activated
The debug.log says:
activated Null in meshdata 4
UnityEngine.Debug:Log(Object)
MeshData:add(MeshData) (at Assets/Source/MeshData.cs:37)
Im not an expert so please explain it as easy as possible :)
Thank you in Advance :)
Answer by Statement · Nov 09, 2015 at 07:35 PM
if (Vertices == null)
Vertices = d.Vertices;
Debug.Log ("activated Null in meshdata "+Vertices.Length);
So the code block runs if Vertices is null.
The very next statement sets Vertices to d.Vertices. Vertices is no longer null.
You're then logging the length of Vertices (which is the same as d.Vertices).
The log message is a little funny. If someone on the street told you "I activated null", what does that mean? It should probably say something like this: "Assigned 4 new vertices" or "$$anonymous$$eshData.Vertices was updated (4 vertices in array)"
Follow this Question
Related Questions
Parsing a simple json object is always returning null properties,Parsing Always return empty object 1 Answer
Why am I getting a null reference error? 1 Answer
NullRefrenceException: Object refrence not set to an instance of an object. 0 Answers
ArgumentNullException: Value cannot be null when slicing mesh 0 Answers