- Home /
Question by
imDJK · Jul 05, 2015 at 01:28 PM ·
unity 5itweenitweenpath
Issue with changing the name of iTween.Path() at runtime
newb alert!
Hey guys,
I am having troubles with changing the name of the path for an object during runtime (I need to assign each object a different Path name as I will have to instantiate around 30 objects) and the best way (I could think of) of doing that is by giving the Path the name of the gameObject.
Until now I have the following class:
using UnityEngine;
using System.Collections;
public class TargetHelper : MonoBehaviour {
public UILabel targetNameLabel;
public UIWidget instructTo;
public UIWidget directTo;
private string pathName;
void OnEnable()
{
AppManager.Instance.AssignRandomName();
AssignName();
Path();
}
void AssignName()
{
gameObject.transform.name = AppManager.Instance.randomName;
targetNameLabel.text = "" + AppManager.Instance.randomName;
AppManager.Instance.uiApp.targets.Add(AppManager.Instance.randomName);
}
void Path()
{
pathName = AppManager.Instance.randomName;
gameObject.GetComponent<iTweenPath>().pathName = pathName;
Debug.Log("Path name: " + gameObject.GetComponent<iTweenPath>().pathName);
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath(gameObject.GetComponent<iTweenPath>().pathName), "time", 90, "easetype", iTween.EaseType.linear, "moveToPath", false));
}
}
But I keep receiving an
NullReferenceException: Object reference not set to an instance of an object
Even if in the console I see that the Path name has been changed before the error is triggered
Any ideas on how I could fix this?
Thanks in advance.
PS: I'm using NGUI (not sure if matters)
Comment