How to check if a component is on an instantiated prefab?

Hi all

I’ve been writing an inspector that has some buttons for aiding the artist in designing asset hierarchies:

alt text

I’ve accidentally discovered that these buttons can be pressed while the Inspector is displaying components of a prefab, which is undesirable.

I’m not sure if the solution is for the MonoBehaviour or the Editor script to prevent this input, but either way I need to be able to check if the component has been instantiated.

Is it possible to check if the current component is in the scene or project?

Thanks,

Ves

Use PrefabUtility.GetPrefabType it will return a PrefabType and with it you can check if its either a Prefab (project window) or a PrefabInstance (scene window)