Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
5.1 KiB

  1. namespace VRTK
  2. {
  3. using UnityEngine;
  4. using UnityEditor;
  5. [CustomEditor(typeof(VRTK_InteractHaptics))]
  6. public class VRTK_InteractHapticsEditor : Editor
  7. {
  8. SerializedProperty clipOnNearTouch;
  9. SerializedProperty strengthOnNearTouch;
  10. SerializedProperty durationOnNearTouch;
  11. SerializedProperty intervalOnNearTouch;
  12. SerializedProperty cancelOnNearUntouch;
  13. SerializedProperty clipOnTouch;
  14. SerializedProperty strengthOnTouch;
  15. SerializedProperty durationOnTouch;
  16. SerializedProperty intervalOnTouch;
  17. SerializedProperty cancelOnUntouch;
  18. SerializedProperty clipOnGrab;
  19. SerializedProperty strengthOnGrab;
  20. SerializedProperty durationOnGrab;
  21. SerializedProperty intervalOnGrab;
  22. SerializedProperty cancelOnUngrab;
  23. SerializedProperty clipOnUse;
  24. SerializedProperty strengthOnUse;
  25. SerializedProperty durationOnUse;
  26. SerializedProperty intervalOnUse;
  27. SerializedProperty cancelOnUnuse;
  28. SerializedProperty objectToAffect;
  29. private void OnEnable()
  30. {
  31. clipOnNearTouch = serializedObject.FindProperty("clipOnNearTouch");
  32. strengthOnNearTouch = serializedObject.FindProperty("strengthOnNearTouch");
  33. durationOnNearTouch = serializedObject.FindProperty("durationOnNearTouch");
  34. intervalOnNearTouch = serializedObject.FindProperty("intervalOnNearTouch");
  35. cancelOnNearUntouch = serializedObject.FindProperty("cancelOnNearUntouch");
  36. clipOnTouch = serializedObject.FindProperty("clipOnTouch");
  37. strengthOnTouch = serializedObject.FindProperty("strengthOnTouch");
  38. durationOnTouch = serializedObject.FindProperty("durationOnTouch");
  39. intervalOnTouch = serializedObject.FindProperty("intervalOnTouch");
  40. cancelOnUntouch = serializedObject.FindProperty("cancelOnUntouch");
  41. clipOnGrab = serializedObject.FindProperty("clipOnGrab");
  42. strengthOnGrab = serializedObject.FindProperty("strengthOnGrab");
  43. durationOnGrab = serializedObject.FindProperty("durationOnGrab");
  44. intervalOnGrab = serializedObject.FindProperty("intervalOnGrab");
  45. cancelOnUngrab = serializedObject.FindProperty("cancelOnUngrab");
  46. clipOnUse = serializedObject.FindProperty("clipOnUse");
  47. strengthOnUse = serializedObject.FindProperty("strengthOnUse");
  48. durationOnUse = serializedObject.FindProperty("durationOnUse");
  49. intervalOnUse = serializedObject.FindProperty("intervalOnUse");
  50. cancelOnUnuse = serializedObject.FindProperty("cancelOnUnuse");
  51. objectToAffect = serializedObject.FindProperty("objectToAffect");
  52. }
  53. public override void OnInspectorGUI()
  54. {
  55. serializedObject.Update();
  56. EditorGUILayout.Space();
  57. EditorGUILayout.LabelField("Haptics On Near Touch Settings", EditorStyles.boldLabel);
  58. EditorGUILayout.ObjectField(clipOnNearTouch, typeof(AudioClip));
  59. if (clipOnNearTouch.objectReferenceValue == null)
  60. {
  61. EditorGUILayout.PropertyField(strengthOnNearTouch);
  62. EditorGUILayout.PropertyField(durationOnNearTouch);
  63. EditorGUILayout.PropertyField(intervalOnNearTouch);
  64. }
  65. EditorGUILayout.PropertyField(cancelOnNearUntouch);
  66. EditorGUILayout.Space();
  67. EditorGUILayout.LabelField("Haptics On Touch Settings", EditorStyles.boldLabel);
  68. EditorGUILayout.ObjectField(clipOnTouch, typeof(AudioClip));
  69. if (clipOnTouch.objectReferenceValue == null)
  70. {
  71. EditorGUILayout.PropertyField(strengthOnTouch);
  72. EditorGUILayout.PropertyField(durationOnTouch);
  73. EditorGUILayout.PropertyField(intervalOnTouch);
  74. }
  75. EditorGUILayout.PropertyField(cancelOnUntouch);
  76. EditorGUILayout.Space();
  77. EditorGUILayout.LabelField("Haptics On Grab Settings", EditorStyles.boldLabel);
  78. EditorGUILayout.ObjectField(clipOnGrab, typeof(AudioClip));
  79. if (clipOnGrab.objectReferenceValue == null)
  80. {
  81. EditorGUILayout.PropertyField(strengthOnGrab);
  82. EditorGUILayout.PropertyField(durationOnGrab);
  83. EditorGUILayout.PropertyField(intervalOnGrab);
  84. }
  85. EditorGUILayout.PropertyField(cancelOnUngrab);
  86. EditorGUILayout.Space();
  87. EditorGUILayout.LabelField("Haptics On Use Settings", EditorStyles.boldLabel);
  88. EditorGUILayout.ObjectField(clipOnUse, typeof(AudioClip));
  89. if (clipOnUse.objectReferenceValue == null)
  90. {
  91. EditorGUILayout.PropertyField(strengthOnUse);
  92. EditorGUILayout.PropertyField(durationOnUse);
  93. EditorGUILayout.PropertyField(intervalOnUse);
  94. }
  95. EditorGUILayout.PropertyField(cancelOnUnuse);
  96. EditorGUILayout.Space();
  97. EditorGUILayout.PropertyField(objectToAffect);
  98. serializedObject.ApplyModifiedProperties();
  99. }
  100. }
  101. }