Enables direct access to the properties of ScriptableObject references in the editor.
This package can be installed via Unity's Package Manager.
- Open the Package Manager window.
- Open the Add (+) menu in the toolbar.
- Select the "Install package from git URL" button.
- Enter this URL: https://github.com/moonymachine/scrutable-objects.git
- Select Install.
To install without using the Package Manager, add the contents of this repository to the Assets directory.
Apply the [ShowProperties]
attribute to any ScriptableObject property to display the properties of whatever object is assigned.
using ScrutableObjects;
using UnityEngine;
public class ExampleMonoBehaviour : MonoBehaviour
{
[ShowProperties]
public ScriptableObject ScriptableObjectProperty;
}
Use the LockObjectAtRuntime
property to disable changing the ScriptableObject reference at runtime in the editor.
using ScrutableObjects;
using UnityEngine;
public class ExampleMonoBehaviour : MonoBehaviour
{
[ShowProperties(LockObjectAtRuntime = true)]
public ScriptableObject ScriptableObjectProperty;
}
Note that this does not prevent all ways of changing the object reference at runtime, so write your code defensively.
The [ShowProperties]
attribute can be applied to lists and arrays as well.
using ScrutableObjects;
using UnityEngine;
public class ExampleMonoBehaviour : MonoBehaviour
{
[ShowProperties]
public List<ScriptableObject> ScriptableObjectList;
[ShowProperties]
public ScriptableObject[] ScriptableObjectArray;
}
To automatically apply to specific types of ScriptableObject, derive a new property drawer from ScrutableObjectDrawer
for that type.
using ScrutableObjects.UnityEditor;
using UnityEditor;
using UnityEngine;
[CustomPropertyDrawer(typeof(ExampleAsset), true)]
public class ExampleAssetDrawer : ScrutableObjectDrawer
{
}