Skip to content

moonymachine/scrutable-objects

Repository files navigation

Scrutable Objects

Enables direct access to the properties of ScriptableObject references in the editor.

Installation

This package can be installed via Unity's Package Manager.

To install without using the Package Manager, add the contents of this repository to the Assets directory.

Usage

ShowProperties Attribute

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;
}

LockObjectAtRuntime Argument

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.

Lists and Arrays

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;
}

Apply to Types

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
{

}

About

Enables direct access to the properties of ScriptableObject references in the editor.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages