상속: MonoBehaviour
 // Use this for initialization
 void Start()
 {
     shootableMask = LayerMask.GetMask ("Enemy");
     gunLine = GetComponent <LineRenderer> ();
     gunAudio = GetComponent<AudioSource> ();
     cardboardController = GetComponent<Cardboard> ();
 }
예제 #2
0
파일: AccTest.cs 프로젝트: bryantk/orca2015
 // Use this for initialization
 void Start()
 {
     cb = GetComponent<Cardboard>();
     if (Application.isEditor)
         filePath = Application.dataPath + "/accData.txt";
     else
         filePath = Application.persistentDataPath + "/accData.txt";
     Input.gyro.enabled = true;
     using (StreamWriter outfile = new StreamWriter(filePath, true)) {
         outfile.WriteLine("--- Begin Simulation ------");
     }
     cldwn = cldwnRate;
 }
    /// @note Each scene load causes an OnDestroy of the current SDK, followed
    /// by and Awake of a new one.  That should not cause the underlying native
    /// code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
    /// on the SDK if they want it to survive across scene loads.
    void Awake()
    {
        if (sdk == null)
        {
            sdk = this;
        }
        if (sdk != this)
        {
            Debug.LogError("There must be only one Cardboard object in a scene.");
            UnityEngine.Object.DestroyImmediate(this);
            return;
        }
#if UNITY_IOS
        Application.targetFrameRate = 60;
#endif
        // Prevent the screen from dimming / sleeping
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        InitDevice();
        StereoScreen = null;
        AddCardboardCamera();
    }
예제 #4
0
        public override void StartController(InstantVR ivr)
        {
            base.StartController(ivr);
#if UNITY_ANDROID
            Transform headcam = this.transform.FindChild("Headcam");
            //localNeckOffset = headcam.localPosition;

            if (headcam != null)
            {
                headcam.gameObject.SetActive(false);

                Cardboard cardboardPrefab = Resources.Load <Cardboard>("CardboardPrefab");
                cardboard = (Cardboard)Instantiate(cardboardPrefab, headcam.position, headcam.rotation);


                if (cardboard == null)
                {
                    Debug.LogError("Could not instantiate Cardboard. CardboardCameraRig is missing?");
                }
                else
                {
                    cardboard.transform.parent = ivr.transform;

                    cardboardStartPoint    = cardboard.transform.position;
                    baseStartPoint         = ivr.transform.position;
                    cardboardStartRotation = cardboard.transform.rotation;
                    baseStartAngle         = ivr.transform.eulerAngles.y;

                    headcam.gameObject.SetActive(false);
                }
                startRotation = Quaternion.Inverse(ivr.transform.rotation);
            }
            //ivrInput = ivr.rightHandTarget.GetComponent<IVR_Input>();
            controller = Controllers.GetController(0);
#if INSTANTVR_ADVANCED
            vicoVRHead = GetComponent <IVR_VicoVRHead>();
#endif
#endif
        }
예제 #5
0
    public override void StartController(InstantVR ivr) {
        base.StartController(ivr);
#if UNITY_ANDROID
        Transform headcam = this.transform.FindChild("Headcam");
        if (headcam != null) {
            headcam.gameObject.SetActive(false);

            Cardboard cardboardPrefab = Resources.Load<Cardboard>("CardboardPrefab");
            cardboard = (Cardboard)Instantiate(cardboardPrefab, headcam.position, headcam.rotation);


            if (cardboard == null)
                Debug.LogError("Could not instantiate Cardboard. CardboardCameraRig is missing?");
            else {
                cardboard.transform.parent = ivr.transform;

                cardboardStartPoint = cardboard.transform.position;
                baseStartPoint = ivr.transform.position;
                cardboardStartRotation = cardboard.transform.rotation;
                baseStartAngle = ivr.transform.eulerAngles.y;

                present = true;
                if (!present) {
                    cardboard.gameObject.SetActive(false);
                    headcam.gameObject.SetActive(true);
                } else
                    headcam.gameObject.SetActive(false);
#if !UNITY_4_5
                if (raycaster) {
                    GameObject mainCamera = cardboard.GetComponentInChildren<StereoController>().gameObject;
                    mainCamera.AddComponent<PhysicsRaycaster>();
                }
#endif
            }
            startRotation = Quaternion.Inverse(ivr.transform.rotation);
        }
#endif
    }
예제 #6
0
    void Awake()
    {
        if (sdk == null)
        {
            sdk = this;
        }
        if (sdk != this)
        {
            Debug.LogWarning("Cardboard SDK object should be a singleton.");
            enabled = false;
            return;
        }

        config.initialize();
#if ANDROID_DEVICE
        ConnectToActivity();
#endif

        CreateStereoScreen();
        UpdateScreenData();

        // Force side-effectful initialization using serialized values.
        EnableAlignmentMarker = enableAlignmentMarker;
        EnableSettingsButton  = enableSettingsButton;
        TapIsTrigger          = tapIsTrigger;
        AutoDriftCorrection   = autoDriftCorrection;
        NeckModelScale        = neckModelScale;

        InCardboard = newInCardboard = false;
#if UNITY_EDITOR
        if (VRModeEnabled && Application.isPlaying)
        {
            SetInCardboard(true);
        }
#endif

        StartCoroutine("EndOfFrame");
    }
예제 #7
0
	// Use this for initialization
	void Start () {
		DontDestroyOnLoad (transform.gameObject);
		go = GameObject.Find ("SocketIO");
		socket = go.GetComponent<SocketIOComponent>();

		controlobject = GameObject.FindWithTag ("unitychan");
		anim = controlobject.GetComponent<Animator> ();
		unitychancontrol = controlobject.GetComponent<UnityChanControlScriptWithRgidBody> ();

		headview = GameObject.FindWithTag ("head");
		cardboardhead = headview.GetComponent<CardboardHead> ();
		hit = new RaycastHit ();

		cardboardobject = GameObject.FindWithTag ("cardboardmain");
		cardboard = cardboardobject.GetComponent<Cardboard> ();

		Debug.Log (socket);
		if (socket == null) {
			Debug.Log("f**k you!");
		}

		socket.On ("connection", Connection);
		socket.On("toclient", Controler);
	}
예제 #8
0
 // Helper routine for creation of a stereo eye.
 private void CreateEye(Cardboard.Eye eye) {
   string nm = name + (eye == Cardboard.Eye.Left ? " Left" : " Right");
   GameObject go = new GameObject(nm);
   go.transform.parent = transform;
   go.AddComponent<Camera>().enabled = false;
   if (GetComponent<GUILayer>() != null) {
     go.AddComponent<GUILayer>();
   }
   if (GetComponent("FlareLayer") != null) {
     go.AddComponent<FlareLayer>();
   }
   var cardboardEye = go.AddComponent<CardboardEye>();
   cardboardEye.eye = eye;
   cardboardEye.CopyCameraAndMakeSideBySide(this);
 }
 public Pose3D GetEyePose(Cardboard.Eye eye) {
   switch(eye) {
     case Cardboard.Eye.Left:
       return leftEyePose;
     case Cardboard.Eye.Right:
       return rightEyePose;
     default:
       return null;
   }
 }
예제 #10
0
 void Start()
 {
     ChangeColor();
     cardboard     = FindObjectOfType <Cardboard>();
     cardboardHead = FindObjectOfType <CardboardHead>();
 }
예제 #11
0
 public Vector3 EyeOffset(Cardboard.Eye eye) {
     return eye == Cardboard.Eye.Left ? LeftEyeOffset : RightEyeOffset;
 }
예제 #12
0
 /// @note Each scene load causes an OnDestroy of the current SDK, followed
 /// by and Awake of a new one.  That should not cause the underlying native
 /// code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
 /// on the SDK if they want it to survive across scene loads.
 void Awake()
 {
     if (sdk == null) {
       sdk = this;
     }
     if (sdk != this) {
       Debug.LogWarning("Cardboard SDK object should be a singleton.");
       enabled = false;
       return;
     }
     #if UNITY_IOS
     Application.targetFrameRate = 60;
     #endif
     // Prevent the screen from dimming / sleeping
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     InitDevice();
     AddDummyCamera();
     StereoScreen = null;
 }
예제 #13
0
 void Start()
 {
     ScreenCenter = new Vector3(Camera.main.pixelWidth / 2,
                                Camera.main.pixelHeight / 2);
     MagnetButton = GetComponent <Cardboard>();
 }
예제 #14
0
    public override void OnInspectorGUI()
    {
        GUI.changed = false;

        DrawDefaultInspector();

        Cardboard cardboard = (Cardboard)target;

        bool newTapIsTrigger = EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);

        if (newTapIsTrigger != cardboard.TapIsTrigger)
        {
            cardboard.TapIsTrigger = newTapIsTrigger;
        }

        bool newEnableAlignmentMarkder =
            EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);

        if (newEnableAlignmentMarkder != cardboard.EnableAlignmentMarker)
        {
            cardboard.EnableAlignmentMarker = newEnableAlignmentMarkder;
        }

        bool newEnableSettingsButton =
            EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);

        if (newEnableSettingsButton != cardboard.EnableSettingsButton)
        {
            cardboard.EnableSettingsButton = newEnableSettingsButton;
        }

        bool newAutoDriftCorrection =
            EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);

        if (newAutoDriftCorrection != cardboard.AutoDriftCorrection)
        {
            cardboard.AutoDriftCorrection = newAutoDriftCorrection;
        }

        bool newVRModeEnabled = EditorGUILayout.Toggle(vrModeEnabledLabel, cardboard.VRModeEnabled);

        if (newVRModeEnabled != cardboard.VRModeEnabled)
        {
            cardboard.VRModeEnabled = newVRModeEnabled;
        }

        float newNeckModelScale = EditorGUILayout.Slider(neckModelScaleLabel,
                                                         cardboard.NeckModelScale, 0, 1);

        if (!Mathf.Approximately(newNeckModelScale, cardboard.NeckModelScale))
        {
            cardboard.NeckModelScale = newNeckModelScale;
        }

        cardboard.BackButtonExitsApp =
            EditorGUILayout.Toggle(backButtonExitsAppLabel, cardboard.BackButtonExitsApp);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(cardboard);
        }

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField(editorSettingsLabel);

        cardboard.autoUntiltHead = EditorGUILayout.Toggle(autoUntiltHeadLabel,
                                                          cardboard.autoUntiltHead);

        cardboard.simulateDistortionCorrection =
            EditorGUILayout.Toggle(simulateDistortionLabel, cardboard.simulateDistortionCorrection);

        cardboard.screenSize = (CardboardProfile.ScreenSizes)
                               EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.screenSize);

        cardboard.deviceType = (CardboardProfile.DeviceTypes)
                               EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.deviceType);

        if (EditorApplication.isPlaying)
        {
            bool newInCardboard = EditorGUILayout.Toggle("Is In Cardboard", cardboard.InCardboard);
            if (newInCardboard != cardboard.InCardboard)
            {
                cardboard.SetInCardboard(newInCardboard); // Takes effect at end of frame.
            }
        }
    }
예제 #15
0
 void Start()
 {
     cartboard = GameObject.Find ("CardboardMain").GetComponent<Cardboard> ();
     Destroy (GameObject.Find ("Lotus"));
 }
예제 #16
0
 // Use this for initialization
 void Start()
 {
     cardb = GameObject.FindObjectOfType<Cardboard>();
 }
예제 #17
0
 void OnDestroy() {
   if (device != null) {
     device.Destroy();
   }
   if (sdk == this) {
     sdk = null;
   }
 }
예제 #18
0
 // Use this for initialization
 void Start()
 {
     head      = transform.GetChild(0);
     rigidbody = GetComponent <Rigidbody>();
     cb        = GetComponent <Cardboard>();
 }
예제 #19
0
  // NOTE: Each scene load causes an OnDestroy of the current SDK, followed
  // by and Awake of a new one.  That should not cause the underlying native
  // code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
  // on the SDK if they want it to survive across scene loads.
  void Awake() {
    if (sdk == null) {
      sdk = this;
    }
    if (sdk != this) {
      Debug.LogWarning("Cardboard SDK object should be a singleton.");
      enabled = false;
      return;
    }
#if UNITY_IOS
    Application.targetFrameRate = 60;
#endif
    InitDevice();
    AddDummyCamera();
    StereoScreen = null;
  }
예제 #20
0
 void OnDestroy() {
     StopCoroutine("EndOfFrame");
     if (sdk == this) {
         sdk = null;
     }
 }
예제 #21
0
  void Awake() {
      if (sdk == null) {
          sdk = this;
      } else {
          Debug.LogWarning("Cardboard SDK object should be a singleton.");
          enabled = false;
      }

      config.initialize();

#if ANDROID_DEVICE
      try {
          AndroidJavaClass player = new AndroidJavaClass(cardboardClass);
          cardboardActivity = player.CallStatic<AndroidJavaObject>("getActivity");
          player.Dispose();
          cardboardActivity.Call("initFromUnity", gameObject.name);
          config.canAccessActivity = true;
      } catch (AndroidJavaException e) {
          Debug.LogError("Cannot access UnityCardboardActivity. "
                  + "Verify that the jar is in Assets/Plugins/Android. " + e);
      }
      // Force side-effectful initialization using serialized values.
      EnableAlignmentMarker = enableAlignmentMarker;
      EnableSettingsButton = enableSettingsButton;
      TapIsTrigger = tapIsTrigger;
#endif

      if (config.canApplyDistortionCorrection()) {
          Debug.Log("Creating new cardboard screen texture");
          StereoScreen = new RenderTexture(Screen.width, Screen.height, 16,
                                           RenderTextureFormat.RGB565);
          StereoScreen.Create();
          InitFromUnity(StereoScreen.GetNativeTextureID());
      } else {
          if (!Application.isEditor) {
            Debug.LogWarning("Lens distortion-correction disabled. Causes: ["
                             + config.getDistortionCorrectionDiagnostic() + "]");
          }
      }

      InCardboard = newInCardboard = false;
#if UNITY_EDITOR
      if (VRModeEnabled && Application.isPlaying) {
          SetInCardboard(true);
      }
#endif
      StartCoroutine("EndOfFrame");
  }
예제 #22
0
 // The transformation from head to eye.
 public Matrix4x4 EyeView(Cardboard.Eye eye) {
     return eye == Cardboard.Eye.Left ? leftEyeView : rightEyeView;
 }
예제 #23
0
	// Use this for initialization
	void Start () {
		head = Camera.main.GetComponent<StereoController> ().Head;
		cd = gameObject.GetComponent<Cardboard> ();
	}
예제 #24
0
 void Start()
 {
     m_Cardboard = Cardboard.SDK;
     InitialState();
     VrMode();
 }
예제 #25
0
 public void CreateCardboard()
 {
     Cardboard.Create();
 }
예제 #26
0
 void Awake()
 {
     Cardboard.Create();
     cam = GetComponent <Camera>();
     AddStereoRig();
 }
예제 #27
0
파일: Player.cs 프로젝트: santr006/VRapp
 // Use this for initialization
 void Start()
 {
     cardboard = GetComponent <Cardboard>();
     camera    = transform.GetChild(0).GetChild(0).gameObject;
     rb        = GetComponent <Rigidbody>();
 }
예제 #28
0
 void Start()
 {
     m_Cardboard = Cardboard.SDK;
     InitialState();
     VrMode();
 }
예제 #29
0
 // The projection matrix for a given eye.  This encodes the field of view,
 // IPD, and other parameters configured by the SDK.
 public Matrix4x4 Projection(Cardboard.Eye eye) {
     return eye == Cardboard.Eye.Left ? leftEyeProj : rightEyeProj;
 }
예제 #30
0
 // Use this for initialization
 void Start()
 {
     cardboardMain = GetComponent <Cardboard>();
     cardboardHead = GetComponentInChildren <CardboardHead>();
     ChangeView();
 }
예제 #31
0
    void Awake()
    {
        if (sdk == null)
        {
            sdk = this;
        }
        else
        {
            Debug.LogWarning("Cardboard SDK object should be a singleton.");
            enabled = false;
        }

        config.initialize();

#if ANDROID_DEVICE
        try {
            AndroidJavaClass player = new AndroidJavaClass(cardboardClass);
            cardboardActivity = player.CallStatic <AndroidJavaObject>("getActivity");
            player.Dispose();
            cardboardActivity.Call("initFromUnity", gameObject.name);
            config.canAccessActivity = true;
        } catch (AndroidJavaException e) {
            Debug.LogError("Cannot access UnityCardboardActivity. "
                           + "Verify that the jar is in Assets/Plugins/Android. " + e);
        }
        // Force side-effectful initialization using serialized values.
        EnableAlignmentMarker = enableAlignmentMarker;
        EnableSettingsButton  = enableSettingsButton;
        TapIsTrigger          = tapIsTrigger;
#elif IOS_DEVICE
        //_initFromUnity(gameObject.name);
        config.canAccessActivity = true;
        EnableAlignmentMarker    = enableAlignmentMarker;
        EnableSettingsButton     = enableSettingsButton;
        TapIsTrigger             = tapIsTrigger;
#endif

        if (config.canApplyDistortionCorrection())
        {
            Debug.Log("Creating new cardboard screen texture");
            StereoScreen = new RenderTexture(Screen.width, Screen.height, 16,
                                             RenderTextureFormat.RGB565);
            StereoScreen.Create();
            InitFromUnity(StereoScreen.GetNativeTextureID());
        }
        else
        {
            if (!Application.isEditor)
            {
                Debug.LogWarning("Lens distortion-correction disabled. Causes: ["
                                 + config.getDistortionCorrectionDiagnostic() + "]");
            }
        }

        InCardboard = newInCardboard = false;
#if UNITY_EDITOR
        if (VRModeEnabled && Application.isPlaying)
        {
            SetInCardboard(true);
        }
#endif
        StartCoroutine("EndOfFrame");
    }
예제 #32
0
    /// @cond HIDDEN
    public override void OnInspectorGUI()
    {
        GUI.changed = false;

        GUIStyle headingStyle = new GUIStyle(GUI.skin.label);

        headingStyle.fontStyle = FontStyle.Bold;
        headingStyle.fontSize  = 14;

        Cardboard cardboard = (Cardboard)target;

        EditorGUILayout.LabelField("General Settings", headingStyle);
        cardboard.VRModeEnabled =
            EditorGUILayout.Toggle(vrModeLabel, cardboard.VRModeEnabled);
        cardboard.DistortionCorrection = (Cardboard.DistortionCorrectionMethod)
                                         EditorGUILayout.EnumPopup(distortionCorrectionLabel, cardboard.DistortionCorrection);
        float oldScale = cardboard.StereoScreenScale;
        float newScale = EditorGUILayout.Slider(stereoScreenScale, oldScale, 0.25f, 2.0f);

        if (!Mathf.Approximately(newScale, oldScale))
        {
            cardboard.StereoScreenScale = newScale;
        }
        cardboard.NeckModelScale =
            EditorGUILayout.Slider(neckModelScaleLabel, cardboard.NeckModelScale, 0, 1);
        cardboard.AutoDriftCorrection =
            EditorGUILayout.Toggle(autoDriftCorrectionLabel, cardboard.AutoDriftCorrection);

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("UI Layer Settings", headingStyle);
        cardboard.EnableAlignmentMarker =
            EditorGUILayout.Toggle(alignmentMarkerLabel, cardboard.EnableAlignmentMarker);
        cardboard.EnableSettingsButton =
            EditorGUILayout.Toggle(settingsButtonLabel, cardboard.EnableSettingsButton);
        cardboard.BackButtonMode = (Cardboard.BackButtonModes)
                                   EditorGUILayout.EnumPopup(backButtonLabel, cardboard.BackButtonMode);

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField("Cardboard Settings", headingStyle);
#if UNITY_IOS
        cardboard.SyncWithCardboardApp =
            EditorGUILayout.Toggle(syncWithCardboardLabel, cardboard.SyncWithCardboardApp);
#endif
        cardboard.TapIsTrigger =
            EditorGUILayout.Toggle(tapIsTriggerLabel, cardboard.TapIsTrigger);

        EditorGUILayout.Separator();

        EditorGUILayout.LabelField(editorSettingsLabel, headingStyle);
        cardboard.autoUntiltHead =
            EditorGUILayout.Toggle(autoUntiltHeadLabel, cardboard.autoUntiltHead);
        cardboard.ScreenSize = (CardboardProfile.ScreenSizes)
                               EditorGUILayout.EnumPopup(screenSizeLabel, cardboard.ScreenSize);
        cardboard.DeviceType = (CardboardProfile.DeviceTypes)
                               EditorGUILayout.EnumPopup(deviceTypeLabel, cardboard.DeviceType);

        if (GUI.changed)
        {
            EditorUtility.SetDirty(cardboard);
        }
    }
 public Rect GetViewport(Cardboard.Eye eye,
                         Cardboard.Distortion distortion = Cardboard.Distortion.Distorted) {
   switch(eye) {
     case Cardboard.Eye.Left:
       return distortion == Cardboard.Distortion.Distorted ?
           leftEyeDistortedViewport : leftEyeUndistortedViewport;
     case Cardboard.Eye.Right:
       return distortion == Cardboard.Distortion.Distorted ?
           rightEyeDistortedViewport : rightEyeUndistortedViewport;
     default:
       return new Rect();
   }
 }
예제 #34
0
 void OnDestroy() {
     StopCoroutine("EndOfFrame");
     if (sdk == this) {
         sdk = null;
     }
 }
예제 #35
0
    /// Compute the position of one of the stereo eye cameras.  Accounts for both
    /// FOV matching and stereo comfort, if those features are enabled.  The input is
    /// the [1,1] entry of the eye camera's projection matrix, representing the vertical
    /// field of view, and the overall scale being applied to the Z axis.  Returns the
    /// position of the stereo eye camera in local coordinates.
    public Vector3 ComputeStereoEyePosition(Cardboard.Eye eye, float proj11, float zScale)
    {
        if (centerOfInterest == null || !centerOfInterest.gameObject.activeInHierarchy) {
          return Cardboard.SDK.EyePose(eye).Position * stereoMultiplier;
        }

        // Distance of COI relative to head.
        float distance = centerOfInterest != null ?
        (centerOfInterest.position - transform.position).magnitude : 0;

        // Size of the COI, clamped to [0..distance] for mathematical sanity in following equations.
        float radius = Mathf.Clamp(radiusOfInterest, 0, distance);

        // Move the eye so that COI has about the same size onscreen as in the mono camera FOV.
        // The radius affects the horizon location, which is where the screen-size matching has to
        // occur.
        float scale = proj11 / cam.projectionMatrix[1, 1];  // vertical FOV
        float offset =
        Mathf.Sqrt(radius * radius + (distance * distance - radius * radius) * scale * scale);
        float eyeOffset = (distance - offset) * Mathf.Clamp01(matchMonoFOV) / zScale;

        float ipdScale = stereoMultiplier;
        if (checkStereoComfort) {
          // Manage IPD scale based on the distance to the COI.
          float minComfort = Cardboard.SDK.ComfortableViewingRange.x;
          float maxComfort = Cardboard.SDK.ComfortableViewingRange.y;
          if (minComfort < maxComfort) {  // Sanity check.
        // If closer than the minimum comfort distance, IPD is scaled down.
        // If farther than the maximum comfort distance, IPD is scaled up.
        // The result is that parallax is clamped within a reasonable range.
        float minDistance = (distance - radius) / zScale - eyeOffset;
        ipdScale *= minDistance / Mathf.Clamp(minDistance, minComfort, maxComfort);
          }
        }

        return ipdScale * Cardboard.SDK.EyePose(eye).Position + eyeOffset * Vector3.forward;
    }
예제 #36
0
 void OnDestroy()
 {
     VRModeEnabled = false;
     if (device != null) {
       device.Destroy();
     }
     if (sdk == this) {
       sdk = null;
     }
 }
예제 #37
0
 // Use this for initialization
 void Start()
 {
     head = transform.GetChild(0);
     rigidbody = GetComponent<Rigidbody>();
     cb = GetComponent<Cardboard>();
 }
 public Matrix4x4 GetProjection(Cardboard.Eye eye,
                                Cardboard.Distortion distortion = Cardboard.Distortion.Distorted) {
   switch(eye) {
     case Cardboard.Eye.Left:
       return distortion == Cardboard.Distortion.Distorted ?
           leftEyeDistortedProjection : leftEyeUndistortedProjection;
     case Cardboard.Eye.Right:
       return distortion == Cardboard.Distortion.Distorted ?
           rightEyeDistortedProjection : rightEyeUndistortedProjection;
     default:
       return Matrix4x4.identity;
   }
 }
예제 #39
0
    public ParsedTouchData()
    {
        Cardboard cardboard = CardboardGameObject().GetComponent <Cardboard>();

        cardboard.TapIsTrigger = false;
    }
예제 #40
0
 void Awake()
 {
     Cardboard.Create();
 }
예제 #41
0
 void OnDestroy() {
     if (sdk == this) {
         sdk = null;
     }
 }
예제 #42
0
 // Helper routine for creation of a stereo eye.
 private void CreateEye(Cardboard.Eye eye)
 {
     string nm = name + (eye == Cardboard.Eye.Left ? " Left" : " Right");
     GameObject go = new GameObject(nm);
     go.transform.SetParent(transform, false);
     go.AddComponent<Camera>().enabled = false;
     #if !UNITY_5
     if (GetComponent("FlareLayer") != null) {
       go.AddComponent("FlareLayer");
     }
     #endif
     var cardboardEye = go.AddComponent<CardboardEye>();
     cardboardEye.eye = eye;
     cardboardEye.CopyCameraAndMakeSideBySide(this);
 }
예제 #43
0
파일: Cardboard.cs 프로젝트: vmohan7/Navi
 /// @note Each scene load causes an OnDestroy of the current SDK, followed
 /// by and Awake of a new one.  That should not cause the underlying native
 /// code to hiccup.  Exception: developer may call Application.DontDestroyOnLoad
 /// on the SDK if they want it to survive across scene loads.
 void Awake()
 {
     if (sdk == null) {
       sdk = this;
     }
     if (sdk != this) {
       Debug.LogError("There must be only one Cardboard object in a scene.");
       UnityEngine.Object.DestroyImmediate(this);
       return;
     }
     #if UNITY_IOS
     Application.targetFrameRate = 60;
     #endif
     // Prevent the screen from dimming / sleeping
     Screen.sleepTimeout = SleepTimeout.NeverSleep;
     InitDevice();
     StereoScreen = null;
     AddCardboardCamera();
 }