示例#1
0
    public override void OnStartServer()
    {
        Debug.Log("in OnStartServer");

        GameObject playerCameraObj = gameObject.transform.Find("PlayerCamera").gameObject;
        Camera     playercamera    = playerCameraObj.GetComponent <Camera>();

        m_playerCameras.Add(playercamera);
        Debug.Log("There are now " + m_playerCameras.Count + " cameras");
        // add the highlighter
        HighlightingRenderer hlrender = playerCameraObj.AddComponent <HighlightingRenderer>();

        hlrender.LoadPreset("Speed");
    }
        //
        private void OnValueChanged(int index)
        {
            var items = dropdownState.items;

            if (hr == null || index < 0 || index >= items.Count)
            {
                return;
            }

            dropdownState.selected = index;

            string name = items[index].text;

            hr.LoadPreset(name);
        }
示例#3
0
        //
        IEnumerator Start()
        {
            highlightingRenderer.ClearPresets();
            for (int i = 0; i < customPresets.Count; i++)
            {
                highlightingRenderer.AddPreset(customPresets[i], false);
            }

            int index = 0;

            while (true)
            {
                ReadOnlyCollection <HighlightingPreset> presets = highlightingRenderer.presets;
                if (index >= presets.Count)
                {
                    index = 0;
                }
                HighlightingPreset preset = presets[index];
                highlightingRenderer.LoadPreset(preset.name);
                index++;

                yield return(new WaitForSeconds(interval));
            }
        }
示例#4
0
    public override void OnStartLocalPlayer()
    {
        Debug.Log("In OnStartLocalPlayer");
        // tag the local player so we can look for it later in other objects
        gameObject.tag = "Player";

        //Make sure the MainCamera is the one for our local player
        Camera     currentMainCamera = Camera.main;
        GameObject playerCameraObj   = gameObject.transform.Find("PlayerCamera").gameObject;
        Camera     playercamera      = playerCameraObj.GetComponent <Camera> ();

        playercamera.tag = "MainCamera";
        if (currentMainCamera != null)
        {
            currentMainCamera.enabled = false;
        }
        playercamera.enabled = true;

        // Set the position of the server player to be the eye of god.
        // Also disable tracking
        if (isServer && LocalPlayerOptions.singleton.observer)
        {
            m_observer = true;
            if (LocalPlayerOptions.singleton.god)
            {
//			gameObject.transform.position = new Vector3 (0, 1.6f, 0);
                gameObject.transform.position = new Vector3(0, 3, -.5f);
                gameObject.transform.Rotate(35, 0, 0);
            }
        }
        else
        {
            // Add the Highlighter, audiolistener, GvrAudioListener, and GvrPointerPhysicsRaycaster scripts to this object
            HighlightingRenderer hlrender = playerCameraObj.GetComponent <HighlightingRenderer>();
            if (hlrender == null)
            {
                hlrender = playerCameraObj.AddComponent <HighlightingRenderer> ();
                hlrender.LoadPreset("Speed");
            }
//			ViconActor tracking = gameObject.GetComponent<ViconActor> ();
            MQTTTrack tracking = gameObject.GetComponent <MQTTTrack>();
            if (LocalPlayerOptions.singleton.trackLocalPlayer)
            {
                // Turn on Holojam
//				Debug.Log("Turning on Holojam");
//				GameObject holojam = GameObject.FindGameObjectWithTag ("Holojam");
//				holojam.SetActive (true);
//				tracking.track = true;
//				tracking.SetLabel(LocalPlayerOptions.singleton.mocapName);

                // Turn on MQTT
                Debug.Log("Turning on MQTT");
                GameObject mqtt = GameObject.FindGameObjectWithTag("MQTT");
                mqtt.SetActive(true);
                tracking.SetLabel("Update/" + LocalPlayerOptions.singleton.mocapName);
                tracking.Track = true;
            }
            else
            {
                tracking.Track = false;
            }
        }

        playerCameraObj.AddComponent <AudioListener>();
        playerCameraObj.AddComponent <GvrAudioListener> ();
        playerCameraObj.AddComponent <GvrPointerPhysicsRaycaster> ();

                #if UNITY_HAS_GOOGLEVR && (UNITY_ANDROID || UNITY_EDITOR)
        GameObject      controllerPointer = gameObject.transform.Find("GvrControllerPointer").gameObject;
        IAAInputManager inputscript       = m_InputManager.GetComponent <IAAInputManager>();
        inputscript.controllerPointer = controllerPointer;
        inputscript.whatAreWe();
        inputscript.SetVRInputMechanism();

        // Add the GvrArmModelOffset scripts to the controller and laser
        GameObject         controller       = controllerPointer.transform.Find("Controller").gameObject;
        GvrArmModelOffsets controllerscript = controller.AddComponent <GvrArmModelOffsets> ();
        controllerscript.joint = GvrArmModelOffsets.Joint.Wrist;
        GameObject         laser       = controllerPointer.transform.Find("Laser").gameObject;
        GvrArmModelOffsets laserscript = laser.AddComponent <GvrArmModelOffsets> ();
        laserscript.joint = GvrArmModelOffsets.Joint.Pointer;

        // Add the GvrLaserPointer script to the laser object
        GvrLaserPointer laserPtrScript = laser.AddComponent <GvrLaserPointer> ();
        laserPtrScript.maxReticleDistance = 4.0f;
        GameObject reticle = laser.transform.Find("Reticle").gameObject;
        laserPtrScript.reticle = reticle;
                #endif

        if (isServer && m_observer)
        {
            // Make the avatar invisible
            gameObject.transform.Find("PlayerCamera/Gamer").gameObject.SetActive(false);
            gameObject.transform.Find("GvrControllerPointer/Controller/ddcontroller").gameObject.SetActive(false);
            if (m_cycleCameras)
            {
                // Remove the server camera (the first one) and save it.
                m_observerCamera = m_playerCameras [0];
                m_playerCameras.RemoveAt(0);
                StartCoroutine(cycleThroughCameras());
            }
        }
    }