public void LinkBlocks() { //Link blocks List <string> startupBlocks = new List <string>(0); for (int i = 0; i < blocks.Count; ++i) { string guid = blocks[i]; Block block = BlockMgr.FindBlock(guid); if (block.action.Equals("Entry:Startup", System.StringComparison.InvariantCultureIgnoreCase)) { startupBlocks.Add(guid); } if (block.action.Contains("Exit")) { continue; } if (i + 1 < blocks.Count) { string next = blocks[i + 1]; Block nextblock = BlockMgr.FindBlock(next); if (!nextblock.action.Contains("Entry")) { block.nexts.Add(next); } } } }
public void Execute() { this.LogDebug("Ready execute block {0}", action); param["path"] = path; VRXX.Action.ActionHub.Invoke(action, param, () => { this.LogDebug("Execute block {0} finish", action); foreach (string next in nexts) { Block block = BlockMgr.FindBlock(next); block.Execute(); } }); }
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(); } } }