예제 #1
0
        public static void SupportCardboard()
        {
#if __SDK_VR_GOOGLE__
            if (null != device_)
            {
                return;
            }

            CanvasMgr.Toggle2D(false);
            CanvasMgr.ToggleEvent(false);
            CameraMgr.ToggleCamera(false);

            device_ = new GameObject("__gvr__").transform;
            device_.SetParent(root_);


            Transform tsHead = new GameObject("head").transform;
            tsHead.SetParent(device_);

            Transform tsCamera = new GameObject("camera").transform;
            tsCamera.tag = "MainCamera";
            tsCamera.SetParent(tsHead);

            CameraMgr.InjectOuterCamera(tsHead);

            /*
             * // Transform tsCamera = CameraMgr.camera;
             * GvrViewer viewer = device_.gameObject.AddComponent<GvrViewer>();
             * viewer.VRModeEnabled = true;
             * viewer.DistortionCorrection = GvrViewer.DistortionCorrectionMethod.Native;
             * viewer.StereoScreenScale = 1f;
             * viewer.NeckModelScale = 0f;
             *
             * reticle_ = Object.Instantiate<GameObject>(Resources.Load<GameObject>("VR/XReticle"));
             * reticle_.name = "Reticle";
             * reticle_.transform.SetParent(device_);
             *
             * GvrReticlePointer reticle = reticle_.AddComponent<GvrReticlePointer>();
             * reticle.reticleSegments = 20;
             * reticle.reticleGrowthSpeed = 8;
             * reticle_.transform.SetParent(tsCamera);
             *
             * event_ = new GameObject("EventSystem");
             * event_.transform.SetParent(device_.transform);
             * event_.AddComponent<GvrPointerManager>();
             * event_.AddComponent<GvrPointerInputModule>();
             * tsCamera.gameObject.AddComponent<PhysicsRaycaster>();
             *
             * XGaze.instance.transform.SetParent(reticle.transform);
             */
            XGaze.instance.transform.localPosition = Vector3.zero;
            XGaze.instance.transform.localRotation = Quaternion.identity;
            XGaze.instance.transform.localScale    = Vector3.one;

            //SightTrigger.SupportCardboard();
#endif
        }
예제 #2
0
        public static void DeleteSightTrigger(string _uuid)
        {
            if (!sightTriggers.ContainsKey(_uuid))
            {
                return;
            }
            Transform trigger = sightTriggers[_uuid];

            CanvasMgr.Detach3DChild(trigger);
            Object.Destroy(trigger.gameObject);
            sightTriggers.Remove(_uuid);
        }
예제 #3
0
        public static void Preload()
        {
            device_  = null;
            reticle_ = null;
            event_   = null;

            root_ = new GameObject("__VRMgr__").transform;
            GameObject.DontDestroyOnLoad(root_.gameObject);

            GameObject objXGaze = Resources.Load <GameObject>("VR/XGaze");

            xgaze_ = GameObject.Instantiate <GameObject>(objXGaze);
            CanvasMgr.Attach3DChild(xgaze_.transform);

            Log.Info("VRMgr", "Preload VRManager finish");
        }
예제 #4
0
        public static SightTrigger NewSightTrigger(string _uuid)
        {
            if (sightTriggers.ContainsKey(_uuid))
            {
                return(sightTriggers[_uuid].GetComponent <SightTrigger>());
            }

            GameObject objTrigger = Resources.Load <GameObject>("trigger/sight_trigger");
            GameObject clone      = Object.Instantiate(objTrigger);

            clone.name = _uuid;
            Transform trigger = clone.transform;

            sightTriggers.Add(_uuid, trigger);

            CanvasMgr.Attach3DChild(trigger);

            AdjustSightTrigger(_uuid);
            return(trigger.GetComponent <SightTrigger>());
        }
예제 #5
0
        public static void SupportMI()
        {
#if __SDK_VR_XIAOMI__
            if (null != device_)
            {
                return;
            }

            //close 2d canvas
            CanvasMgr.Toggle2D(false);
            //close standalone input event
            CanvasMgr.ToggleEvent(false);

            device_ = new GameObject("__mivr__").transform;
            device_.SetParent(root_);

            GameObject leftEye = new GameObject("LeftEye");
            leftEye.transform.SetParent(device_);
            Camera leftEyeCamera = leftEye.AddComponent <Camera>();
            leftEyeCamera.nearClipPlane = 0.1f;

            GameObject rightEye = new GameObject("RightEye");
            rightEye.transform.SetParent(device_);
            Camera rightEyeCamera = rightEye.AddComponent <Camera>();
            rightEyeCamera.nearClipPlane = 0.1f;

            addXRectiel(device_);

            device_.gameObject.AddComponent <MiCamera>();
            device_.gameObject.AddComponent <VrManager>();
            device_.gameObject.AddComponent <MIInputManager>();

            CameraMgr.InjectOuterCamera(device_);

            ///XGaze.instance.transform.SetParent(reticle.transform);
            XGaze.instance.transform.localPosition = Vector3.zero;
            XGaze.instance.transform.localRotation = Quaternion.identity;
            XGaze.instance.transform.localScale    = Vector3.one;
#endif
        }
예제 #6
0
파일: UIMgr.cs 프로젝트: simonkhc/VRMaker-1
        //-------------------------------------------

        public static GameObject New3DText(string _uuid)
        {
            if (null != CanvasMgr.FindElement3d(_uuid))
            {
                return(CanvasMgr.FindElement3d(_uuid).gameObject);
            }

            GameObject root_ = new GameObject(_uuid);

            root_.AddComponent <Image>();
            CanvasMgr.Attach3DChild(root_.transform);

            RectTransform panel = root_.GetComponent <RectTransform>();

            panel.sizeDelta     = new Vector2(100, 100);
            panel.localPosition = new Vector3(0, 0, 6);
            panel.localScale    = new Vector3(0.01f, 0.01f, 0.01f);

            GameObject textbox = new GameObject("Page_1");

            textbox.AddComponent <Text>();
            textbox.transform.SetParent(panel);

            RectTransform textTransform = textbox.GetComponent <RectTransform>();

            textTransform.localPosition    = new Vector3(0, 0, 0);
            textTransform.localScale       = new Vector3(1f, 1f, 1f);
            textTransform.sizeDelta        = new Vector2(0, -40);
            textTransform.anchoredPosition = new Vector2(0, 20);
            textTransform.anchorMin        = new Vector2(0, 0);
            textTransform.anchorMax        = new Vector2(1, 1);
            textTransform.pivot            = new Vector2(0.5f, 0.5f);

            Text text = textbox.GetComponent <Text>();

            //text.color = new Color(0, 0, 0);
            text.alignment = TextAnchor.UpperLeft;
            //text.fontSize = 30;

            Font mFont = Resources.Load <Font>("BuxtonSketch");

            text.font = mFont;

            GameObject close = new GameObject("close");

            close.AddComponent <Image>();
            close.AddComponent <Button>();
            close.transform.SetParent(panel);

            RectTransform closeTransform = close.GetComponent <RectTransform>();

            closeTransform.localPosition    = new Vector3(0, 0, 0);
            closeTransform.localScale       = new Vector3(1f, 1f, 1f);
            closeTransform.sizeDelta        = new Vector3(40, 40);
            closeTransform.anchoredPosition = new Vector2(0, 20);
            closeTransform.anchorMin        = new Vector2(0.5f, 0);
            closeTransform.anchorMax        = new Vector2(0.5f, 0);
            closeTransform.pivot            = new Vector2(0.5f, 0.5f);

            Button but_close = close.GetComponent <Button>();

            but_close.GetComponent <Image>().sprite = (Sprite)Resources.LoadAll("Close", typeof(Sprite))[0];

            but_close.onClick.AddListener(delegate()
            {
                Delete3DText(root_);
            });

            //up page
            GameObject left = new GameObject("up");

            left.AddComponent <Image>();
            left.AddComponent <Button>();
            left.transform.SetParent(panel);

            RectTransform leftTransform = left.GetComponent <RectTransform>();

            leftTransform.localPosition    = new Vector3(0, 0, 0);
            leftTransform.localScale       = new Vector3(1f, 1f, 1f);
            leftTransform.sizeDelta        = new Vector3(40, 40);
            leftTransform.anchoredPosition = new Vector2(20, 20);
            leftTransform.anchorMin        = new Vector2(0, 0);
            leftTransform.anchorMax        = new Vector2(0, 0);
            leftTransform.pivot            = new Vector2(0.5f, 0.5f);

            Button butt_left = left.GetComponent <Button>();

            butt_left.GetComponent <Image>().sprite = (Sprite)Resources.LoadAll("up", typeof(Sprite))[0];

            butt_left.onClick.AddListener(delegate()
            {
                Transform root = butt_left.transform.parent;
                string uuid    = root.name;
                int curPage    = Text_3Ds[uuid];

                if (curPage <= 1)
                {
                    Debug.Log("Is the first page...");
                    return;
                }

                root.FindChild(string.Format("Page_{0}", curPage)).gameObject.SetActive(false);
                curPage--;
                root.FindChild(string.Format("Page_{0}", curPage)).gameObject.SetActive(true);

                Text_3Ds[uuid] = curPage;
            });

            //down page
            GameObject right = new GameObject("down");

            right.AddComponent <Image>();
            right.AddComponent <Button>();
            right.transform.SetParent(panel);

            RectTransform rightTransform = right.GetComponent <RectTransform>();

            rightTransform.localPosition    = new Vector3(0, 0, 0);
            rightTransform.localScale       = new Vector3(1f, 1f, 1f);
            rightTransform.sizeDelta        = new Vector3(40, 40);
            rightTransform.anchoredPosition = new Vector2(-20, 20);
            rightTransform.anchorMin        = new Vector2(1, 0);
            rightTransform.anchorMax        = new Vector2(1, 0);
            rightTransform.pivot            = new Vector2(0.5f, 0.5f);

            Button butt_right = right.GetComponent <Button>();

            butt_right.GetComponent <Image>().sprite = (Sprite)Resources.LoadAll("down", typeof(Sprite))[0];

            butt_right.onClick.AddListener(delegate()
            {
                Transform root = butt_left.transform.parent;

                string uuid = root.name;
                int curPage = Text_3Ds[uuid];

                Transform temp = null;
                temp           = root.FindChild(string.Format("Page_{0}", curPage + 1));
                if (temp == null)
                {
                    Debug.Log("It's already the last page...");
                    return;
                }

                root.FindChild(string.Format("Page_{0}", curPage)).gameObject.SetActive(false);
                curPage++;
                root.FindChild(string.Format("Page_{0}", curPage)).gameObject.SetActive(true);
                Text_3Ds[uuid] = curPage;
            });

            TogglePaging(root_, false);

            if (!Text_3Ds.ContainsKey(_uuid))
            {
                Text_3Ds.Add(_uuid, 1);
            }

            Uis.Add(_uuid, root_);
            return(root_);
        }