> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.unity.editor/ks.unity.editor.kseditorutils.md).

# Class ksEditorUtils

Namespace: [KS.Unity.Editor](/reactor/api-reference/ks.unity.editor.md)\
Assembly: KSUnity-Editor.dll

Editor utilities

```csharp
public class ksEditorUtils
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) ← [ksEditorUtils](/reactor/api-reference/ks.unity.editor/ks.unity.editor.kseditorutils.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Properties

### IsMPPMVirtualPlayer <a href="#ks_unity_editor_kseditorutils_ismppmvirtualplayer" id="ks_unity_editor_kseditorutils_ismppmvirtualplayer"></a>

Detects if the editor instance is a Multiplayer Playmode virtual player by checking the application data path and for the presence of a MPPMVersion.json file.

```csharp
public static bool IsMPPMVirtualPlayer { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### IsUnityFocused <a href="#ks_unity_editor_kseditorutils_isunityfocused" id="ks_unity_editor_kseditorutils_isunityfocused"></a>

Is Unity the focused application?

```csharp
public static bool IsUnityFocused { get; }
```

#### Property Value

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### UnityVersion <a href="#ks_unity_editor_kseditorutils_unityversion" id="ks_unity_editor_kseditorutils_unityversion"></a>

Unity editor version

```csharp
public static ksVersion UnityVersion { get; }
```

#### Property Value

[ksVersion](/reactor/api-reference/ks.reactor.client/ks.reactor.client.ksversion.md)

## Methods

### CenterWindow(EditorWindow, float, float) <a href="#ks_unity_editor_kseditorutils_centerwindow_unityeditor_editorwindow_system_single_system_single" id="ks_unity_editor_kseditorutils_centerwindow_unityeditor_editorwindow_system_single_system_single"></a>

Resizes and centers a window in the center of the Unity editor.

```csharp
public static void CenterWindow(EditorWindow window, float width = 400, float height = 150)
```

#### Parameters

`window` EditorWindow

window to center.

`width` [float](https://learn.microsoft.com/dotnet/api/system.single)

width for the window in pixels.

`height` [float](https://learn.microsoft.com/dotnet/api/system.single)

height for the window in pixels.

### ClearDefineSymbol(string) <a href="#ks_unity_editor_kseditorutils_cleardefinesymbol_system_string" id="ks_unity_editor_kseditorutils_cleardefinesymbol_system_string"></a>

Clears a define symbol for the current build target.

```csharp
public static bool ClearDefineSymbol(string symbol)
```

#### Parameters

`symbol` [string](https://learn.microsoft.com/dotnet/api/system.string)

symbol to clear

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the define symbol was removed. False if it was not defined.

### FindWindow(string) <a href="#ks_unity_editor_kseditorutils_findwindow_system_string" id="ks_unity_editor_kseditorutils_findwindow_system_string"></a>

Finds a window of a type from the UnityEditor namespace if it is open. This can be used to get instances of internal Unity windows.

```csharp
public static EditorWindow FindWindow(string className)
```

#### Parameters

`className` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of editor window class to find instance of.

#### Returns

EditorWindow

window, or null if the window wasn't found.

### FindWindows(string, Assembly) <a href="#ks_unity_editor_kseditorutils_findwindows_system_string_system_reflection_assembly" id="ks_unity_editor_kseditorutils_findwindows_system_string_system_reflection_assembly"></a>

Finds all open windows of a type from the UnityEditor namespace. This can be used to get instances of internal Unity windows.

```csharp
public static Object[] FindWindows(string className, Assembly assembly = null)
```

#### Parameters

`className` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of editor window class to find instances of.

`assembly` [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

Assembly to load from. If null, loads from the EditorWindow's assembly.

#### Returns

Object\[]

windows of the given class name.

### FocusInspectorWindow() <a href="#ks_unity_editor_kseditorutils_focusinspectorwindow" id="ks_unity_editor_kseditorutils_focusinspectorwindow"></a>

Focuses the inspector window. Opens it if it is not already open.

```csharp
public static void FocusInspectorWindow()
```

### GetAssetPath(Object) <a href="#ks_unity_editor_kseditorutils_getassetpath_unityengine_object" id="ks_unity_editor_kseditorutils_getassetpath_unityengine_object"></a>

Gets the asset path for an asset. If the object is part of the prefab stage, gets prefab's asset path.

```csharp
public static string GetAssetPath(Object asset)
```

#### Parameters

`asset` Object

Asset to get path for.

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

Asset path, or null if the object is not an asset or part of a prefab stage.

### GetEditorPosition() <a href="#ks_unity_editor_kseditorutils_geteditorposition" id="ks_unity_editor_kseditorutils_geteditorposition"></a>

Gets the position of the Unity editor in screen pixels.

```csharp
public static Rect GetEditorPosition()
```

#### Returns

Rect

position of the Unity editor.

### GetPrefabStage(Object) <a href="#ks_unity_editor_kseditorutils_getprefabstage_unityengine_object" id="ks_unity_editor_kseditorutils_getprefabstage_unityengine_object"></a>

Gets the prefab stage containing a component or game object.

```csharp
public static PrefabStage GetPrefabStage(Object componentOrGameObject)
```

#### Parameters

`componentOrGameObject` Object

Component or game object to get prefab stage for.

#### Returns

PrefabStage

Prefab stage for the component or game object, or null if it is not part of a prefab stage.

### GetPropertyType(SerializedProperty) <a href="#ks_unity_editor_kseditorutils_getpropertytype_unityeditor_serializedproperty" id="ks_unity_editor_kseditorutils_getpropertytype_unityeditor_serializedproperty"></a>

Gets the type of a serialized property using reflection.

```csharp
public static Type GetPropertyType(SerializedProperty property)
```

#### Parameters

`property` SerializedProperty

Property to get type for.

#### Returns

[Type](https://learn.microsoft.com/dotnet/api/system.type)

The type of the property, or null if it could not be accessed using reflection.

### GetPropertyValue\<T>(SerializedProperty, Object) <a href="#ks_unity_editor_kseditorutils_getpropertyvalue__1_unityeditor_serializedproperty_unityengine_object" id="ks_unity_editor_kseditorutils_getpropertyvalue__1_unityeditor_serializedproperty_unityengine_object"></a>

Gets the value of a serialized property using reflection.

```csharp
public static T GetPropertyValue<T>(SerializedProperty property, Object target = null)
```

#### Parameters

`property` SerializedProperty

property to get value from.

`target` Object

target object to get property value from. If null, uses the property target.

#### Returns

T

value of the property.

#### Type Parameters

`T`

### GetReleaseId() <a href="#ks_unity_editor_kseditorutils_getreleaseid" id="ks_unity_editor_kseditorutils_getreleaseid"></a>

Get the Unity package release ID

```csharp
public static string GetReleaseId()
```

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

UUID for the current package release

### GetUnityUserDisplayName() <a href="#ks_unity_editor_kseditorutils_getunityuserdisplayname" id="ks_unity_editor_kseditorutils_getunityuserdisplayname"></a>

Gets the Unity user's display name.

```csharp
public static string GetUnityUserDisplayName()
```

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

Display name

### GetUnityUserId() <a href="#ks_unity_editor_kseditorutils_getunityuserid" id="ks_unity_editor_kseditorutils_getunityuserid"></a>

Get the Unity user's account ID

```csharp
public static string GetUnityUserId()
```

#### Returns

[string](https://learn.microsoft.com/dotnet/api/system.string)

### IsInResourcesOrAssetBundle(Object) <a href="#ks_unity_editor_kseditorutils_isinresourcesorassetbundle_unityengine_object" id="ks_unity_editor_kseditorutils_isinresourcesorassetbundle_unityengine_object"></a>

Checks if an object is an asset is in a Resources folder or an asset bundle.

```csharp
public static bool IsInResourcesOrAssetBundle(Object uobj)
```

#### Parameters

`uobj` Object

Object to check.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the object is an asset in Resources or an asset bundle.

### IsResourceOrAssetBundlePrefabInstance(Object) <a href="#ks_unity_editor_kseditorutils_isresourceorassetbundleprefabinstance_unityengine_object" id="ks_unity_editor_kseditorutils_isresourceorassetbundleprefabinstance_unityengine_object"></a>

Checks if an object is an instance of a prefab from Resources or an asset bundle.

```csharp
public static bool IsResourceOrAssetBundlePrefabInstance(Object uobj)
```

#### Parameters

`uobj` Object

Object to check.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the object is an instance of a prefab from Resources or an asset bundle.

### LoadAssembly(string) <a href="#ks_unity_editor_kseditorutils_loadassembly_system_string" id="ks_unity_editor_kseditorutils_loadassembly_system_string"></a>

Loads an assembly by name. Logs an error if the assembly cannot be loaded.

```csharp
public static Assembly LoadAssembly(string assemblyName)
```

#### Parameters

`assemblyName` [string](https://learn.microsoft.com/dotnet/api/system.string)

Name of assembly to load

#### Returns

[Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

Assembly, or null if it could not be loaded.

### OpenWindow(string, Assembly) <a href="#ks_unity_editor_kseditorutils_openwindow_system_string_system_reflection_assembly" id="ks_unity_editor_kseditorutils_openwindow_system_string_system_reflection_assembly"></a>

Opens a window of a type from the UnityEditor namespace. If a window of the type is already open, returns it. This can be used to open internal Unity windows.

```csharp
public static EditorWindow OpenWindow(string className, Assembly assembly = null)
```

#### Parameters

`className` [string](https://learn.microsoft.com/dotnet/api/system.string)

name of editor window class to open.

`assembly` [Assembly](https://learn.microsoft.com/dotnet/api/system.reflection.assembly)

Assembly to load from. If null, loads from the EditorWindow's assembly.

#### Returns

EditorWindow

window, or null if the window could not be opened.

### RefreshInspectorWindow(bool) <a href="#ks_unity_editor_kseditorutils_refreshinspectorwindow_system_boolean" id="ks_unity_editor_kseditorutils_refreshinspectorwindow_system_boolean"></a>

Refreshes the inspector window.

```csharp
public static void RefreshInspectorWindow(bool rebuildInspectors = false)
```

#### Parameters

`rebuildInspectors` [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

if true, inspectors will be rebuilt.

### SetDefineSymbol(string) <a href="#ks_unity_editor_kseditorutils_setdefinesymbol_system_string" id="ks_unity_editor_kseditorutils_setdefinesymbol_system_string"></a>

Sets a define symbol for the current build target.

```csharp
public static bool SetDefineSymbol(string symbol)
```

#### Parameters

`symbol` [string](https://learn.microsoft.com/dotnet/api/system.string)

symbol to define.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

true if the define symbol was added. False if it was already defined.

### TryGetPropertyValue\<T>(SerializedProperty, out T, Object) <a href="#ks_unity_editor_kseditorutils_trygetpropertyvalue__1_unityeditor_serializedproperty___0__unityengine" id="ks_unity_editor_kseditorutils_trygetpropertyvalue__1_unityeditor_serializedproperty___0__unityengine"></a>

Tries to get the value of a serialized property using reflection.

```csharp
public static bool TryGetPropertyValue<T>(SerializedProperty property, out T value, Object target = null)
```

#### Parameters

`property` SerializedProperty

property to get value from.

`value` T

Set to the value of the property.

`target` Object

target object to get property value from. If null, uses the property target.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

True if the property value was retrieved successfully.

#### Type Parameters

`T`
