Skip to content

Commit

Permalink
Add UI prefab & add UI functions to components
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed-shariff committed Jan 23, 2024
1 parent dcbd6c9 commit a0509bb
Show file tree
Hide file tree
Showing 13 changed files with 927 additions and 332 deletions.
28 changes: 25 additions & 3 deletions Editor/HPUIContinuousInteractableEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,60 @@
using ubco.ovilab.HPUI.Interaction;
using System.Collections.Generic;
using System.Linq;
using ubco.ovilab.HPUI.UI;

namespace ubco.ovilab.HPUI.Editor
{
[CanEditMultipleObjects]
[CustomEditor(typeof(HPUIContinuousInteractable), true)]
public class HPUIContinuousInteractableEditor: HPUIBaseInteractableEditor
{
private const string UIPrefab = "Packages/ubc.ok.ovilab.hpui-core/Runtime/Assets/HPUIContinousUI.prefab";
private HPUIContinuousInteractable t;
private SerializedProperty uiProp;

protected override List<string> EventPropertyNames => base.EventPropertyNames.Union(new List<string>()
{
"continuousSurfaceCreatedEvent",
"boundsCollider" // NOTE: this is not relevant to the HPUIContinuousInteractable.
"boundsCollider", // NOTE: this is not relevant to the HPUIContinuousInteractable.
"ui"
}).ToList();

protected override void OnEnable()
{
base.OnEnable();
t = target as HPUIContinuousInteractable;
uiProp = serializedObject.FindProperty("ui");
}

/// <inheritdoc />
protected override void DrawInspector()
{
base.DrawInspector();
EditorGUILayout.PropertyField(uiProp);
if (uiProp.objectReferenceValue == null)
{
if (GUILayout.Button(new GUIContent("Instantiate & add UI", "Instantiate UI for continuous interface generation and add it")))
{
GameObject uiObj = PrefabUtility.InstantiatePrefab(AssetDatabase.LoadAssetAtPath<GameObject>(UIPrefab)) as GameObject;
uiProp.objectReferenceValue = uiObj.GetComponent<HPUIContinuousInteractableUI>();
Debug.Log($"[[[{uiProp.objectReferenceValue}]]]");
}
}
}

public override void OnInspectorGUI()
{
base.OnInspectorGUI();
GUI.enabled = EditorApplication.isPlaying;
if (GUILayout.Button("Manual recompute"))
if (GUILayout.Button(new GUIContent("Manual recompute", "Assuming the the corresponding hand is held straight, compute and generate the surface")))
{
foreach (Object t in targets)
{
(t as HPUIContinuousInteractable)?.ManualRecompute();
}
}
if (GUILayout.Button("Automated recompute"))
if (GUILayout.Button(new GUIContent("Automated recompute", "Intiate the process to estimate the joint locations and generate the surface")))
{
foreach (Object t in targets)
{
Expand Down
File renamed without changes.
Loading

0 comments on commit a0509bb

Please sign in to comment.