Class ScyllaEditorHooks
Gives runtime code access to the editor operations it needs, such as a deferred call,
marking an object dirty or exiting Play mode, without referencing UnityEditor.
Inherited Members
Namespace: Scylla.Core.Util
Assembly: ScyllaCore.dll
Syntax
public static class ScyllaEditorHooks
Remarks
Scylla's runtime assemblies ship as DLLs compiled without UNITY_EDITOR, and a
project that installs Scylla as a package runs those same DLLs inside the Editor. Code
behind #if UNITY_EDITOR in a runtime assembly is therefore missing in the Editor
of such a project. Runtime code calls these hooks instead, with no preprocessor guard.
The Scylla Core editor assembly installs the editor side when the editor loads. In a player build nothing is installed: every method does nothing or returns its default, and the events are never raised. IsAvailable tells the two apart.
Properties
IsAvailable
Gets whether the editor side is installed, which is the case in the Editor only.
Declaration
public static bool IsAvailable { get; }
Property Value
| Type | Description |
|---|---|
| bool |
LastActiveSceneViewCamera
Gets the camera of the Scene view that was active last, or null when there is
none or in a player build.
Declaration
public static Camera LastActiveSceneViewCamera { get; }
Property Value
| Type | Description |
|---|---|
| Camera |
Methods
CancelDelayCall(Action)
Removes a callback queued with DelayCall(Action) that has not run yet. Removing a callback that is not queued does nothing.
Declaration
public static void CancelDelayCall(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The callback to remove. |
CopySerialized(Object, Object)
Copies every serialized field of one object onto another of the same type, like
EditorUtility.CopySerialized.
Declaration
public static bool CopySerialized(Object source, Object destination)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | source | The object to copy from. |
| Object | destination | The object to copy onto. |
Returns
| Type | Description |
|---|---|
| bool |
|
DelayCall(Action)
Runs a callback once, after the Inspector has finished updating, like
EditorApplication.delayCall. Does nothing in a player build.
Declaration
public static void DelayCall(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | The callback to run. |
Remarks
A call made in the Editor before the editor side is installed, such as from an
OnValidate during a script reload, is queued and handed over on install.
FindAssets<T>()
Finds every asset of a type in the project, like AssetDatabase.FindAssets
followed by a load of each result.
Declaration
public static T[] FindAssets<T>() where T : Object
Returns
| Type | Description |
|---|---|
| T[] | The assets; an empty array when there are none and always in a player build. |
Type Parameters
| Name | Description |
|---|---|
| T | The asset type. |
GetAssetPath(Object)
Gets the project path of an asset, like AssetDatabase.GetAssetPath.
Declaration
public static string GetAssetPath(Object target)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | target | The asset. |
Returns
| Type | Description |
|---|---|
| string | The path, or an empty string for an object that is not an asset and always in a player build. |
IsPersistent(Object)
Reports whether an object is stored on disk as an asset, like
EditorUtility.IsPersistent.
Declaration
public static bool IsPersistent(Object target)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | target | The object to check. |
Returns
| Type | Description |
|---|---|
| bool |
|
LoadAssetAtPath<T>(string)
Loads an asset by its project path, like AssetDatabase.LoadAssetAtPath.
Declaration
public static T LoadAssetAtPath<T>(string assetPath) where T : Object
Parameters
| Type | Name | Description |
|---|---|---|
| string | assetPath | The project path, such as |
Returns
| Type | Description |
|---|---|
| T | The asset, or |
Type Parameters
| Name | Description |
|---|---|
| T | The asset type. |
RecordUndo(Object, string)
Records an object's state before a change so the change can be undone, like
Undo.RecordObject. Does nothing in a player build.
Declaration
public static void RecordUndo(Object target, string actionName)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | target | The object about to change. |
| string | actionName | The name shown in the Undo menu. |
RepaintSceneViews()
Repaints every open Scene view, like SceneView.RepaintAll. Does nothing in a
player build.
Declaration
public static void RepaintSceneViews()
SetDirty(Object)
Marks an object as changed so the Editor saves it, like EditorUtility.SetDirty.
Does nothing in a player build.
Declaration
public static void SetDirty(Object target)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | target | The changed object. |
TryExitPlayMode()
Leaves Play mode when running in the Editor.
Declaration
public static bool TryExitPlayMode()
Returns
| Type | Description |
|---|---|
| bool |
|
Events
PlayModeStateChanged
Raised in the Editor on every Play mode transition, like
EditorApplication.playModeStateChanged. Never raised in a player build.
Declaration
public static event Action<ScyllaPlayModeStateChange> PlayModeStateChanged
Event Type
| Type | Description |
|---|---|
| Action<ScyllaPlayModeStateChange> |
SceneViewGUI
Raised in the Editor once per Scene view GUI pass, the moment to draw into a Scene view with immediate-mode rendering. Never raised in a player build.
Declaration
public static event Action SceneViewGUI
Event Type
| Type | Description |
|---|---|
| Action |