Пример #1
0
        public static void LoadSkybox(string _package, string _file
                                      , OnLoadReadyDelegate _onReady
                                      , OnLoadObjectSuccessDelegate _onSuccess
                                      , OnErrorDelegate _onError)
        {
            if (string.IsNullOrEmpty(_package))
            {
                _onError("package is null");
                return;
            }

            if (string.IsNullOrEmpty(_file))
            {
                _onError("file is null");
                return;
            }

            _onReady();

            CoroutineMgr.Start(asyncLoadBundle(_package, _file, (_res) =>
            {
                Log.Debug("ResourceMgr", "load skybox [{0}] finish...", _file);
                CameraMgr.ApplySkybox(_res as Material);
                _onSuccess(_res);
            },
                                               _onError));
        }
Пример #2
0
 public static void UseUGCSkybox(string _file)
 {
     UGCMgr.Res   res = UGCMgr.Find(_file);
     Editor.Image img = (fsm.current as Editor.Image);
     img.skybox = res.data as Material;
     CameraMgr.ApplySkybox(res.data as Material);
 }
Пример #3
0
 public override void OnEnter()
 {
     base.OnEnter();
     CameraMgr.UseDefaultSkybox();
     CameraMgr.Place(Vector3.zero);
     CameraMgr.Euler(Vector3.zero);
     slate.DoEnter();
 }
Пример #4
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
        }
Пример #5
0
 public static void Reset()
 {
     CameraMgr.UseDefaultSkybox();
     CameraMgr.Place(Vector3.zero);
     CameraMgr.Euler(Vector3.zero);
     ResourceMgr.ToggleAllGameObjects(false);
     TriggerMgr.ToggleAllTrigger(false);
     fsm.Reset();
 }
Пример #6
0
        public static void FocusSightTrigger(string _uuid)
        {
            if (!sightTriggers.ContainsKey(_uuid))
            {
                return;
            }

            CameraMgr.LookAt(sightTriggers[_uuid]);
        }
Пример #7
0
        public static void UpdateZoom(float _speed)
        {
            if (!zoom_)
            {
                return;
            }

            CameraMgr.Zoom(_speed);
        }
Пример #8
0
 public static void Clean()
 {
     CameraMgr.UseDefaultSkybox();
     CameraMgr.Place(Vector3.zero);
     CameraMgr.Euler(Vector3.zero);
     ResourceMgr.CleanAllGameObjects();
     TriggerMgr.Clean();
     fsm.Clean();
     images.Clear();
 }
Пример #9
0
 public static void UpdateAxis(Vector3 _axis)
 {
     if (!pitch_)
     {
         _axis.x = 0;
     }
     if (!yaw_)
     {
         _axis.y = 0;
     }
     if (!roll_)
     {
         _axis.z = 0;
     }
     CameraMgr.Rotate(_axis);
 }
Пример #10
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
        }
Пример #11
0
        public void DoEnter()
        {
            //preload assets
            foreach (Asset asset in assets.Values)
            {
                // asset has format like as .wav
                if (asset.file.Contains("."))
                {
                    byte[] data = UGCMgr.Take(asset.file);
                    if (null == data)
                    {
                        this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file);
                        continue;
                    }
                    if (asset.group.Equals("skybox"))
                    {
                        Material skybox = UGCMgr.BuildSkybox(data);
                        CameraMgr.ApplySkybox(skybox);
                    }
                }
                else
                {
                    Object obj = ResourceMgr.FindFromPreload(asset.package, asset.file);
                    if (null == obj)
                    {
                        this.LogError("Missing asset, group:{0} package:{1} file:{2} ", asset.group, asset.package, asset.file);
                        continue;
                    }

                    if (asset.group.Equals("agent"))
                    {
                        GameObject clone = ResourceMgr.CloneGameObject(asset.package, asset.file, asset.guid);
                        agents.Add(asset.guid);
                        clone.transform.position   = new Vector3(asset.px, asset.py, asset.pz);
                        clone.transform.rotation   = Quaternion.Euler(asset.rx, asset.ry, asset.rz);
                        clone.transform.localScale = new Vector3(asset.sx, asset.sy, asset.sz);

                        if (asset.gaze)
                        {
                            ReticleHandler handler = clone.AddComponent <ReticleHandler>();
                            handler.path    = asset.slate;
                            handler.trigger = asset.gazeAlias;
                            EventTrigger et = clone.AddComponent <EventTrigger>();

                            EventTrigger.Entry entryEnter = new EventTrigger.Entry();
                            entryEnter.eventID = EventTriggerType.PointerEnter;
                            entryEnter.callback.AddListener((data) => { handler.onPointerEnter(); });
                            et.triggers.Add(entryEnter);

                            EventTrigger.Entry entryExit = new EventTrigger.Entry();
                            entryExit.eventID = EventTriggerType.PointerExit;
                            entryExit.callback.AddListener((data) => { handler.onPointerExit(); });
                            et.triggers.Add(entryExit);

                            EventTrigger.Entry entryClick = new EventTrigger.Entry();
                            entryClick.eventID = EventTriggerType.PointerClick;
                            entryClick.callback.AddListener((data) => { handler.onPointerClick(); });
                            et.triggers.Add(entryClick);

                            Collider collider = clone.GetComponent <Collider>();
                            if (null != collider)
                            {
                                collider.enabled = true;
                            }
                        }
                    }
                    else if (asset.group.Equals("skybox"))
                    {
                        CameraMgr.ApplySkybox(obj as Material);
                    }
                }
            }

            //hide all triggers
            TriggerMgr.ToggleAllTrigger(false);
            //show trigger in current slate
            foreach (string trigger in triggers)
            {
                TriggerMgr.ToggleTrigger(trigger, true);
            }

            // execute startup blocks
            foreach (string guid in blocks)
            {
                Block block = BlockMgr.FindBlock(guid);
                if (block.action.Equals("Entry:Startup"))
                {
                    block.Execute();
                }
            }
        }
Пример #12
0
 public static void UseSkybox(Material _skybox)
 {
     Editor.Image img = (fsm.current as Editor.Image);
     img.skybox = _skybox;
     CameraMgr.ApplySkybox(_skybox);
 }