Ejemplo n.º 1
0
        private UiLaser CreateLaser()
        {
            GameObject laser = new GameObject("Ui Laser");

            laser.transform.SetParent(this.transform, false);

            UiLaser laserComponent = laser.AddComponent <UiLaser> ();

            laserComponent.CreateBeam(laserMaterial);

            return(laserComponent);
        }
Ejemplo n.º 2
0
        private void FindHands()
        {
            // Lazily create the wand input module

            if (wandInputModule == null)
            {
                GameObject eventSystemObj = new GameObject("Isolated Event System");
                eventSystemObj.transform.SetParent(this.transform, false);

                eventSystemObj.gameObject.AddComponent <IsolatedEventSystem> ();

                wandInputModule = eventSystemObj.gameObject.AddComponent <WandInputModule> ();
                wandInputModule.CursorSprite   = cursorSprite;
                wandInputModule.CursorMaterial = cursorMaterial;
            }

            // Lazily create the lasers

            if (leftLaser == null)
            {
                leftLaser = CreateLaser();
            }
            if (rightLaser == null)
            {
                rightLaser = CreateLaser();
            }

            // Do Api specific binding

            if (activeBinding == null)
            {
                // No active binding, try all known bindings to see what catches on

                if (steamVrBinding.FindHands() > 0)
                {
                    // SteamVR found hands, so use SteamVR from now on
                    activeBinding = steamVrBinding;
                }
                else if (manualBinding.FindHands() > 0)
                {
                    activeBinding = manualBinding;
                }
                // other api bindings here...
            }
            else
            {
                // We have an active binding, check it again to see if it found any more hands
                activeBinding.FindHands();
            }

            if (activeBinding != null)
            {
                // We have a new binding, so hook up all the things

                wandInputModule = GameObject.FindObjectOfType(typeof(WandInputModule)) as WandInputModule;
                if (wandInputModule != null)
                {
                    wandInputModule.OnHandsDetected(this);
                }

                leftLaser.OnHandDetected(activeBinding.LeftHandIndex, activeBinding.LeftHand, wandInputModule);
                rightLaser.OnHandDetected(activeBinding.RightHandIndex, activeBinding.RightHand, wandInputModule);

                VrDebugPanel[] panels = GameObject.FindObjectsOfType(typeof(VrDebugPanel)) as VrDebugPanel[];
                foreach (VrDebugPanel panel in panels)
                {
                    panel.OnHandsDetected(this, wandInputModule.GetControllerCamera());
                }
            }
        }