I feel like the answer to this is probably really obvious, so I feel a bit like an idiot for posting it, but is it possible to change materials on child objects of Player prefabs?
Player prefabs are loaded into the scene, so I can't define which object I want to switch the material on in an Action List, right? If you don't assign "Change material" an object that already exists in the scene, it results in a NullReference exception.
Not that that would help, because prefabs' child objects are inaccessible from the defining window, so if I wanted to change a material of an object that wasn't the root object of the prefab, I'd be stuck.
Anyway, is there a workaround for this that I'm not seeing?
Thanks,
— Lurky.
Comments
However, you can still affect the prefab by using ActionList assets, instead of scene-based prefabs:
-Create a new ActionList asset and give it the Object: Change material Action
-Drag the Player prefab into the scene
-Assign the Player's child object (from the scene) into the Action's field
-A Constant ID number will be auto-generated on the object, and displayed in the Action
-Find the Constant ID component on the child object, and check Retain in prefab?
-Click Apply on the Player's scene object to update the prefab, and remove it from the scene
The asset will refer to the player's child via the Constant ID number, which will persist among all scenes, instead of the actual object reference.
Thanks a lot, Chris!
— Lurky.