示例#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 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();
                }
            }
        }
示例#4
0
 public static void UseSkybox(Material _skybox)
 {
     Editor.Image img = (fsm.current as Editor.Image);
     img.skybox = _skybox;
     CameraMgr.ApplySkybox(_skybox);
 }