VR Development Framework
v 1.0.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
AVR_UIInteractionProvider_Editor.cs
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
4 using UnityEditor;
5 using UnityEngine.Events;
6 using UnityEngine.EventSystems;
7 
8 using AVR;
9 using AVR.UI;
10 
11 /// <summary>
12 /// Namespace of the arc-vr-ui (UnityEditor) package
13 /// </summary>
14 namespace AVR.UEditor.UI {
15  [CustomEditor(typeof(AVR_UIInteractionProvider))]
16  [CanEditMultipleObjects]
17  public class AVR_UIInteractionProvider_Editor : AVR.UEditor.Core.AVR_Component_Editor
18  {
19  public override void OnInspectorGUI()
20  {
21  base.OnInspectorGUI();
22 
24 
25  if(prov.UIRay==null) {
26  EditorGUILayout.HelpBox("UIInteractionProvider requires a UIRay to work!", MessageType.Warning);
27  if (GUILayout.Button("FIX NOW: Add default UIRay"))
28  {
29  GameObject ray = AVR.UEditor.Core.AVR_EditorUtility.InstantiatePrefabAsChild(prov.transform, "/editor/defaultPrefabPaths/uiRay");
30  prov.UIRay = ray.GetComponent<AVR_UIRay>();
31  }
32  }
33 
34  // There is no EventSystem
35  if(FindObjectOfType<EventSystem>()==null) {
36  EditorGUILayout.HelpBox("UIInteractionProvider requires an EventSystem object to work!", MessageType.Warning);
37  if (GUILayout.Button("FIX NOW: Create EventSystem Object"))
38  {
39  AVR.UEditor.Core.AVR_EditorUtility.InstantiatePrefabAsChild(null, "/editor/defaultPrefabPaths/eventSystem");
40  }
41  }
42  // There is an EventSystem but no VRInput object
43  else if(FindObjectOfType<VRInput>()==null) {
44  EditorGUILayout.HelpBox("UIInteractionProvider requires a VRInput object to work!", MessageType.Warning);
45  EventSystem sys = FindObjectOfType<EventSystem>();
46  if (GUILayout.Button("FIX: Add VRInput Component to "+sys.name))
47  {
48  sys.gameObject.AddComponent<VRInput>();
49  }
50  }
51  }
52  }
53 }
Represents a UI pointer-ray.
Definition: AVR_UIRay.cs:12
NOTE: If your EventSystem object has a InputSystemUIInputModule (new Unity input system) then any set...
This class overrides the base Input with Input from our VR components, thus enabling UI Interaction w...
Definition: VRInput.cs:14