Hi all,
I have a game with 2 scenes: “GameLevel1” and “GameLevel2”
In “GameLevel2” scene I have an object named “Map” and have a component(script) named “Map”, too.
I want to get Map script after changing scene from GameLevel1 to GameLevel2, and I used scripts:
GameObject is a component, which means that it can a variable newGameObject : GameObject, or you can access it, transform.gameObject. From there, you can do GetComponent() or Find().
Thanks,
I tried 2nd way, but a compile error occured. Find() is a class function (static function in C#), so you can’t access it with an instance, instead of classname
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public GameObject hand;
void Awake() {
hand = GameObject.Find("Hand");
hand = GameObject.Find("/Hand");
hand = GameObject.Find("/Monster/Arm/Hand");
hand = GameObject.Find("Monster/Arm/Hand");
}
}