Quantcast
Channel: Questions in topic: "clone"
Viewing all articles
Browse latest Browse all 508

Getting variable from instantiated clone instead of prefab C#

$
0
0
Here's the problem. I want to get variables from cloned object script, but instead i get variables of prefab's script. Code:


        public GameObject prefab;
        public Script script;
        public int value;

        void Start () {
        
        GameObject clone =(GameObject)Instantiate (prefab, transform.position, transform.rotation);
        script=(Script)clone.GetComponent
Editor indicates, that script indicates as [Prefab(Clone) (Script)], that means it refered to cloned object.

Viewing all articles
Browse latest Browse all 508

Trending Articles