コード例 #1
0
 public UIDialogQueueData(Type uiType, UITransitionType transition, object[] args, UICallback callbacks = null)
 {
     UIType         = uiType;
     TransitionType = transition;
     Args           = args;
     Callbacks      = callbacks;
 }
コード例 #2
0
ファイル: UIMan.cs プロジェクト: hieunt89/unity3d-tree-editor
        /// <summary>
        /// Preprocesses the UI.
        /// </summary>
        /// <param name="prefab">Prefab.</param>
        /// <param name="args">Arguments.</param>
        void PreprocessUI(GameObject prefab, object[] args)
        {
            Type uiType = (Type)args [0];

            if (prefab == null)
            {
                UnuLogger.LogFormatWarning("UI Error: cannot find {0}, make sure you have put UI prefab in Resources folder!", uiType.Name);
                return;
            }

            GameObject uiObj = Instantiate(prefab) as GameObject;

            uiObj.name = uiType.Name;

            UIManBase uiBase = uiObj.GetComponent <UIManBase> ();

            if (uiBase is UIManScreen)
            {
                uiBase.Trans.SetParent(screenRoot, false);
                uiBase.RectTrans.localScale = Vector3.one;
                if (!screenDict.ContainsKey(uiType))
                {
                    screenDict.Add(uiType, uiBase as UIManScreen);
                }
                bool     seal  = (bool)args [1];
                object[] param = (object[])args [2];
                ShowScreen(uiType, seal, param);
            }
            else if (uiBase is UIManDialog)
            {
                uiBase.Trans.SetParent(dialogRoot, false);
                uiBase.RectTrans.localScale = Vector3.one;
                dialogDict.Add(uiType, uiBase as UIManDialog);
                UICallback callbacks = (UICallback)args [1];
                object[]   param     = (object[])args [2];
                IsLoadingDialog = false;
                ShowDialog(uiType, callbacks, param);
            }
        }
コード例 #3
0
ファイル: UIMan.cs プロジェクト: hieunt89/unity3d-tree-editor
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="type">Type.</param>
        /// <param name="callbacks">Callbacks.</param>
        /// <param name="args">Arguments.</param>
        void ShowDialog(Type uiType, UICallback callbacks, params object[] args)
        {
            if (IsInDialogTransition || IsLoadingDialog)
            {
                EnqueueDialog(uiType, UITransitionType.SHOW, args, callbacks);
                return;
            }

            UIManDialog dialog = null;

            if (!dialogDict.TryGetValue(uiType, out dialog))
            {
                IsLoadingDialog = true;
                string prefabPath = Path.Combine(GetUIPrefabPath(uiType, true), uiType.Name);
                ResourceFactory.LoadAsync <GameObject> (prefabPath, PreprocessUI, uiType, callbacks, args);
                return;
            }

            if (dialog.IsActive)
            {
                return;
            }

            if (dialog.useCover)
            {
                cover.gameObject.SetActive(true);
                BringToFront(dialogRoot, cover, 1);
            }

            BringToFront(dialogRoot, dialog.transform, 2);
            activeDialog.Enqueue(uiType);
            IsInDialogTransition = true;
            dialog.SetCallbacks(callbacks);
            dialog.OnShow(args);
            OnShowUI(dialog, args);
            DoAnimShow(dialog);
        }
コード例 #4
0
        /// <summary>
        /// Shows the dialog.
        /// </summary>
        /// <param name="type">Type.</param>
        /// <param name="callbacks">Callbacks.</param>
        /// <param name="args">Arguments.</param>
        private void ShowDialog(Type uiType, UICallback callbacks, params object[] args)
        {
            if (this.IsInDialogTransition || this.IsLoadingDialog)
            {
                EnqueueDialog(uiType, UITransitionType.Show, args, callbacks);
                return;
            }

            if (!this.dialogDict.TryGetValue(uiType, out UIManDialog dialog))
            {
                this.IsLoadingDialog = true;
                UIManAssetLoader.Load <GameObject>(uiType.Name, (key, asset) => PreprocessDialogue(key, asset, uiType, callbacks, args));
                return;
            }

            if (dialog.IsActive)
            {
                return;
            }

            if (dialog.useCover)
            {
                this.cover.gameObject.SetActive(true);
                BringToFront(this.dialogRoot, this.cover, 1);
            }

            BringToFront(this.dialogRoot, dialog.transform, 2);

            this.activeDialog.Push(uiType);
            this.IsInDialogTransition = true;
            dialog.SetCallbacks(callbacks);
            dialog.OnShow(args);

            OnShowUI(dialog, args);
            DoAnimShow(dialog);
        }
コード例 #5
0
 public void SetCallbacks(UICallback callbacks)
 {
     mCallbacks = callbacks;
 }
コード例 #6
0
ファイル: UIManDialog.cs プロジェクト: grashaar/uiman
 public void SetCallbacks(UICallback callbacks)
 {
     this.m_callbacks = callbacks;
 }
コード例 #7
0
 public UIDialogQueueData(Type uiType, UITransitionType transition, object[] args, UICallback callbacks = null)
 {
     this.UIType         = uiType;
     this.TransitionType = transition;
     this.Args           = args;
     this.Callbacks      = callbacks;
 }
コード例 #8
0
        /// <summary>
        /// Enqueues the dialog.
        /// </summary>
        /// <param name="content">Content.</param>
        /// <param name="transition">Transition.</param>
        /// <param name="args">Arguments.</param>
        /// <param name="callback">Callback.</param>
        private void EnqueueDialog(Type uiType, UITransitionType transition, object[] args, UICallback callback)
        {
            var data = new UIDialogQueueData(uiType, transition, args, callback);

            this.dialogQueue.Enqueue(data);
        }
コード例 #9
0
        /// <summary>
        /// Preprocesses the UIManDialogue.
        /// </summary>
        /// <param name="prefab">Prefab.</param>
        /// <param name="args">Arguments.</param>
        private void PreprocessDialogue(string key, UnityEngine.Object asset, Type uiType, UICallback callbacks, params object[] args)
        {
            if (!(asset is GameObject prefab))
            {
                Debug.LogError($"Asset of key={key} is not a prefab.");
                return;
            }

            var obj = Instantiate(prefab) as GameObject;

            obj.name = uiType.Name;

            var dialogue = obj.GetComponent <UIManDialog>();

            if (!dialogue)
            {
                Destroy(obj);
                Debug.LogError($"{obj} does not contain any component derived from UIManDialogue.");
                return;
            }

            dialogue.Transform.SetParent(this.dialogRoot, false);
            dialogue.RectTransform.localScale = Vector3.one;
            this.dialogDict.Add(uiType, dialogue as UIManDialog);
            this.IsLoadingDialog = false;

            ShowDialog(uiType, callbacks, args);
        }
コード例 #10
0
        /// <summary>
        /// Display popup as confirm dialog.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="buttonYes">Button yes.</param>
        /// <param name="buttonNo">Button no.</param>
        /// <param name="onYes">On yes.</param>
        /// <param name="onNo">On no.</param>
        /// <param name="callbackArgs">Callback arguments.</param>
        public void ShowPopup(string title, string message, string buttonYes, string buttonNo, Action <object[]> onYes, Action <object[]> onNo = null, params object[] callbackArgs)
        {
            var uiCallbacks = new UICallback(onYes, onNo);

            ShowDialog <UIPopupDialog>(uiCallbacks, title, message, buttonYes, buttonNo, callbackArgs);
        }
コード例 #11
0
 /// <summary>
 /// Shows the dialog.
 /// </summary>
 /// <param name="callbacks">Callbacks.</param>
 /// <param name="args">Arguments.</param>
 /// <typeparam name="T">The 1st type parameter.</typeparam>
 public void ShowDialog <T>(UICallback callbacks, params object[] args)
 {
     ShowDialog(typeof(T), callbacks, args);
 }
コード例 #12
0
ファイル: UIMan.cs プロジェクト: hieunt89/unity3d-tree-editor
        /// <summary>
        /// Display popup as message dialog.
        /// </summary>
        /// <param name="title">Title.</param>
        /// <param name="message">Message.</param>
        /// <param name="button">Button.</param>
        /// <param name="onOK">On O.</param>
        /// <param name="callbackArgs">Callback arguments.</param>
        public void ShowPopup(string title, string message, string button = "OK", Action <object[]> onOK = null, params object[] callbackArgs)
        {
            UICallback uiCallbacks = new UICallback(onOK);

            ShowDialog <UIPopupDialog> (uiCallbacks, title, message, button, callbackArgs);
        }