Animation Editor: Events are forgetting my GameObjects

(apologies if this is in the wrong forum… it’s half coding and half Animation Editor… I had to pick one)

I’ve been using the animation editor to animate a camera. At certain points in the camera’s movement, I want a certain object in my scene to be enabled or disabled. So, I created two simple Javascript functions:

//disable an object
function disableGameObject (object:GameObject) {
	object.renderer.enabled = false;
}

//enable an object
function enableGameObject (object: GameObject) {
	object.renderer.enabled = true;
}

Then, for every time I need disableGameObject() or enableGameObject(), I add that function as an event to the animation at the appropriate time, and then drag the object in my scene into the function.

It works great! The objects on the stage disappear and reappear when they’re supposed to… until I save the game and close Unity. When I open up Unity again, the animation events are remembered, but it doesn’t remember to what objects the animation events apply. It will simply say “disableGameObject (null)” instead, even though the objects are still on stage.

Does anyone know how to fix this?

EDIT: I found a workaround. It’s almost as good. All I do now is, instead of passing a GameObject reference, I pass a string that looks for a GameObject of the same name:

//disable an object
function disableGameObject (objectName: String) {
	object = GameObject.Find(objectName);
	object.renderer.enabled = false;
}

//enable an object
function enableGameObject (objectName: String) {
	object = GameObject.Find(objectName);
	object.renderer.enabled = true;
}

Incidentally, due to the fact that the workaround was a code solution, this should probably be moved to the scripting forum.

Could you submit a bug with sample project on this? - I would like someone eventually to fix this if it’s an actual bug.

I would like to mention that this is also happening to me, as of unity 3.2 build x_x’…

EDIT: nevermind, I just read an unity answer that stated that these events only accept non-scene object references which is pretty counter-intuitive to me, but meh…

I already mentioned it in case 376644 a few month ago

I would love to see this fixed, too.


oxl

If this is true, I’m missing the sense of it .


oxl