Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="content">Content.</param>
        /// <param name="seal">If set to <c>true</c> seal.</param>
        /// <param name="args">Arguments.</param>
        void ShowScreen(Type uiType, bool seal, params object[] args)
        {
            if (CurrentScreen != null && CurrentScreen.State != UIState.BUSY && CurrentScreen.State != UIState.HIDE)
            {
                CurrentScreen.HideMe();
            }

            UIManScreen screen = null;

            if (!screenDict.TryGetValue(uiType, out screen))
            {
                string prefabPath = Path.Combine(GetUIPrefabPath(uiType, false), uiType.Name);
                ResourceFactory.LoadAsync <GameObject> (prefabPath, PreprocessUI, uiType, seal, args);
                return;
            }

            if (!screen.gameObject.activeInHierarchy)
            {
                screen.gameObject.SetActive(true);
            }


            if (screen.useBackground)
            {
                background.gameObject.SetActive(true);
                string bgName = "";
                if (!string.IsNullOrEmpty(config.backgroundRootFolder))
                {
                    int resFolderIndex = config.backgroundRootFolder.LastIndexOf(UIManDefine.RESOURCES_FOLDER);
                    if (resFolderIndex > -1)
                    {
                        bgName = config.backgroundRootFolder.Substring(resFolderIndex + 10);
                    }
                }
                bgName = bgName + screen.backgroundType;
                ResourceFactory.LoadAsync <Texture2D> (bgName, SetScreenBackground);
            }

            BringToFront(screenRoot, screen.transform, 2);

            screen.OnShow(args);
            OnShowUI(screen, args);
            DoAnimShow(screen);

            CurrentScreen = screen;
            if (!seal)
            {
                screenQueue.Add(screen);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Backs the screen.
        /// </summary>
        /// <param name="args">Arguments.</param>
        public void BackScreen(params object[] args)
        {
            if (this.screenQueue.Count <= 1)
            {
                UnuLogger.LogWarning("UI Error: There are no scene has been loaded before this scene!", this);
                return;
            }

            this.CurrentScreen.HideMe();
            UIManScreen beforeScreen = this.screenQueue[this.screenQueue.Count - 2];

            OnBack(this.CurrentScreen, beforeScreen, args);

            this.screenQueue.RemoveAt(this.screenQueue.Count - 1);
            ShowScreen(beforeScreen.UIType, true, args);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Hides the screen.
        /// </summary>
        /// <param name="content">Content.</param>
        public void HideScreen(Type uiType)
        {
            UIManScreen screen = null;

            if (screenDict.TryGetValue(uiType, out screen))
            {
                screen.OnHide();
                OnHideUI(screen);
                DoAnimHide(screen);
            }
            else
            {
                UnuLogger.LogFormatWarning("There are no UI of {0} has been show!", uiType.Name);
                return;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="content">Content.</param>
        /// <param name="seal">If set to <c>true</c> seal.</param>
        /// <param name="args">Arguments.</param>
        void ShowScreen(Type uiType, bool seal, params object[] args)
        {
            if (CurrentScreen != null && CurrentScreen.UIType == uiType)
            {
                return;
            }

            if (CurrentScreen != null && CurrentScreen.State != UIState.BUSY && CurrentScreen.State != UIState.HIDE)
            {
                CurrentScreen.HideMe();
            }

            UIManScreen screen = null;

            if (!screenDict.TryGetValue(uiType, out screen))
            {
                string prefabPath = Path.Combine(GetUIPrefabPath(uiType, false), uiType.Name);
                ResourceFactory.LoadAsync <GameObject> (prefabPath, PreprocessUI, uiType, seal, args);
                return;
            }

            if (screen.useBackground)
            {
                background.gameObject.SetActive(true);
                string bgName = config.backgroundRootFolder + screen.backgroundType;
                ResourceFactory.LoadAsync <Texture2D> (bgName, SetScreenBackground);

                BringToFront(screenRoot, bgTrans, 1);
            }

            BringToFront(screenRoot, screen.transform, 2);

            screen.OnShow(args);
            OnShowUI(screen, args);
            DoAnimShow(screen);

            CurrentScreen = screen;
            if (!seal)
            {
                screenQueue.Add(screen);
            }
        }
Ejemplo n.º 5
0
        public override void OnInspectorGUI()
        {
            GUILayout.BeginHorizontal("Box");
            LabelHelper.HeaderLabel("UIMan View Model");
            GUILayout.EndHorizontal();
            LineHelper.Draw(Color.gray);

            UIManBase uiManBase = (UIManBase)target;

            EditorGUILayout.Space();
            LabelHelper.HeaderLabel("General");
            GUILayout.BeginVertical("Box");

            if (uiManBase is UIManDialog)
            {
                UIManDialog dialog = (UIManDialog)uiManBase;
                dialog.useCover = EditorGUILayout.Toggle(cover, dialog.useCover);
                EditorUtility.SetDirty(target);
            }
            else if (uiManBase is UIManBase)
            {
                UIManScreen screen = (UIManScreen)uiManBase;
                screen.useBackground = EditorGUILayout.Toggle(background, screen.useBackground);
                if (screen.useBackground)
                {
                    screen.backgroundType = EditorGUILayout.TextField(screen.backgroundType);
                }
                EditorUtility.SetDirty(target);
            }

            if (uiManBase.motionShow == UIMotion.CUSTOM_MECANIM_ANIMATION || uiManBase.motionHide == UIMotion.CUSTOM_MECANIM_ANIMATION)
            {
                if (uiManBase.gameObject != null)
                {
                    uiManBase.animRoot = uiManBase.gameObject.GetComponent <Animator> ();
                }

                uiManBase.animRoot = EditorGUILayout.ObjectField(animator, uiManBase.animRoot, typeof(Animator), true) as Animator;

                if (uiManBase.animRoot == null || uiManBase.animRoot.runtimeAnimatorController == null)
                {
                    if (GUILayout.Button("Generate Animator"))
                    {
                        AnimationEditorUtils.GenerateAnimator(uiManBase.gameObject, UIManDefine.ANIM_SHOW, UIManDefine.ANIM_HIDE, UIManDefine.ANIM_IDLE);
                    }
                }
            }

            uiManBase.motionShow = (UIMotion)EditorGUILayout.EnumPopup(show, uiManBase.motionShow);
            uiManBase.motionHide = (UIMotion)EditorGUILayout.EnumPopup(hide, uiManBase.motionHide);
            uiManBase.motionIdle = (UIMotion)EditorGUILayout.EnumPopup(idle, uiManBase.motionIdle);

            UIMotion[] motions = new UIMotion[3] {
                uiManBase.motionShow, uiManBase.motionHide, uiManBase.motionIdle
            };
            bool haveMecanimAnim = false;
            bool haveTweenAnim   = false;

            foreach (UIMotion m in motions)
            {
                if ((int)m == 7)
                {
                    haveMecanimAnim = true;
                }
                else
                {
                    haveTweenAnim = true;
                }
            }
            if (haveTweenAnim && haveMecanimAnim)
            {
                GUILayout.BeginHorizontal("Box");
                EditorGUILayout.LabelField("<color=red><b>Warning: </b>Your motion type is not match with each others so it maybe cause unexpected error!\nPlease select all motion type as Mecanim if you want to make you animation manually with Unity animation editor!</color>", EditorGUIHelper.RichText(true));
                GUILayout.EndHorizontal();
            }

            if (uiManBase.motionIdle != UIMotion.CUSTOM_MECANIM_ANIMATION && uiManBase.motionIdle != UIMotion.NONE)
            {
                GUILayout.BeginHorizontal("Box");
                EditorGUILayout.LabelField("<color=red><b>Warning: </b>Idle motion is now only support Mecanim animation!</color>", EditorGUIHelper.RichText(true));
                GUILayout.EndHorizontal();
            }

            uiManBase.animTime     = EditorGUILayout.FloatField(time, uiManBase.animTime);
            uiManBase.showPosition = EditorGUILayout.Vector3Field(position, uiManBase.showPosition);

            GUILayout.EndVertical();
            LineHelper.Draw(Color.gray);

            EditorGUILayout.Space();
            LabelHelper.HeaderLabel("Custom fields");
            GUILayout.BeginVertical("Box");
            DrawDefaultInspector();
            GUILayout.EndVertical();

            EditorGUILayout.Space();
            if (GUILayout.Button("Edit View (UI)", GUILayout.Height(25)))
            {
                GameObject         prefabInstance;
                UnityEngine.Object obj = FindObjectOfType(uiManBase.UIType);
                if (obj != null)
                {
                    prefabInstance = ((MonoBehaviour)obj).gameObject;
                }
                else
                {
                    bool isDialog = uiManBase.GetUIBaseType() == UIBaseType.DIALOG;
//					string prefabFolder = GetUIPrefabPath (selectedType, isDialog);
//					string prefabFile = selectedType.Name + PREFAB_EXT;
//					string prefabPath = Path.Combine (prefabFolder, prefabFile);
//					GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject> (prefabPath);
//					if (prefab == null) {
//						prefab = FindAssetObject<GameObject> (selectedType.Name, PREFAB_EXT);
//					}

                    prefabInstance = PrefabUtility.InstantiatePrefab(uiManBase.gameObject) as GameObject;
                    if (isDialog)
                    {
                        prefabInstance.transform.SetParent(UIMan.Instance.dialogRoot, false);
                    }
                    else
                    {
                        prefabInstance.transform.SetParent(UIMan.Instance.screenRoot, false);
                    }
                }
                Selection.activeGameObject = prefabInstance;
            }
            if (GUILayout.Button("Edit View Logic (Handler)", GUILayout.Height(25)))
            {
                string handler = CodeGenerationHelper.GetScriptPathByType(target.GetType());
                handler = handler.Replace(".cs", ".Handler.cs");
                UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(handler, 1);
            }
        }