0
votes

I'm really new to unity, This is my first project. My problem is than when I create a new gameobject

public GameObject fancyName;

and then drag the prefab I want over the script window, if I make any changes on fancyName, instead of modifying what I see on the screen I get to modify my prefab... What do I have to do in order to modify the Instantiate GameObject and not the prefab?

1
Instantiate and grab a reference to that instantiated gameobject, something like GameObject go = (GameObject)Instantiate(fancyName, pos, rot).Gunnar B.
Thanks, that solved my proble!Mattia Rubini

1 Answers

2
votes

It is an expected behavior because fancyName holds a reference to your prefab so any changes you make to 'fancyName' is a direct modification to your prefab (remember you dragged & dropped your prefab to this variable right?).

You should instantiate/clone it:

var clone = (GameObject) Instantiate(fancyName);

and then

MakeChange(clone); // Do anything you want