Exemple #1
0
        private void FirstPersonCameraInspector(HeadTarget headTarget)
        {
            if (headTarget.unityVRHead == null)
            {
                return;
            }

#if hSTEAMVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
            EditorGUI.BeginDisabledGroup(headTarget.humanoid.steam.enabled && headTarget.viveTracker.enabled);
#endif
            bool wasEnabled = headTarget.unityVRHead.enabled;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
#if hSTEAMVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
            if (headTarget.humanoid.steam.enabled && headTarget.viveTracker.enabled)
            {
                headTarget.unityVRHead.enabled = false;
            }
#endif
            bool enabled = EditorGUILayout.ToggleLeft(headTarget.unityVRHead.name, headTarget.unityVRHead.enabled, GUILayout.MinWidth(80));
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(headTarget, enabled ? "Enabled " : "Disabled " + headTarget.unityVRHead.name);
                headTarget.unityVRHead.enabled = enabled;
            }
            EditorGUILayout.EndHorizontal();

#if hFACE
            if (enabled)   // && microphoneEnabledProp != null) {
            {
                EditorGUI.indentLevel++;
                microphoneEnabledProp.boolValue = EditorGUILayout.ToggleLeft("Microphone", microphoneEnabledProp.boolValue);
                EditorGUI.indentLevel--;
            }
#endif

            if (!Application.isPlaying)
            {
                UnityVRHead.CheckCamera(headTarget);
                if (!wasEnabled && headTarget.unityVRHead.enabled)
                {
                    UnityVRHead.AddCamera(headTarget);
                }
                else if (wasEnabled && !headTarget.unityVRHead.enabled)
                {
                    UnityVRHead.RemoveCamera(headTarget);
                }
            }
#if hSTEAMVR && hVIVETRACKER && (UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX)
            EditorGUI.EndDisabledGroup();
#endif
        }
        private static void FirstPersonCameraInspector(HeadTarget headTarget)
        {
            if (headTarget.unityVRHead == null || headTarget.humanoid == null)
            {
                return;
            }

#if hSTEAMVR && hVIVETRACKER && UNITY_STANDALONE_WIN
            EditorGUI.BeginDisabledGroup(headTarget.humanoid.steam.enabled && headTarget.viveTracker.enabled);
#endif
            bool wasEnabled = headTarget.unityVRHead.enabled;

            EditorGUILayout.BeginHorizontal();
            EditorGUI.BeginChangeCheck();
#if hSTEAMVR && hVIVETRACKER && UNITY_STANDALONE_WIN
            if (headTarget.humanoid.steam.enabled && headTarget.viveTracker.enabled)
            {
                headTarget.unityVRHead.enabled = false;
            }
#endif
            GUIContent text = new GUIContent(
                "First Person Camera",
                "Enables a first person camera. Disabling and enabling again reset the camera position"
                );
            bool enabled = EditorGUILayout.ToggleLeft(text, headTarget.unityVRHead.enabled, GUILayout.Width(200));

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(headTarget, enabled ? "Enabled " : "Disabled " + headTarget.unityVRHead.name);
                headTarget.unityVRHead.enabled = enabled;
            }
            EditorGUILayout.EndHorizontal();

            if (!Application.isPlaying && !HumanoidControl_Editor.IsPrefab(headTarget.humanoid))
            {
                UnityVRHead.CheckCamera(headTarget);
                if (!wasEnabled && headTarget.unityVRHead.enabled)
                {
                    UnityVRHead.AddCamera(headTarget);
                }
                else if (wasEnabled && !headTarget.unityVRHead.enabled)
                {
                    UnityVRHead.RemoveCamera(headTarget);
                }
            }
#if hSTEAMVR && hVIVETRACKER && UNITY_STANDALONE_WIN
            EditorGUI.EndDisabledGroup();
#endif
        }
Exemple #3
0
        private void AddInteractionPointer()
        {
            InteractionPointer pointer  = HumanoidInteractionPointer.Add(headTarget.transform, InteractionPointer.PointerType.FocusPoint);
            Camera             fpCamera = UnityVRHead.GetCamera(headTarget);

            if (fpCamera != null)
            {
                pointer.transform.position = fpCamera.transform.position;
                pointer.transform.rotation = fpCamera.transform.rotation;
            }
            pointer.focusPointObj.transform.localPosition = new Vector3(0, 0, 2);

            HeadInput.Add(headTarget.transform);

            ControllerInput controllerInput = headTarget.humanoid.GetComponent <ControllerInput>();

            if (controllerInput != null)
            {
                controllerInput.leftButtonOneInput.SetMethod(pointer.Click, InputEvent.EventType.Start);
            }
        }