Skip to content

Commit

Permalink
Improve inspector of interactables editors
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Jan 16, 2024
1 parent a708064 commit e9e949c
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
8 changes: 6 additions & 2 deletions Editor/HPUIBaseInteractableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace ubco.ovilab.HPUI.Editor
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HPUIBaseInteractable), true)]
public class HPUIBaseInteractableEditor: XRBaseInteractableEditor
{
Expand Down Expand Up @@ -55,8 +56,11 @@ protected override List<string> GetDerivedSerializedPropertyNames()
return props;
}

// Selection mode and distance calculation mode are programatically set.
/// <inheritdoc />
protected override void DrawSelectionConfiguration()
{}
protected override void DrawSelectionConfiguration() { }

/// <inheritdoc />
protected override void DrawDistanceCalculationMode() { }
}
}
12 changes: 10 additions & 2 deletions Editor/HPUIContinuousInteractableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@

namespace ubco.ovilab.HPUI.Editor
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HPUIContinuousInteractable), true)]
public class HPUIContinuousInteractableEditor: HPUIBaseInteractableEditor
{
private HPUIContinuousInteractable t;
protected override List<string> EventPropertyNames => base.EventPropertyNames.Union(new List<string>() { "continuousSurfaceCreatedEvent" }).ToList();
protected override List<string> EventPropertyNames => base.EventPropertyNames.Union(new List<string>()
{
"continuousSurfaceCreatedEvent",
"boundsCollider" // NOTE: this is not relevant to the HPUIContinuousInteractable.
}).ToList();

protected override void OnEnable()
{
Expand All @@ -24,7 +29,10 @@ public override void OnInspectorGUI()
GUI.enabled = EditorApplication.isPlaying;
if (GUILayout.Button("Run calibration"))
{
t.Configure();
foreach (Object t in targets)
{
(t as HPUIContinuousInteractable)?.Configure();
}
}
GUI.enabled = true;
}
Expand Down
1 change: 1 addition & 0 deletions Editor/HPUIInteractorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace ubco.ovilab.HPUI.Editor
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HPUIInteractor), true)]
public class HPUIInteractorEditor: XRBaseInteractorEditor
{
Expand Down
17 changes: 12 additions & 5 deletions Runtime/Interaction/HPUIBaseInteractable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ public Handedness Handedness
set => handedness = value;
}

public Collider boundsCollider;
[SerializeField]
private Collider boundsCollider;

/// <summary>
/// The collider used to compute the bounds of the interactable.
/// /// <seealso cref="ComputeInteractorPostion"/>
/// </summary>
public Collider BoundsCollider { get => boundsCollider; set => boundsCollider = value; }

[SerializeField]
private int _zOrder;
Expand Down Expand Up @@ -76,13 +83,13 @@ protected override void OnEnable()
/// </summary>
protected virtual void ComputeSurfaceBounds()
{
if (boundsCollider == null)
if (BoundsCollider == null)
{
boundsCollider = colliders[0];
Debug.LogWarning($"boundsCollider is not set. Using {boundsCollider.name}'s collider.");
BoundsCollider = colliders[0];
Debug.LogWarning($"boundsCollider is not set. Using {BoundsCollider.name}'s collider.");
}

Bounds colliderBounds = boundsCollider.bounds;
Bounds colliderBounds = BoundsCollider.bounds;
Transform interactableTransform = GetAttachTransform(null);
boundsMax = ComputeTargetPointOnInteractablePlane(colliderBounds.max, interactableTransform);
boundsMin = ComputeTargetPointOnInteractablePlane(colliderBounds.min, interactableTransform);
Expand Down

0 comments on commit e9e949c

Please sign in to comment.