Skip to content

Commit 52a8a25

Browse files
committed
WARNING: The following changes may affect your project if you're updating from an older version:
- DraggedReferenceSourceUI component's "Object Reference" variable is changed to "Object[] References" - Moved "Can Drop Parent On Child" and "Can Add Objects To Pseudo Scenes" properties from HierarchyDragDropListener to RuntimeHierarchy - "hierarchy.Select(someTransform)" function's equivalent is now "hierarchy.Select(someTransform, RuntimeHierarchy.SelectOptions.FocusOnSelection)" - RuntimeHierarchy's "Create Dragged References On Hold" property is changed to "Pointer Long Press Action" Release Notes: - Added "Multi Selection" option to RuntimeHierarchy: -- SelectionChangedDelegate now takes ReadOnlyCollection<Transform> parameter -- CurrentSelection returns ReadOnlyCollection<Transform> -- Select function has a variant that takes IList<Transform> -- Deselect function has variants that allow deselecting only a subset of the selection -- Added IsSelected function to check if a Transform is selected - Added tooltip support to RuntimeHierarchy (when enabled, hovering the cursor over a Transform for a while will display its name in a tooltip) - Added "bool IsLocked" property to RuntimeInspector and RuntimeHierarchy which prevents changing the inspected/selected object from outside (similar to Unity's own Inspector lock) - Space between expand arrow and the label next to it is now configurable via UISkin - Expand arrows now scale correctly with UISkin's Line Height
1 parent bb9b941 commit 52a8a25

37 files changed

+1924
-417
lines changed

.github/README.md

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Runtime Inspector & Hierarchy for Unity 3D
22

3-
![screenshot](images/img1.png)
3+
![screenshot](Images/DarkSkin.png)
44

55
**Available on Asset Store:** https://assetstore.unity.com/packages/tools/gui/runtime-inspector-hierarchy-111349
66

@@ -51,20 +51,22 @@ This plugin supports Unity's new Input System but it requires some manual modifi
5151

5252
## E. FEATURES
5353

54-
- The hierarchy costs **1 SetPass call** and **~5 batches** (assuming that **Sprite Packing** is enabled in *Editor Settings*)
55-
- The inspector costs **1 SetPass call** and **~10 batches** (assuming that **Sprite Packing** is enabled in *Editor Settings*)
56-
- Both panels are heavily optimized in terms of GC in order not to generate any unnecessary garbage. By default, both the inspector and the hierarchy are refreshed 4 times a second to reflect any changes to their user interface almost immediately. Each refresh of the inspector generates some garbage for GC since most of the time, the inspected object has variables of value types. These variables are *boxed* when accessed via reflection and this boxing creates some unavoidable garbage. However, this process can be greatly optimized by increasing the **Refresh Interval** of the inspector and/or the hierarchy
54+
- Both panels are heavily optimized in terms of GC in order not to cause any unnecessary allocations. By default, both the inspector and the hierarchy are refreshed 4 times a second to reflect any changes to their user interface almost immediately. Each refresh of the inspector generates some garbage for GC since most of the time, the inspected object has variables of value types. These variables are *boxed* when accessed via reflection and this boxing creates some unavoidable garbage. However, this process can be greatly optimized by increasing the **Refresh Interval** of the inspector and/or the hierarchy
5755
- Includes a built-in color picker and a reference picker:
5856

59-
![screenshot](images/img2.png)
57+
![screenshot](Images/Pickers.png)
6058

6159
- Visual appearance of the inspector and the hierarchy can be tweaked by changing their **Skin**. There are two premade skins included in the **Skins** directory: *LightSkin* and *DarkSkin*. You can create your own skins using the **Assets-Create-yasirkula-RuntimeInspector-UI Skin** context menu
6260

63-
![screenshot](images/img3.png)
61+
![screenshot](Images/LightSkin.png)
62+
63+
- The hierarchy supports multi-selection:
64+
65+
![screenshot](Images/HierarchyMultiSelection.png)
6466

6567
### E.1. INSPECTOR
6668

67-
![screenshot](images/img4.png)
69+
![screenshot](Images/InspectorProperties.png)
6870

6971
RuntimeInspector works similar to the editor Inspector. It can expose commonly used Unity types out-of-the-box, as well as custom classes and structs that are marked with **System.Serializable** attribute. 1-dimensional arrays and generic Lists are also supported.
7072

@@ -96,33 +98,40 @@ While changing the inspector's settings, you are advised not to touch **Internal
9698

9799
### E.2. HIERARCHY
98100

99-
![screenshot](images/img5.png)
101+
![screenshot](Images/HierarchyProperties.png)
100102

101103
RuntimeHierarchy simply exposes the objects in your scenes to the user interface. In addition to exposing the currently active Unity scenes in the hierarchy, you can also expose a specific set of objects under what is called a **pseudo-scene** in the hierarchy. Pseudo-scenes can help you categorize the objects in your scene. Adding/removing objects to/from pseudo-scenes is only possible via the scripting API and helper components.
102104

103105
- **Refresh Interval**: the refresh interval of the hierarchy. At each refresh, the destroyed objects are removed from the hierarchy while newly created objects are added to the hierarchy. Sibling indices of the objects are also synced with the Unity Hierarchy at each refresh
104106
- **Object Names Refresh Interval**: accessing **GameObject.name** property generates garbage. Therefore, names of objects in the hierarchy are not synced at each *Refresh Interval* but rather at each *Object Names Refresh Interval* to help avoid excessive garbage
105107
- **Search Refresh Interval**: the refresh interval for the search results. At each refresh, each GameObject's name is checked to see if it matches the searched term, so this process will generate some garbage
108+
- **Allow Multi Selection**: when disabled, only a single Transform can be selected in the hierarchy
106109
- **Expose Unity Scenes**: when disabled, Unity scenes are not exposed in the hierarchy. This is useful when you want to use the hierarchy solely for pseudo-scenes
107-
- **Exposed Scenes**: specifies the scenes that are exposed in the hierarchy by their name. When empty, all scenes are exposed
110+
- **Exposed Unity Scenes Subset**: specifies the scenes that are exposed in the hierarchy by their name. When empty, all scenes are exposed
108111
- **Expose Dont Destroy On Load Scene**: when enabled, *DontDesroyOnLoad* objects will be exposed in the hierarchy
109112
- **Pseudo Scenes Order**: the order of the pseudo-scenes from top to bottom in the hierarchy. Note that entering a pseudo-scene here does not automatically create it when the application starts. Pseudo-scenes can be created via the scripting API only
110-
- **Create Dragged Reference On Hold**: when enabled, if you click and hold on an object in the hierarchy for a while, a **dragged reference item** will be created that can be dropped on a *reference drawer* in the inspector to assign that object to that variable (similar to Unity's drag&drop reference assignment)
111-
- **Dragged Reference Hold Time**: this value defines the hold time in seconds before a dragged reference item is created
112-
- **Can Reorganize Items**: when enabled, dropping a dragged reference item that holds a Transform onto an object in the hierarchy will change the dragged Transform's parent (similar to parenting in Unity's Hierarchy)
113+
- **Pointer Long Press Action**: determines what will happen when an object is clicked and then held for a while:
114+
- **None**: nothing ¯\\\_(ツ)\_
115+
- **Create Dragged Reference Item**: creates a **dragged reference item** that can be dropped onto a *reference drawer* in the inspector to assign the held object(s) to that variable (similar to Unity's drag&drop reference assignment)
116+
- **Show Multi Selection Toggles**: displays multi-selection toggles in front of each object. This is mostly useful on mobile devices where CTRL and Shift keys aren't present. Has no effect if *Allow Multi Selection* is disabled
117+
- **Show Multi Selection Toggles Then Create Dragged Reference Item**: if multi-selection toggles aren't visible, displays them. Otherwise, creates a dragged reference item
118+
- **Pointer Long Press Duration**: determines how long an object should be held until the *Pointer Long Press Action* is executed
113119
- **Double Click Threshold**: when an object in the hierarchy is double clicked, **OnItemDoubleClicked** event is raised (see *SCRIPTING API*). This value determines the maximum allowed delay between two clicks to register a double click
120+
- **Can Reorganize Items**: when enabled, dropping a dragged reference item that holds Transform(s) onto an object in the hierarchy will change the dragged Transform(s)' parents (similar to parenting in Unity's Hierarchy)
121+
- **Can Drop Dragged Parent On Child**: when enabled, a dragged reference item can be dropped onto one of its child objects. In this case, the child object will be unparented and then the dragged reference item will become a child of it. Has no effect if *Can Reorganize Items* is disabled
122+
- **Can Drop Dragged Objects To Pseudo Scenes**: when enabled, dropping a dragged reference item onto a pseudo-scene or above/below a root object in the pseudo-scene will automatically add it to that pseudo-scene. Has no effect if *Can Reorganize Items* is disabled
123+
- **Show Tooltips**: when enabled, hovering over an object for a while will show a tooltip displaying the object's name. Can be useful for objects with very long names
124+
- **Tooltip Delay**: determines how long the cursor should remain static over an object before the tooltip appears. Has no effect if *Show Tooltips* is disabled
114125
- **Show Horizontal Scrollbar**: when enabled, a horizontal scrollbar will be displayed if the names displayed in the hierarchy don't fit the available space. Note that only the visible items' width values are used to determine the size of the scrollable area
115126
- **Sync Selection With Editor Hierarchy**: simply synchronizes the selected object between the Unity Hierarchy and this RuntimeHierarchy
116127

117128
Additional settings for *Can Reorganize Items* can be found at the *RuntimeHierarchy/ScrollView/Viewport* object:
118129

119-
![screenshot](images/img6.png)
130+
![screenshot](Images/HierarchyDropListenerProperties.png)
120131

121132
- **Sibling Index Modification Area**: when a dragged reference item is dropped near the top or bottom edges of a Transform in hierarchy, it will be inserted above or belove the target Transform. This value determines the size of the area near the top and bottom edges
122133
- **Scrollable Area**: while hovering the cursor near the top or bottom edges of the scroll view with a dragged reference item, scroll view will automatically be scrolled to show contents in that direction. This value determines the size of the area near the top and bottom edges of the scroll view
123134
- **Scroll Speed**: determines how fast the scroll view will be scrolled while hovering the cursor over *Scrollable Area*
124-
- **Can Drop Parent On Child**: when enabled, a dragged reference item can be dropped onto one of its child objects. In this case, the child object will be unparented and then the dragged reference item will become a child of it
125-
- **Can Add Objects To Pseudo Scenes**: when enabled, dropping a dragged reference item onto a pseudo-scene or above/below a root object in the pseudo-scene will automatically add it to that pseudo-scene
126135

127136
## F. SCRIPTING API
128137

@@ -139,12 +148,26 @@ public void StopInspect();
139148
- You can change the selected object in the hierarchy using the following functions:
140149

141150
```csharp
142-
public bool Select( Transform selection ); // returns true when the selection is changed successfully
143-
public void Deselect();
151+
// SelectOptions is an enum flag meaning that it can take multiple values with | (OR) operator. These values are:
152+
// - Additive: new selection will be appended to the current selection instead of replacing it
153+
// - FocusOnSelection: scroll view will be snapped to the selected object(s)
154+
// - ForceRevealSelection: normally, when selection changes, the new selection will be fully explored in the hierarchy (i.e. all of the parents of the selection will be
155+
// expanded to reveal the selection). This doesn't automatically happen if selection doesn't change. When this flag is set, however, the selected objects will be fully
156+
// revealed/explored even if the selection doesn't change
157+
public bool Select( Transform selection, SelectOptions selectOptions = SelectOptions.None ); // Selects the specified Transform. Returns true when the selection is changed successfully
158+
public bool Select( IList<Transform> selection, SelectOptions selectOptions = SelectOptions.None ); // Selects the specified Transform(s)
159+
160+
public void Deselect(); // Deselects all Transforms
161+
public void Deselect( Transform deselection ); // Deselects only the specified Transform
162+
public void Deselect( IList<Transform> deselection ); // Deselects only the specified Transform(s)
163+
164+
public bool IsSelected( Transform transform ); // Returns true if the selection includes the Transform
144165
```
145166

146-
- You can access the currently selected object in the hierarchy via the `CurrentSelection` property
167+
- You can access the currently selected object(s) in the hierarchy via the `CurrentSelection` property
168+
- Hierarchy's multi-selection toggles can be enabled manually via the `MultiSelectionToggleSelectionMode` property
147169
- You can call the `Refresh()` function on the inspector and/or the hierarchy to refresh them manually
170+
- You can lock the inspector and/or the hierarchy via the `IsLocked` property
148171
- You can register to the `OnSelectionChanged` event of the hierarchy to get notified when the selection has changed
149172
- You can register to the `OnInspectedObjectChanging` delegate of the inspector to get notified when the inspected object is about to change and, if you prefer, change the inspected object altogether. For example, if you want to inspect only objects that have a *Renderer* component attached, you can use the following function:
150173

@@ -270,12 +293,13 @@ private Object CreateDraggedReferenceItemForNPCsOnly( RaycastHit hit )
270293
}
271294
```
272295

273-
- **DraggedReferenceSourceUI**: when assigned to a UI element, that element can create a dragged reference item for its **Reference** object after it is clicked and held for a while
296+
- **DraggedReferenceSourceUI**: when assigned to a UI element, that element can create a dragged reference item for its **References** object(s) after it is clicked and held for a while
274297

275-
You can also use your own scripts to create dragged reference items by calling the following function in the **RuntimeInspectorUtils** class:
298+
You can also use your own scripts to create dragged reference items by calling the following functions in the **RuntimeInspectorUtils** class:
276299

277300
```csharp
278301
public static DraggedReferenceItem CreateDraggedReferenceItem( Object reference, PointerEventData draggingPointer, UISkin skin = null );
302+
public static DraggedReferenceItem CreateDraggedReferenceItem( Object[] references, PointerEventData draggingPointer, UISkin skin = null, Canvas referenceCanvas = null );
279303
```
280304

281305
## G. CUSTOM DRAWERS (EDITORS)
@@ -387,7 +411,7 @@ Inside *GenerateElements* function, you can call **parent** parameter's **Create
387411

388412
Here are some example custom drawers:
389413

390-
![screenshot](images/CustomColliderEditor.png)
414+
![screenshot](Images/CustomColliderEditor.png)
391415

392416
```csharp
393417
// Custom drawer for Collider type and the types that derive from it
@@ -408,7 +432,7 @@ public class ColliderEditor : IRuntimeInspectorCustomEditor
408432

409433
---
410434

411-
![screenshot](images/CustomMeshRendererEditor.png)
435+
![screenshot](Images/CustomMeshRendererEditor.png)
412436

413437
```csharp
414438
// Custom drawer for MeshRenderer type (but not the types that derive from it)
@@ -434,7 +458,7 @@ public class MeshRendererEditor : IRuntimeInspectorCustomEditor
434458

435459
---
436460

437-
![screenshot](images/CustomCameraEditor.png)
461+
![screenshot](Images/CustomCameraEditor.png)
438462

439463
```csharp
440464
// Custom drawer for Camera type (but not the types that derive from it)
File renamed without changes.
8.34 KB
Loading
31.8 KB
Loading
28.3 KB
Loading
24.2 KB
Loading
File renamed without changes.
File renamed without changes.

.github/images/img4.png

-23.8 KB
Binary file not shown.

.github/images/img5.png

-20 KB
Binary file not shown.

0 commit comments

Comments
 (0)