class ManagedEditorWindow

Allows user to create dockable editor windows in managed code.

Each managed editor window implementation is wrapped in this object and then managed by its parent interop object of ScriptEditorWindow type.

Public

Constructors

ManagedEditorWindow

ManagedEditorWindow(const String &ns, const String &type, const GUIPhysicalSize &defaultSize, bool localUndoRedo, EditorWindowTabGroup &tabGroup)

Constructs a new managed window.

ns
Namespace of the window type.
type
Name of the window type.
defaultSize
Default width/height of the window when initially created.
localUndoRedo
Determines should the window use a local undo/redo stack instead of the global one.
tabGroup
Container to initially dock the window in.

Methods

~ManagedEditorWindow

~ManagedEditorWindow() noexcept

staticCreateScriptObject

static MonoObject *CreateScriptObject(const String &ns, const String &typeName)

Attempts to create a script object for the editor window described by the provided type.

Returned object will not have the constructor called.

IsInitialized

bool IsInitialized() const

Checks has the OnInitialize method been called yet.

GetNamespace

String GetNamespace() const

Returns the namespace of the managed window type.

GetTypename

String GetTypename() const

Returns the managed window type name.

Update

void Update() override

Called once every frame.

Close

void Close() override

Closes and destroys the window.

WrapCursorToWindow

GUIPhysicalPoint WrapCursorToWindow() const

Moves the cursor so it is within the window bounds.

Returns the offset that the cursor was moved by.

IsPointerOverWindow

bool IsPointerOverWindow() const

Checks is the pointer currently over the window area.

SetupScriptBindings

void SetupScriptBindings()

Sets up script bindings between native and managed class.

Must be called after creating the script object wrapper, or after assembly is reloaded.

TriggerOnInitialize

void TriggerOnInitialize()

Triggers OnInitialize callbacks on the managed instance.

TriggerOnDestroy

void TriggerOnDestroy()

Triggers OnDestroy callbacks on the managed instance.

GetUndoRedo

SPtr<UndoRedo> GetUndoRedo() const

Returns the local undo/redo stack specific to this editor window.

Only windows marked with [UndoRedoLocal] attribute will return a non-null value.

staticGetOrOpenWindow

static SPtr<ManagedEditorWindow> GetOrOpenWindow(const String &nameSpace, const String &typeName)

Attempts to find an existing managed editor window with the provided name, or if not found attempts to open a new instance of the window.

nameSpace
Namespace of the managed window type.
typeName
Type name of the managed window type.

Returns: Instance of the managed window, or null if window cannot be found or opened.

staticGetWindow

static SPtr<ManagedEditorWindow> GetWindow(const String &nameSpace, const String &typeName)

Attempts to find a currently open managed editor window with the provided name.

nameSpace
Namespace of the managed window type.
typeName
Type name of the managed window type.

Returns: Instance of the managed window, or null if an open window is not found.

staticGetAllOpenWindows

static Vector<SPtr<ManagedEditorWindow>> GetAllOpenWindows()

Returns a list of all currently open managed windows.

Internal

Methods

staticRegisterManagedEditorWindows

static void RegisterManagedEditorWindows()

Finds all editor window implementations in managed assemblies and registers them with the editor window system.

staticClearRegisteredEditorWindows

static void ClearRegisteredEditorWindows()

Removes all editor windows registered previously with RegisterManagedEditorWindows().

Useful during assembly refresh when editor window implementations might be added/removed.

Private

Methods

ShouldPersistScriptReload

bool ShouldPersistScriptReload() const override

If true, the object will be given an opportunity to back up its data before a script reload operation, and its script object will be automatically recreated once script reload ends, and given an opportunity to restore the backed up data.

If false, the script object and its wrapper will be destroyed on script reload.

NotifyScriptWillReload

void NotifyScriptWillReload() override

Called on all script objects before script object reload happens.

RecreateScriptObjectAfterScriptReload

bool RecreateScriptObjectAfterScriptReload() override

Called on all script objects after script assemblies have been reloaded.

This needs to recreate the internal script object using the new assemblies, as the old one will have been destroyed during the reload. Only relevant for script objects that persist script reload (i.e. ShouldPersistScriptReload() returns true). Returns true if the script object was created, otherwise the responsibility will fall to the script object wrapper.

NotifyScriptReloadFinished

void NotifyScriptReloadFinished() override

Called on all script object wrappers as the final step in script reload, after RestoreDataAfterScriptReload().

Allows you to perform actions that require the entire scripting world to be fully recreated.

DoOnWindowResized

void DoOnWindowResized(const GUIPhysicalSize &size)

Triggered when the native editor window is resized.

DoOnFocusChanged

void DoOnFocusChanged(bool inFocus)

Triggered when the native editor window gains or loses focus.

staticRegisterScriptEditorWindow

static void RegisterScriptEditorWindow(const SPtr<ManagedEditorWindow> &editorWindow)

Registers a newly created editor window interop object and adds it to a list of currently active editor windows.

staticUnregisterScriptEditorWindow

static void UnregisterScriptEditorWindow(const String &windowTypeName)

Removes a window from the active editor window list.

windowTypeName
Name of the window type. Provided by ManagedEditorWindow::GetName().

staticOpenEditorWindowCallback

static SPtr<DockableEditorWindow> OpenEditorWindowCallback(String ns, String type, const GUIPhysicalSize &size, bool localUndoRedo, EditorWindowTabGroup &parentTabGroup)

Callback that is triggered when user requests a window to be opened.

Fields

mNamespace

String mNamespace

mTypename

String mTypename

mOnInitializeThunk

OnInitializeThunkDef mOnInitializeThunk

mOnDestroyThunk

OnDestroyThunkDef mOnDestroyThunk

mUpdateThunk

UpdateThunkDef mUpdateThunk

mDoOnFocusChangedMethod

MonoMethod * mDoOnFocusChangedMethod

mDoOnWindowResizedMethod

MonoMethod * mDoOnWindowResizedMethod

mGetDisplayNameMethod

MonoMethod * mGetDisplayNameMethod

mIsInitialized

bool mIsInitialized

mUndoRedo

SPtr<UndoRedo> mUndoRedo