Hi. Does unity currently have any way to get control over adding assets to gameobjects? I am making a custom gameobject type that needs to update its data when a specific sub-gameobject gets a new material/texture in the editor (when a new texture is dragged onto it, for example). I haven’t seen much about this in my search.
GameObject is a sealed class… I don’t think you’re making a “custom gameobject type”.
ScriptableObject? MonoBehaviour? Component?
As for knowing that something changed, I doubt there’s any event fired when something like that happen. You could always build a dictionary of object/material pair and retest it every a few times per second.
Sort of what LightStriker said, you can do this without making your own “custom gameobject type.” There is no need to check the assets on a GameObject, as this can be solved with scripting. When the action is done to change the texture, make sure there is also a part of it that calls a function on the other gameObject, so it can make whatever needs to happen happen elsewhere.
Also, if you want to make this a generic script, you’d need lookup tables/states/dictionaries. Otherwise, when whatever script or such changes the material/texture in game, make sure it also makes the other GameObject change.
When I said “custom gameobject type” I didn’t mean anything super specific. I just meant that I’m adding a new menu item in the editor (this is a design-time, editor extension) that creates a specifically configured set of gameobjects and components that work together. The top level parent has a custom inspector that works as a front-end for the system. This front-end needs to be aware of what material/texture exists on the mesh of one of the other gameobjects. Currently, dragging materials into the scene view is an easy way to bypass this system and assign a material without the front-end being aware.
I was hoping to avoid repeatedly checking for material changes, but it seems like the most appropriate solution now that you’ve pointed it out. Thank you both for your help.