コード例 #1
0
    private void UpdateReticlePointer(EventController event_controller)
    {
        WVR_DeviceType           _type       = event_controller.device;
        GameObject               _prevObject = event_controller.prevRaycastedObject;
        PointerEventData         _event_data = event_controller.event_data;
        WaveVR_ControllerPointer _pointer    = event_controller.pointer;
        WaveVR_Beam              _beam       = event_controller.beam;

        if (_pointer != null && _beam != null)
        {
            Vector3    _intersectionPosition = GetIntersectionPosition(_event_data.enterEventCamera, _event_data.pointerCurrentRaycast);
            GameObject _go = GetRaycastedObject(_type);

            if (_go != _prevObject)
            {
                if (_go != null)
                {
                    _pointer.SetPointerColor(new Color32(11, 220, 249, 255));
                    _pointer.OnPointerEnter(_event_data.enterEventCamera, _go, _intersectionPosition, true);
                    _beam.SetEndOffset(_intersectionPosition, false);
                }
                else
                {
                    _pointer.SetPointerColor(Color.white);
                    _pointer.OnPointerExit(_event_data.enterEventCamera, _prevObject);
                    _beam.ResetEndOffset();
                }
            }
        }
    }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     if (reticleObject != null)
     {
         reticle = reticleObject.GetComponent <WaveVR_ControllerPointer>();
     }
 }
    private bool getComponentParameter(GameObject controller, CComponent comp)
    {
        bool ret = false;

        var ch = controller.transform.childCount;

        for (int i = 0; i < ch; i++)
        {
            GameObject child = controller.transform.GetChild(i).gameObject;

            if (comp == CComponent.Beam)
            {
                WaveVR_Beam wb = child.GetComponentInChildren <WaveVR_Beam>();
                if (wb != null)
                {
                    ret = wb.ShowBeam;
                    PrintDebugLog("getComponentParameter() wb.ShowBeam is " + ret);
                    break;
                }
            }
            else if (comp == CComponent.ControllerPointer)
            {
                WaveVR_ControllerPointer wcp = child.GetComponentInChildren <WaveVR_ControllerPointer>();
                if (wcp != null)
                {
                    ret = wcp.ShowPointer;
                    PrintDebugLog("getComponentParameter() wcp.ShowPointer is " + ret);
                    break;
                }
            }
        }

        return(ret);
    }
コード例 #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        WaveVR_ControllerPointer myScript = target as WaveVR_ControllerPointer;

        myScript.ShowPointer = (bool)EditorGUILayout.Toggle("Show Controller Pointer", myScript.ShowPointer);
        if (true == myScript.ShowPointer)
        {
            myScript.device          = (WaveVR_Controller.EDeviceType)EditorGUILayout.EnumPopup("device", myScript.device);
            myScript.UseSystemConfig = EditorGUILayout.Toggle("Use system config", myScript.UseSystemConfig);

            if (false == myScript.UseSystemConfig)
            {
                EditorGUILayout.LabelField("Custom settings");
                myScript.Blink = EditorGUILayout.Toggle("Pointer blinking", myScript.Blink);
                myScript.PointerOuterDiameterMin = EditorGUILayout.FloatField("Min. pointer diameter", myScript.PointerOuterDiameterMin);

                EditorGUILayout.Space();
                myScript.UseDefaultTexture = EditorGUILayout.Toggle("Use default texture", myScript.UseDefaultTexture);

                if (false == myScript.UseDefaultTexture)
                {
                    myScript.CustomTexture = (Texture2D)EditorGUILayout.ObjectField("Custom texture", myScript.CustomTexture, typeof(Texture2D), false);
                }
            }
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty((WaveVR_ControllerPointer)target);
        }
    }
    public void OnPointerClick(PointerEventData eventData)
    {
        if (EventSystem.current == null)
        {
            EventSystem _es = FindObjectOfType <EventSystem> ();
            if (_es != null)
            {
                this.eventSystem = _es.gameObject;
            }
        }
        else
        {
            this.eventSystem = EventSystem.current.gameObject;
        }

        WaveVR_ControllerInputModule _cim = null;

        if (this.eventSystem != null)
        {
            _cim = this.eventSystem.GetComponent <WaveVR_ControllerInputModule> ();
            if (_cim != null)
            {
                this.raycastMode = _cim.RaycastMode;
            }
        }

        GameObject _go = eventData.enterEventCamera.gameObject;

        if (_go != null)
        {
            Log.d(LOG_TAG, "OnPointerClick() " + _go.name);
            switch (this.raycastMode)
            {
            case WaveVR_ControllerInputModule.ERaycastMode.Mouse:
                WaveVR_PointerCameraTracker _pct = _go.GetComponent <WaveVR_PointerCameraTracker> ();
                if (_pct != null && _cim != null)
                {
                    Log.d(LOG_TAG, "OnPointerClick() set beam length of " + _pct.type + " to " + this.length);
                    _cim.ChangeBeamLength(_pct.type, this.length);
                }
                break;

            case WaveVR_ControllerInputModule.ERaycastMode.Fixed:
                WaveVR_ControllerPointer _cp = _go.GetComponent <WaveVR_ControllerPointer> ();
                if (_cp != null && _cim != null)
                {
                    Log.d(LOG_TAG, "OnPointerClick() set beam length of " + _cp.device + " to " + this.length);
                    _cim.ChangeBeamLength(_cp.device, this.length);
                }
                break;

            // Do nothing in beam mode
            case WaveVR_ControllerInputModule.ERaycastMode.Beam:
            default:
                break;
            }
        }
    }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (reticleObject != null && reticle == null)
        {
            reticle = reticleObject.GetComponent <WaveVR_ControllerPointer>();
        }

        if (reticleObject != null && reticle != null)
        {
            pointer_location   = reticleObject.transform.position + reticleObject.transform.forward * reticle.PointerDistanceInMeters;
            transform.rotation = Quaternion.LookRotation(pointer_location - transform.position);
        }
    }
コード例 #7
0
    private void SetEmitter(GameObject gobj)
    {
        WaveVR_Beam _beam = gobj.GetComponent <WaveVR_Beam> ();
        WaveVR_ControllerPointer _pointer = gobj.GetComponent <WaveVR_ControllerPointer> ();

        if (_beam == null && _pointer == null)
        {
            return;
        }

        WaveVR_Controller.EDeviceType _focus_dev = WaveVR_Controller.EDeviceType.Head;
        #if UNITY_EDITOR
        if (Application.isEditor)
        {
            _focus_dev = this.Type;
        }
        else
        #endif
        {
            WVR_DeviceType _focus_dt = WaveVR_Utils.WVR_GetFocusedController();
            if (_focus_dt == WVR_DeviceType.WVR_DeviceType_Controller_Right)
            {
                _focus_dev = WaveVR_Controller.EDeviceType.Dominant;
            }
            if (_focus_dt == WVR_DeviceType.WVR_DeviceType_Controller_Left)
            {
                _focus_dev = WaveVR_Controller.EDeviceType.NonDominant;
            }
        }
        if (_focus_dev == WaveVR_Controller.EDeviceType.Head)
        {
            return;
        }

        if (_focus_dev != this.Type)
        {
            if (_beam != null)
            {
                PrintDebugLog("SetEmitter() focus type: " + _focus_dev + " hide beam.");
                _beam.ShowBeam = false;
            }
            if (_pointer != null)
            {
                PrintDebugLog("SetEmitter() focus type: " + _focus_dev + " hide pointer.");
                _pointer.ShowPointer = false;
            }
        }
    }
コード例 #8
0
    private void SetupReticleBeam_Right()
    {
        if (reticlePointer_right == null)
        {
            reticlePointer_right = RightController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            // Remove right reticle by default.
            if (reticlePointer_right != null)
            {
                reticlePointer_right.removePointer();
            }
        }

        if (beam_right == null)
        {
            beam_right = RightController.GetComponentInChildren <WaveVR_Beam> ();
        }
    }
    private void ForceSetActiveOfEmitter(ControllerInstance ci, bool enabled)
    {
        GameObject _controller = ci.instance;

        if (_controller != null)
        {
            if (ci.showBeam != enabled)
            {
                WaveVR_Beam _beam = _controller.GetComponentInChildren <WaveVR_Beam> ();
                if (_beam != null)
                {
                    ci.showBeam    = enabled;
                    _beam.ShowBeam = enabled;
                    PrintDebugLog("ForceSetActiveOfEmitter() Set " + ci.type + " controller " + _controller.name
                                  + ", index: " + ci.index
                                  + ", beam: " + _beam.ShowBeam);
                }
            }

            if (ci.showPointer != enabled)
            {
                WaveVR_ControllerPointer _pointer = _controller.GetComponentInChildren <WaveVR_ControllerPointer> ();
                if (_pointer != null)
                {
                    ci.showPointer       = enabled;
                    _pointer.ShowPointer = enabled;
                    PrintDebugLog("ForceSetActiveOfEmitter() Set " + ci.type + " controller " + _controller.name
                                  + ", index: " + ci.index
                                  + ", pointer: " + _pointer.ShowPointer);
                }
            }
        }
        else
        {
            if (Log.gpl.Print)
            {
                PrintDebugLog("ForceSetActiveOfEmitter() controller " + ci.type + " , index: " + ci.index + " controller is null, remove it from list.");
            }
            removeControllerInstance(ci.index);
        }
    }
コード例 #10
0
    private void renderControllerPointer(WVR_DeviceType type, bool result)
    {
        if (WaveVR_EventSystemControllerProvider.Instance != null)
        {
            GameObject ctrlr = WaveVR_EventSystemControllerProvider.Instance.GetControllerModel(type);
            if (ctrlr != null)
            {
                WaveVR_ControllerPointer cp   = ctrlr.GetComponentInChildren <WaveVR_ControllerPointer>();
                MeshRenderer             cpmr = null;

                if (cp != null)
                {
                    cpmr = cp.gameObject.GetComponentInChildren <MeshRenderer>();
                }
                if (cpmr != null)
                {
                    cpmr.enabled = result;
                }
            }
        }
    }
コード例 #11
0
    private bool ForceSetActiveOfEmitter(ControllerInstance ci, bool enabled)
    {
        bool _ret = false;

        GameObject _controller = ci.instance;

        if (_controller != null)
        {
            WaveVR_Beam _beam = _controller.GetComponentInChildren <WaveVR_Beam> ();
            WaveVR_ControllerPointer _pointer = _controller.GetComponentInChildren <WaveVR_ControllerPointer> ();

            if (_beam != null && _pointer != null)
            {
                _beam.ShowBeam       = enabled & ci.ShowBeam;
                _pointer.ShowPointer = enabled & ci.showPointer;

                PrintDebugLog("ForceSetActiveOfEmitter() Set " + ci.type + " controller " + _controller.name
                              + ", index: " + ci.index
                              + ", beam: " + _beam.ShowBeam
                              + ", pointer: " + _pointer.ShowPointer);

                _ret = true;
            }
            else
            {
                PrintIntervalLog(() => "ForceSetActiveOfEmitter() " + ci.type + " controller " + _controller.name
                                 + ", beam is " + (_beam == null ? "disabled" : "enabled")
                                 + ", pointer is " + (_pointer == null ? "disabled" : "enabled"));
            }
        }
        else
        {
            PrintDebugLog("ForceSetActiveOfEmitter() controller " + ci.type + " , index: " + ci.index + " controller is null, remove it from list.");
            removeControllerInstance(ci.index);
        }

        return(_ret);
    }
コード例 #12
0
    public void HidePointer()
    {
        WaveVR_ControllerPointer _cp = null;

        if (this.domintController != null)
        {
            _cp = this.domintController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("HidePointer() right.");
                _cp.ShowPointer = false;
            }
        }
        if (this.noDomiController != null)
        {
            _cp = this.noDomiController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("HidePointer() left.");
                _cp.ShowPointer = false;
            }
        }
    }
コード例 #13
0
    public void ShowPointer()
    {
        WaveVR_ControllerPointer _cp = null;

        if (this.domintController != null)
        {
            _cp = this.domintController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("ShowPointer() dominant.");
                _cp.ShowPointer = true;
            }
        }
        if (this.noDomiController != null)
        {
            _cp = this.noDomiController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("ShowPointer() non-dominant.");
                _cp.ShowPointer = true;
            }
        }
    }
コード例 #14
0
    public void ShowPointer()
    {
        WaveVR_ControllerPointer _cp = null;

        if (this.rightController != null)
        {
            _cp = this.rightController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("ShowPointer() right.");
                _cp.ShowPointer = true;
            }
        }
        if (this.leftController != null)
        {
            _cp = this.leftController.GetComponentInChildren <WaveVR_ControllerPointer> ();
            if (_cp != null)
            {
                PrintDebugLog("ShowPointer() left.");
                _cp.ShowPointer = true;
            }
        }
    }
コード例 #15
0
    private void ApplyAdaptiveControllerParameters()
    {
        var ch = controllerPrefab.transform.childCount;

        for (int i = 0; i < ch; i++)
        {
            PrintInfoLog(controllerPrefab.transform.GetChild(i).gameObject.name);
            // get controller pointer
            if (controllerPrefab.transform.GetChild(i).gameObject.name == "ControllerPointer")
            {
                GameObject CM = controllerPrefab.transform.GetChild(i).gameObject;

                WaveVR_ControllerPointer cp = CM.GetComponent <WaveVR_ControllerPointer>();

                if (cp != null)
                {
                    cp.device = this.deviceType;
                    PrintInfoLog("ControllerPointer is found");
                }
            }
            // get model
            if (controllerPrefab.transform.GetChild(i).gameObject.name == "Model")
            {
                GameObject CM = controllerPrefab.transform.GetChild(i).gameObject;

                WaveVR_AdaptiveController ac = CM.GetComponent <WaveVR_AdaptiveController>();

                if (ac != null)
                {
                    ac.device = this.deviceType;
                    var ret = ac.makeupControllerModel(renderModelNamePath, sessionid);
                    PrintInfoLog("AdaptiveController is active: " + ret);
                }

                WaveVR_AdaptiveControllerActions aca = CM.GetComponent <WaveVR_AdaptiveControllerActions>();

                if (aca != null)
                {
                    aca.enableButtonEffect = this.enableButtonEffect;
                    if (aca.enableButtonEffect)
                    {
                        PrintInfoLog("AdaptiveController button effect is active");
                        aca.device          = this.deviceType;
                        aca.useSystemConfig = this.useEffectSystemConfig;
                        if (!this.useEffectSystemConfig)
                        {
                            aca.buttonEffectColor = this.buttonEffectColor;
                        }
                    }
                }
            }

            // get beam
            if (controllerPrefab.transform.GetChild(i).gameObject.name == "Beam")
            {
                GameObject  CM = controllerPrefab.transform.GetChild(i).gameObject;
                WaveVR_Beam wb = CM.GetComponent <WaveVR_Beam>();

                if (wb != null)
                {
                    wb.useSystemConfig = this.useBeamSystemConfig;
                    if (!this.useBeamSystemConfig)
                    {
                        PrintInfoLog("Beam doesn't use system config");
                        wb.updateEveryFrame = this.updateEveryFrame;
                        wb.startWidth       = this.startWidth;
                        wb.endWidth         = this.endWidth;
                        wb.startOffset      = this.startOffset;
                        wb.endOffset        = this.endOffset;
                        wb.StartColor       = this.StartColor;
                        wb.EndColor         = this.EndColor;
                    }
                }
            }
        }
    }