Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/main' into global-namesp…
Browse files Browse the repository at this point in the history
…ace-watcher
  • Loading branch information
mtschoen-unity committed May 28, 2022
2 parents 39e875b + 8e593ec commit e7b26e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
17 changes: 14 additions & 3 deletions Editor/HiddenInspector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
using UnityEngine;
using UnityObject = UnityEngine.Object;

#if !UNITY_2019_1_OR_NEWER
using UnityEditor.SceneManagement;
#endif

namespace Unity.Labs.SuperScience
{
public class HiddenInspector : EditorWindow
Expand Down Expand Up @@ -104,7 +108,7 @@ void OnGUI()
m_ShowHiddenProperties = EditorGUILayout.Toggle(k_ShowHiddenPropertiesLabel, m_ShowHiddenProperties);
using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollPosition))
{
DrawSerializedObject(target, target);
DrawSerializedObject(target, target, 0);

// Bail on this GUI pass if we've just destroyed the object
if (target == null)
Expand All @@ -114,12 +118,20 @@ void OnGUI()
var components = target.GetComponents<Component>();
for (var i = 0; i < components.Length; i++)
{
#if UNITY_2019_1_OR_NEWER
DrawSerializedObject(components[i], target);
#else
DrawSerializedObject(components[i], target, i);
#endif
}
}
}

#if UNITY_2019_1_OR_NEWER
void DrawSerializedObject(UnityObject drawTarget, GameObject inspectorTarget)
#else
void DrawSerializedObject(UnityObject drawTarget, GameObject inspectorTarget, int i)
#endif
{
var expanded = false;
using (new EditorGUILayout.HorizontalScope())
Expand Down Expand Up @@ -184,8 +196,7 @@ void DrawSerializedObject(UnityObject drawTarget, GameObject inspectorTarget)
if (expanded)
{
// Cache SerializedObjects to avoid heap churn
SerializedObject serializedObject;
if (!m_SerializedObjects.TryGetValue(drawTarget, out serializedObject))
if (!m_SerializedObjects.TryGetValue(drawTarget, out var serializedObject))
{
serializedObject = new SerializedObject(drawTarget);
m_SerializedObjects[drawTarget] = serializedObject;
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Use the example scripts directly, or tweak and alter the algorithms inside to fi
## Stabilizr : Object Stabilization for XR
"The Fishing Rod Problem" - Virtual objects or rays locked to a controller can shake in an unnatural way. In the real world, long objects have weight, which gives them stabilization through inertia. In XR, this lack of stabilization makes objects feel fake and precise selection difficult.

Stabilzr is a solution to this problem. It smoothes the rotation of virtual objects in three scenarios
Stabilizr is a solution to this problem. It smooths the rotation of virtual objects in three scenarios
- Steady Motion: Holding an object at a precise angle while moving the controller
- Orbiting (endpoint) Motion: Holding the end of an object or ray at a particular spot while moving the controller
- Still Motion: Holding an object at a precise angle while clicking a button on the controller

Stabilzr works without adding lag to large sweeping motions - precise control is enabled while **in the worst case** only diverging from ground truth by 2 degrees for a single frame.
Stabilizr works without adding lag to large sweeping motions - precise control is enabled while **in the worst case** only diverging from ground truth by 2 degrees for a single frame.

For an example of Stabilzr in action, check out the included 'TestScene'. A 6 foot broom and 12 foot pointing stick are attached to the right and left XR controllers. To compare before/after, two additional gameobjects (labelled Non-Stabilized Overlay) can be enabled. These are non-stabilized copies of the broom and pointer that render of top of the originals.
For an example of Stabilizr in action, check out the included 'TestScene'. A 6 foot broom and 12 foot pointing stick are attached to the right and left XR controllers. To compare before/after, two additional gameobjects (labelled Non-Stabilized Overlay) can be enabled. These are non-stabilized copies of the broom and pointer that render of top of the originals.

## GizmoModule: Gizmos for EditorXR/Runtime
The normal Gizmos.Draw[Primitive] and Debug.DrawLine APIs don't work in EditorXR, and don't work in Runtime. The GizmoModule can be loaded alongside EditorXR, or included in a player build to provide similar functionality through the Graphics.DrawMesh API.
Expand Down Expand Up @@ -65,7 +65,7 @@ Sometimes it is necessary for Unity systems to add hidden objects to the user's
The HiddenHierarchy window shows a Hierarchy-like view of the currently open scenes, preview scenes, and "free objects" which exist outside of scenes. This is useful for debugging systems involving hidden objects, in case new objects "leak" into the scene or the system somehow fails to destroy a hidden object.

## HiddenInspector: Edit hidden components and properties
Likewise with hidden GameObjects, some Components may be hidden. The HiddenInspector window displays the currently selected GameObject and its full list of components, including those which are hidden from the normal inspector. Each component (as well as the GameObject's properties) will contain a raw list of properties, similar to the Debug Inpector.
Likewise with hidden GameObjects, some Components may be hidden. The HiddenInspector window displays the currently selected GameObject and its full list of components, including those which are hidden from the normal inspector. Each component (as well as the GameObject's properties) will contain a raw list of properties, similar to the Debug Inspector.

It is possible to show even more properties by enabling Show Hidden Properties. This will show non-visible properties as well as the hideFlags field which can be used to make component or objects visible to the normal hierarchy and inspector, and enable editing on read-only objects. Naturally, this can have detrimental consequences and may have adverse effects on Unity systems. Similarly, destroying hidden objects or components with this view can case errors or adverse effects.

Expand All @@ -76,7 +76,7 @@ This is an example of how to hook into Undo.postprocessModifications and Undo.un
One way to store metadata for a Scene is by keeping it in a ScriptableObject Asset, in which case you need to make sure the Asset is kept in sync with the Scene. This example shows how to use the OnWillSaveAssets callback in AssetModificationProcessor to ensure that a metadata Asset gets saved with the Scene.

## EditorDelegates
It is sometimes necessary to reference Editor code in your runtime assembly. For example, a MonoBehaviour may exist only for the purpose of edit-time functionality, but it must live in a runtime assembly due to the rule against MonoBehaviours in Editor assemblies. In this case, it is often useful to define some static delegate fields inside of an '#if UNTY_EDITOR' directive. An Editor class can assign its own methods to those delegates, providing access to itself in the runtime assembly.
It is sometimes necessary to reference Editor code in your runtime assembly. For example, a MonoBehaviour may exist only for the purpose of edit-time functionality, but it must live in a runtime assembly due to the rule against MonoBehaviours in Editor assemblies. In this case, it is often useful to define some static delegate fields inside of an '#if UNITY_EDITOR' directive. An Editor class can assign its own methods to those delegates, providing access to itself in the runtime assembly.

EditorDelegatesExampleWindow provides functionality to EditorDelegates for checking if the mouse is over the window and firing callbacks when the window is focused and unfocused. The MonoBehaviour EditorDelegatesUser is then able to use this functionality even though it is in the runtime assembly.

Expand Down

0 comments on commit e7b26e2

Please sign in to comment.