コード例 #1
0
 private void TeleportPressed()
 {
     if (controllerPointer == null)
     {
         controllerPointer = gameObject.AddComponent <ControllerPointer>();
     }
     controllerPointer.UpdateColor(Color.green);
 }
コード例 #2
0
ファイル: GrabMachine.cs プロジェクト: LeTalSkyppy/SwiftVR
 void Awake()
 {
     pose                       = GetComponent <SteamVR_Behaviour_Pose>();
     inputSource                = pose.inputSource;
     controllerPointer          = gameObject.AddComponent <ControllerPointer>();
     teleportArc                = GetComponent <TeleportArc>();
     teleportArc.traceLayerMask = layerMask;
 }
コード例 #3
0
ファイル: GrabMachinePC.cs プロジェクト: LeTalSkyppy/SwiftVR
 private void Start()
 {
     if (photonView.IsMine)
     {
         layerMaskMachine  = LayerMask.GetMask("MovableArea");
         TPCamera          = gameObject.GetComponent <PlayerController>().orbitCam.gameObject;
         controllerPointer = TPCamera.AddComponent <ControllerPointer>();
     }
 }
コード例 #4
0
    public void GetPointers()
    {
        if (controllerPointerA == null)
        {
            controllerPointerA = FindObjectOfType <ControllerPointer>();
        }

        if (controllerPointerB == null)
        {
            ControllerPointer[] pointers = FindObjectsOfType <ControllerPointer>();
            foreach (ControllerPointer p in pointers)
            {
                if (p != controllerPointerA)
                {
                    controllerPointerB = p;
                }
            }
        }
    }
コード例 #5
0
 private void Awake()
 {
     pointer = FindObjectOfType <ControllerPointer>();
     image   = GetComponent <Image>();
 }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        if (controller.GetPress(EVRButtonId.k_EButton_ApplicationMenu))
        {
            this.LineVisualizer.GetComponent <MeshRenderer>().enabled = true;

            Debug.Log("menu button pressed...");
            Ray forwardRay = new Ray(this.transform.position, this.transform.forward);
            Debug.DrawRay(this.transform.position, this.transform.forward);
            RaycastHit info = new RaycastHit();
            if (Physics.Raycast(forwardRay, out info))
            {
                Debug.Log(info.collider.gameObject.name);

                if (info.collider.gameObject.GetComponent <PanelControl>())
                {
                    info.collider.gameObject.GetComponent <PanelControl>().HandleHit(controller);
                }
                else if (info.collider.gameObject.GetComponent <CubeDescription>())
                {
                    info.collider.gameObject.GetComponent <CubeDescription>().HandleHit();//.description.gameObject.SetActive(!info.collider.gameObject.GetComponent<CubeDescription>().description.gameObject.activeSelf);
                }

                if (info.collider.gameObject.GetComponent <PanelsScript>())
                {
                    if (this.lastHit == null)
                    {
                        //info.collider.gameObject.GetComponent<PanelsScript>().switchDoorState();
                        if (info.collider.gameObject.GetComponent <PanelsScript>().doorOpen)
                        {
                            if (controller.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
                            {
                                info.collider.gameObject.GetComponent <PanelsScript>().switchDoorState();
                            }
                        }
                        else
                        {
                            info.collider.gameObject.GetComponent <PanelsScript>().switchDoorState();
                        }
                    }
                    else if (this.lastHit != null)
                    {
                        if (info.collider.gameObject == this.lastHit)
                        {
                            // just holding do nothing
                        }
                    }
                    this.lastHit = info.collider.gameObject;
                }
                else if (info.collider.gameObject.GetComponent <AbstractPanelItem>())
                {
                    info.collider.gameObject.GetComponent <AbstractPanelItem>().SwitchSelectionState();
                    if (info.collider.gameObject.GetComponent <CubeDescription>())
                    {
                        info.collider.gameObject.GetComponent <CubeDescription>().description.gameObject.SetActive(!info.collider.gameObject.GetComponent <CubeDescription>().description.gameObject.activeSelf);
                    }
                    //   this.description.gameObject.SetActive(!this.description.gameObject.activeSelf);
                }
            }
            else
            {
                if (this.lastHit != null)
                {
                    if (this.lastHit.gameObject.GetComponent <PanelsScript>())
                    {
                        if (this.lastHit.GetComponent <PanelsScript>().doorOpen)
                        {
                            if (controller.GetPress(EVRButtonId.k_EButton_SteamVR_Trigger))
                            {
                                this.lastHit.GetComponent <PanelsScript>().switchDoorState();
                            }
                        }
                        else
                        {
                            this.lastHit.GetComponent <PanelsScript>().switchDoorState();
                        }
                    }
                }
                this.lastHit = null;
            }
        }
        else
        {
            this.LineVisualizer.GetComponent <MeshRenderer>().enabled = false;
            this.lastHit = null;
        }

        if (controller.GetPressUp(EVRButtonId.k_EButton_SteamVR_Trigger))
        {
            ControllerPointer.TriggerEvent();
        }
    }