prak
May 17, 2013, 1:41pm
1
I have a few Prefabs that get instantiated throughout the game.
Each contain a “Type” value.
As I adjust the game, I make tweaks to the Prefab. When I apply changes to the Prefab, I want everything to update except the “Type” value.
Is this possible?
Well, I think maybe you could just have your games master script (game logic/whatever) keep track of type, and hand off its value to the instantiated prefabs when they are spawned, like
(in c#)
GameObject myNewPrefab = Instantiate(so on...
then you would do like:
MyGameObjectScriptName myNewPrefabsScript = myNewPrefab.GetComponent(so on...
to get the script controlling it, and then…
myNewPrefabsScript.Type = Type; // this is set forever in the master script, but assigned to the prefab
of course if you have more than one “type” you could do:
if(myNewPrefab.tag == TheFirstType)
myNewPrefabsScript.Type = ThisType;
else if(myNewPrefab.tag == TheOtherType)
myNewPrefabsScript.Type = OtherType;
else
myNewPrefabsScript.Type = SomeOtherType;
all of the possible types keep in master script, as they instantiate, tell them what type they are
hope that helps!