# How to set keys for emission on/off for a prefab?

I am making a prototype for a Mario game and am having difficulty completing a canned animation for a prefab. There is an item box asset that has 3 materials and an "ItemGet" animation. One of these materials has an active emission property that is supposed to turn off during a specific frame of the "ItemGet" animation. These boxes will have an "Active" and "Inactive" state.

• While "Active", the item box just bobs up and down and IF Mario hits the trigger, the "ItemGet" animation plays (and the player gets a unique item). The box then becomes "Inactive".
• While "Inactive", no animations play, the emission effect is gone and the trigger cannot be reactivated.

Challenges:

• finding the correct property to set a keyframe for in the Animations panel.
• Making sure Active versions of the prefab remain Active after any ItemBox becomes Inactive and that all materials don't change when GetItem plays.

Ideas:

• Instead of keying the emission on/off property (assuming that exists and does what I think it does; trouble finding it), swap the materials.
• ( . . . ), swap the mesh.

Can somebody please help me find a viable way to finish this animation that fits this object's intended use-case?

• For the standard shader, the emission property is easy to find inside the animation: GameObject -> MeshRenderer -> Material -> _EmissionColor. If your material is authored differently though the path may differ. Jun 25, 2019 at 3:18
• Changing that changed the color for the entire object for some reason, all 3 materials changed Jun 25, 2019 at 9:27
• To change just one material, you can use the MaterialReference[i] property, where i is the index of the material you want to change within the renderer's array. Jun 25, 2019 at 10:57