- when i debug.log GetPersistentTarget(i) it gives me the gameobject name too so i think there is an access to its gameobject. i want to check getcomponent of assigned gameobject.

1 Answer
1GetPersistentTarget returns a UnityEngine.Object. You can covert this to a GameObject by using the ‘as’ keyword, or by casting to a GameObject:
UnityEngine.Object unityObject = unityEvent.GetPersistentTarget (0);
GameObject go = unityObject as GameObject;
//or....
GameObject go = (GameObject) unityObject
i've tried this but it gives me null error: InvalidCastException: Specified cast is not valid.
– rebloomdevtoolsCan you post the code you're tying?
– ArachnidAnimalAfter the first line of code above, add: Debug.Log ("object type: " + unityObject.GetType()); What does the console say?
– ArachnidAnimalthanks it solved. null error was for my own code.
– rebloomdevtools