Beispiel #1
0
        // Read the UI prefab from certain directory
        private BaseUIForm ReadUIForm(string uiName)
        {
            // Find the path according to uiName
            string     path    = QueryUIFormPath(uiName);
            GameObject cloneUI = null;

            if (!string.IsNullOrEmpty(path))
            {
// To be improved ...
                var uiObj = Resources.Load(path) as GameObject;
                cloneUI = Instantiate <GameObject>(uiObj, Vector3.zero, Quaternion.identity);
// To be improved ...
            }

            // Initalize the cloned prefab according to it's info
            if (cloneUI != null)
            {
                BaseUIForm baseForm = cloneUI.GetComponent <BaseUIForm>();
                if (baseForm == null)
                {
                    Debug.LogError("Config file error!!");
                    Debug.LogError("Not a NextUI element.");

                    return(null);
                }

                // Set the parent of current UIForm
                switch (baseForm.CurrentUIType.formType)
                {
                case UIFormType.Normal:
                    cloneUI.transform.SetParent(_currentNormal, false);
                    break;

                case UIFormType.Fixed:
                    cloneUI.transform.SetParent(_currentFixed, false);
                    break;

                case UIFormType.PopUp:
                    cloneUI.transform.SetParent(_currentPopUp, false);
                    break;
                }

                // Hide the ui form temparary
                baseForm.Hide();

                // Add current UIForm into all forms cach
                _allFormsCach.Add(uiName, baseForm);

                return(baseForm);
            }
            else
            {
                Debug.LogError("Prefab: " + uiName + " not found!!");

                return(null);
            }
        }
Beispiel #2
0
        // Remove the hide other forms from the qeueu of current show forms
        private void RemoveFromHideOthers(string uiName, BaseUIForm uiForm)
        {
            uiForm.Hide();
            _showFormsCach.Remove(uiName);

            // Redisplay other forms
            foreach (BaseUIForm item in _showFormsCach.Values)
            {
                item.Redisplay();
            }
            foreach (BaseUIForm item in _moduelFormsStack)
            {
                item.Redisplay();
            }
        }
Beispiel #3
0
 // Remove the moduel ui form from the moduel stack
 private void RemoveFromModuelStack(string uiName, BaseUIForm uiForm)
 {
     // Only allowed to close the top form of the stack
     if (_moduelFormsStack.Peek() != uiForm)
     {
         return;
     }
     uiForm.Hide();
     _moduelFormsStack.Pop();
     if (_moduelFormsStack.Count > 0)
     {
         var preForm = _moduelFormsStack.Peek();
         preForm.Redisplay();
     }
 }
Beispiel #4
0
 // Remove the ui form from the queue of current shown forms
 private void RemoveFromCurrentShow(string uiName, BaseUIForm uiForm)
 {
     uiForm.Hide();
     _showFormsCach.Remove(uiName);
 }