11-08-2019, 01:44 PM
hi, So I'm creating a spline and adding 2 control points, when I try to get a refernce to one of them I get a null ref exception, see code below :
The following code is run ONLY ONCE while the left mouse button is down :
the spline & 2 control points are definately there.
But if i change the code so that
is ran after the first time the mouse button is down it works.
It even though I'm refreshing the spline it seems like it wont refresh until update is run again.
The following code is run ONLY ONCE while the left mouse button is down :
Code:
drawmousePOS_OBJ = GameObject.Find ("mousePOS");
drawmousePOS_OBJ.AddComponent<CurvySpline> ().Interpolation = CurvyInterpolation.Bezier;
drawing_spline = drawmousePOS_OBJ.GetComponent<CurvySpline> ();
drawing_spline.Add ().transform.position = v3;
drawing_spline.Add ().transform.position = v3;
drawing_spline.SetDirtyAll ();
drawing_spline.Refresh ();
drawtaxiCP0002 = GameObject.Find ("mousePOS/CP0001");
Debug.Log (drawtaxiCP0002.transform.position ); // this line creates a null ref exception
the spline & 2 control points are definately there.
But if i change the code so that
Code:
drawtaxiCP0002 = GameObject.Find ("mousePOS/CP0001");
Debug.Log (drawtaxiCP0002.transform.position ); // works as expected !!
is ran after the first time the mouse button is down it works.
It even though I'm refreshing the spline it seems like it wont refresh until update is run again.