void InitWindow(CUILoadState uiState, CUIController uiBase, bool open, params object[] args) { uiBase.OnInit(); if (OnInitEvent != null) { OnInitEvent(uiBase); } if (open) { OnOpen(uiState, args); uiBase.gameObject.SetActive(true); } else { if (!uiState.IsStaticUI) { CloseWindow(uiBase.UIName); // Destroy } else { uiBase.gameObject.SetActive(false); } } OnUIWindowLoadedCallbacks(uiState, uiBase); }
IEnumerator LoadUIAssetBundle(string path, string name, CUILoadState openState) { CAssetLoader assetLoader = new CAssetLoader(path); while (!assetLoader.IsFinished) { yield return(null); } GameObject uiObj = (GameObject)assetLoader.Asset; openState.IsLoading = false; uiObj.SetActive(false); uiObj.name = openState.Name; UiBridge.UIObjectFilter(uiObj); CUIController uiBase = (CUIController)uiObj.AddComponent(openState.UIType); openState.UIWindow = uiBase; uiBase.UIName = uiBase.UITemplateName = openState.Name; InitWindow(openState, uiBase, openState.OpenWhenFinish, openState.OpenArgs); OnUIWindowLoaded(openState, uiBase); }
void OnDynamicWindowCallback(CUIController _ui, object[] _args) { string template = (string)_args[0]; string name = (string)_args[1]; GameObject uiObj = (GameObject)UnityEngine.Object.Instantiate(_ui.gameObject); uiObj.name = name; UiBridge.UIObjectFilter(uiObj); CUIController uiBase = uiObj.GetComponent <CUIController>(); uiBase.UITemplateName = template; uiBase.UIName = name; CUILoadState _instanceUIState = UIWindows[name]; _instanceUIState.IsLoading = false; _instanceUIState.UIWindow = uiBase; object[] originArgs = new object[_args.Length - 2]; // 去除前2个参数 for (int i = 2; i < _args.Length; i++) { originArgs[i - 2] = _args[i]; } InitWindow(_instanceUIState, uiBase, true, originArgs); OnUIWindowLoaded(_instanceUIState, uiBase); }
void OnOpen(CUILoadState uiState, params object[] args) { if (uiState.IsLoading) { uiState.OpenWhenFinish = true; uiState.OpenArgs = args; return; } CUIController uiBase = uiState.UIWindow; Action doOpenAction = () => { if (uiBase.gameObject.activeSelf) { uiBase.OnClose(); } uiBase.gameObject.SetActive(true); uiBase.OnOpen(args); if (OnOpenEvent != null) { OnOpenEvent(uiBase); } }; doOpenAction(); }
IEnumerator LoadUIAssetBundle(string path, string name, CUILoadState openState) { var assetLoader = CStaticAssetLoader.Load(path); openState.UIResourceLoader = assetLoader; // 基本不用手工释放的 while (!assetLoader.IsFinished) { yield return(null); } GameObject uiObj = (GameObject)assetLoader.TheAsset; openState.IsLoading = false; // Load完 uiObj.SetActive(false); uiObj.name = openState.TemplateName; CUIController uiBase = (CUIController)uiObj.AddComponent(openState.UIType); UiBridge.UIObjectFilter(uiBase, uiObj); openState.UIWindow = uiBase; uiBase.UIName = uiBase.UITemplateName = openState.TemplateName; InitWindow(openState, uiBase, openState.OpenWhenFinish, openState.OpenArgs); }
void InitWindow(CUILoadState uiState, CUIController uiBase, bool open, params object[] args) { uiBase.OnInit(); if (open) { OnOpen(uiState, args); uiBase.gameObject.SetActive(true); } }
public CXHome(CUIController controller) : base("Home", new SnipsNLUEngine(Path.Combine("Engines", "home")), controller) { MenuHandlers[Prefixed("PACKAGES")] = GetPackagesMenuItem; MenuIndexes[Prefixed("PACKAGES")] = 3; Initialized = NLUEngine.Initialized; if (!Initialized) { SayErrorLine("NLU engine for package {0} did not initialize. Exiting.", this.Name); Program.Exit(ExitResult.UNKNOWN_ERROR); } }
void OnUIWindowLoaded(CUILoadState uiState, CUIController uiBase) { //if (openState.OpenWhenFinish) // 加载完打开 模式下,打开时执行回调 { while (uiState.CallbacksWhenFinish.Count > 0) { Action <CUIController, object[]> callback = uiState.CallbacksWhenFinish.Dequeue(); object[] _args = uiState.CallbacksArgsWhenFinish.Dequeue(); callback(uiBase, _args); } } }
public CUILoadState(string _UITypeName) { Name = _UITypeName; UIWindow = null; UIType = "CUI" + _UITypeName; IsLoading = true; OpenWhenFinish = false; OpenArgs = null; CallbacksWhenFinish = new Queue <Action <CUIController, object[]> >(); CallbacksArgsWhenFinish = new Queue <object[]>(); }
// Use this for initialization void Start() { _uiController = GetComponent <CUIController>(); Cash = 1000; Food = 0.0f; JobsCeiling = 0.0f; buildingCounts[0] = 0; buildingCounts[1] = 0; buildingCounts[2] = 0; buildingCounts[3] = 0; _uiController.UpdateCityData(); _uiController.UpdateDayCount(); }
public CBaseResourceLoader UIResourceLoader; // 加载器,用于手动释放资源 public CUILoadState(string uiTypeTemplateName, string uiInstanceName) { TemplateName = uiTypeTemplateName; InstanceName = uiInstanceName; UIWindow = null; UIType = "CUI" + uiTypeTemplateName; IsLoading = true; OpenWhenFinish = false; OpenArgs = null; CallbacksWhenFinish = new Queue <Action <CUIController, object[]> >(); CallbacksArgsWhenFinish = new Queue <object[]>(); }
void OnOpen(CUILoadState uiState, params object[] args) { if (OpenWindowEvent != null) { OpenWindowEvent(uiState.UIType); } CUIController uiBase = uiState.UIWindow; uiBase.OnPreOpen(); if (uiBase.gameObject.activeSelf) { uiBase.OnClose(); } else { uiBase.gameObject.SetActive(true); } uiBase.OnOpen(args); }
public bool IsOpen(string name) { CUIController uiBase = GetUIBase(name); return(uiBase == null ? false : uiBase.gameObject.activeSelf); }
public void UIObjectFilter(CUIController ui, GameObject uiObject) { }
// Methods: void Awake() { if (!m_instance) { m_instance = this; } }