- Home /
ObjectField Get object type(Asset, Scene Object)
Hey all, so you know how we can use "SelectionMode.Assets" or "SelectionMode.Editable" to only allow certain objects to be selectable in an Editor Script, is there a way to find out if the Object assigned to an ObjectField is an Asset or a Scene Object?
Thanks in advance! Stephane
Answer by ScroodgeM · Aug 05, 2012 at 10:42 AM
in custom inspector: [allowSceneObjects : boolean]
http://docs.unity3d.com/Documentation/ScriptReference/EditorGUI.ObjectField.html
anytime manual checking:
http://docs.unity3d.com/Documentation/ScriptReference/AssetDatabase.Contains.html
Ah AssetDatabase.Contains is what I was looking for, thx Scroodge!
Answer by yoyo · Apr 01, 2015 at 03:57 PM
You can use EditorUtility.IsPersistent to determine whether a game object is (part of) an asset or is from the current scene.