System.Action Type2Close(UIType type) { switch (type) { case UIType.QuickInventory: return(CloseQuickInventoryUI); case UIType.FullInventory: return(CloseFullInventoryUI); case UIType.QuickTrade: return(CloseQuickTradeUI); case UIType.FullTrade: return(CloseFullTradeUI); } return(null); }
UIElementHolder Type2UI(UIType type) { switch (type) { case UIType.QuickInventory: return(quickInventory); case UIType.FullInventory: return(fullInventory); case UIType.QuickTrade: return(quickTrade); case UIType.FullTrade: return(fullTrade); } return(null); }
void CloseAllUIs() { for (int i = 0; i < uiTypesCount; i++) { UIType t = (UIType)i; if (IsOpen(t)) { Type2Close(t) (); } } // for (int i = 0; i < 4; i++) { // UIType t = (UIType)i; // if (IsOpen(t)) { // BeginClose(t, Type2UI(t)); // } // } }
/// <summary> /// Creates the U. /// </summary> /// <param name="type">Type.</param> protected void CreateUI(UIType id) { System.Type type = null; if (_dict.TryGetValue((int)id, out type)) { // 1. 得到相应Prefab的路径 string path = UIPrefabPath + type.Name; // 2. 实例化Prefab并放入UI_Root下 GameObject prefab = Resources.Load <GameObject>(path); if (prefab == null) { Debuger.LogError("找不到UI预制体: " + path); } GameObject obj = GameObject.Instantiate <GameObject>(prefab); obj.transform.SetParent(transform); obj.GetComponent <RectTransform>().localPosition = Vector3.zero; obj.GetComponent <RectTransform>().sizeDelta = Vector2.one; obj.transform.localScale = Vector3.one; } }
public void OpenFullTradeUI(Inventory showInventory)//System.Func<int> getWorkingInventorySlot) { { CloseAllUIs(); UIType type = UIType.FullTrade; if (!CheckForAlternateCallback(type)) { return; } InitializeCallbacksForUIs(false, type, OnFullTradeSubmit); int uiIndex = 0; BeginShow(true, true, inventory, showInventory, fullTrade.subHolders[uiIndex], maxFullInventoryButtons, uiIndex, 1); uiIndex = 1; BeginShow(true, false, showInventory, inventory, fullTrade.subHolders[uiIndex], maxFullInventoryButtons, uiIndex, 0); BroadcastUIOpen(UIType.FullTrade); }
void InitializeCallbacksForUIs(bool isRadial, UIType type, System.Action <GameObject[], object[], Vector2Int> onSubmit) { for (int i = 0; i < currentPaginatedOffsets.Length; i++) { currentPaginatedOffsets[i] = 0; } UIElementHolder uiHolder = Type2UI(type); UIManager.ShowUI(uiHolder, true, !isRadial); uiHolder.onSubmitEvent += onSubmit; // // quick inventory doesnt need alternative inputs, just the one submit // if (type != UIType.QuickInventory) { // } uiHolder.alternativeSubmit += callbackToGetAlternativeSubmit(type); if (!isRadial) { uiHolder.onSelectEvent += OnPaginatedUISelect; } }
public bool IsOpen(UIType type) { return(Type2UI(type).gameObject.activeInHierarchy); }
/// <summary> /// Registers the U. /// </summary> /// <param name="type">Type.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public void RegisterUI <T> (UIType id) where T : UI_Base { var type = typeof(T); _dict.Add((int)id, type); }