|
I have a component, that I want to automatically reset when the game object it is attached to is duplicated / cloned in the editor. I have tried doing this with a stored ID, and every time you inspect the component it looks through the whole scene for other objects with the same ID and if there is one, resets itself. But this is a very clumsy way of doing it, and it's very specific (I have to individually reset every variable). Is there a way to reset a component? Is there a way to catch duplication? Is it possible to do this from a custom editor instead of the component itself (lets say I don't have access to the component's script)?
(comments are locked)
|
|
You could save the "restored" version as a prefab, and instance off of that? Hm. Using a prefab would be tricky, as I then need very specific code to get instantiate the prefab, get the right component out of it, read its data and remove the instance again. Plus I have to create prefabs for pretty much everything. But the most important issue for me is to catch when the duplication actually happens.
Nov 02 '10 at 09:39 AM
Orion 1
(comments are locked)
|

Is it supposed to be an editor duplication event, or a run-time duplication event? Have you tried calling Reset() during OnEnable() ?
It indeed is supposed to be editor duplication, which does not call OnEnable().