Skip to content

ScriptableObjectUtility

Namespace: SideXP.Core.EditorOnly

public static class ScriptableObjectUtility

Miscellaneous functions for working with ScriptableObject and assets in the editor.

Methods

GetScriptPath(Type)

public static string GetScriptPath(Type scriptableObjectType)

Gets the path to the source script of the given type of ScriptableObject.

Parameters

  • scriptableObjectType: The type of the ScriptableObject you want to get the script file path.

Returns

Returns the found script path, or null if the path to the script file can't be found.

GetScriptPath(ScriptableObject)

public static string GetScriptPath(ScriptableObject obj)

Gets the path to the source script of the given type of ScriptableObject.

Parameters

  • obj: The ScriptableObject you want to get the script path.

Returns

Returns the found script path, or null if the path to the script file can't be found.

GetScriptPath<TScriptableObject>()

public static string GetScriptPath<TScriptableObject>()

Gets the path to the source script of the given type of ScriptableObject.

Type parameters

  • TScriptableObject: The type of the ScriptableObject you want to get the script file path.

Returns

Returns the found script path, or null if the path to the script file can't be found.

ResetToDefaults(ScriptableObject)

public static void ResetToDefaults(ScriptableObject obj)

Reset the given object to its default values. This operation is undoable.

Parameters

  • obj: The object to reset.

Remarks

Since Unity doesn't provide a utility function to do this, this function will create an asset of the same type, and copy its serialized values to the given object.