Esempio n. 1
0
        /// <summary>
        /// Special Function to Rollback in Screenstack
        /// </summary>
        public virtual void BackToScreen(MaterialScreen screen, Type transitionType, bool animate)
        {
            var stackIndex = screen != null?m_ScreenStack.IndexOf(screen) : -1;

            //Revert all screens before target screen in stack
            var processingScreenStack = new List <MaterialScreen>(m_ScreenStack);

            for (int i = processingScreenStack.Count - 1; i > stackIndex; i--)
            {
                if (processingScreenStack[i] != null && processingScreenStack[i] != currentScreen)
                {
                    processingScreenStack[i].TransitionOut();
                    processingScreenStack[i].Interrupt(true);
                    RemoveFromScreenStack(processingScreenStack[i]);
                }
            }

            //Back to screen
            if (screen != null)
            {
                var currentScreenIndex = m_CurrentScreenIndex;
                var screenIndex        = m_MaterialScreens.IndexOf(screen);
                Transition(screenIndex, transitionType, animate);
                //We dont want to stack the last screen
                RemoveFromScreenStack(currentScreenIndex);
            }
        }
Esempio n. 2
0
        public void TransitionImmediate(MaterialScreen screen, Type transitionType)
        {
            var screenIndex = m_MaterialScreens.IndexOf(screen);

            if (screenIndex >= 0)
            {
                Transition(screenIndex, transitionType, false);
            }
        }
Esempio n. 3
0
        public void Transition(MaterialScreen screen, Type transitionType, bool animate = true)
        {
            var screenIndex = m_MaterialScreens.IndexOf(screen);

            if (screenIndex >= 0)
            {
                Transition(screenIndex, transitionType, animate);
            }
        }
Esempio n. 4
0
 public virtual bool PushToScreenStack(MaterialScreen screen)
 {
     //Only accept screens of this ScreenView
     if (screen != null && m_MaterialScreens.IndexOf(screen) >= 0)
     {
         RemoveFromScreenStack(screen);
         m_ScreenStack.Add(screen);
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
        void OnEnable()
        {
            m_MaterialScreen = (MaterialScreen)target;

            m_OptionsControlledByScreenView = serializedObject.FindProperty("m_OptionsControlledByScreenView");
            m_DisableWhenNotVisible         = serializedObject.FindProperty("m_DisableWhenNotVisible");
            m_DestroyOnHide = serializedObject.FindProperty("m_DestroyOnHide");

            m_FadeIn          = serializedObject.FindProperty("m_FadeIn");
            m_FadeInTweenType = serializedObject.FindProperty("m_FadeInTweenType");
            m_FadeInAlpha     = serializedObject.FindProperty("m_FadeInAlpha");

            m_ScaleIn          = serializedObject.FindProperty("m_ScaleIn");
            m_ScaleInTweenType = serializedObject.FindProperty("m_ScaleInTweenType");
            m_ScaleInScale     = serializedObject.FindProperty("m_ScaleInScale");

            m_SlideIn           = serializedObject.FindProperty("m_SlideIn");
            m_SlideInTweenType  = serializedObject.FindProperty("m_SlideInTweenType");
            m_SlideInDirection  = serializedObject.FindProperty("m_SlideInDirection");
            m_AutoSlideInAmount = serializedObject.FindProperty("m_AutoSlideInAmount");
            m_SlideInAmount     = serializedObject.FindProperty("m_SlideInAmount");
            m_SlideInPercent    = serializedObject.FindProperty("m_SlideInPercent");

            m_RippleIn          = serializedObject.FindProperty("m_RippleIn");
            m_RippleInTweenType = serializedObject.FindProperty("m_RippleInTweenType");
            m_RippleInType      = serializedObject.FindProperty("m_RippleInType");
            m_RippleInPosition  = serializedObject.FindProperty("m_RippleInPosition");

            m_FadeOut          = serializedObject.FindProperty("m_FadeOut");
            m_FadeOutTweenType = serializedObject.FindProperty("m_FadeOutTweenType");
            m_FadeOutAlpha     = serializedObject.FindProperty("m_FadeOutAlpha");

            m_ScaleOut          = serializedObject.FindProperty("m_ScaleOut");
            m_ScaleOutTweenType = serializedObject.FindProperty("m_ScaleOutTweenType");
            m_ScaleOutScale     = serializedObject.FindProperty("m_ScaleOutScale");

            m_SlideOut           = serializedObject.FindProperty("m_SlideOut");
            m_SlideOutTweenType  = serializedObject.FindProperty("m_SlideOutTweenType");
            m_SlideOutDirection  = serializedObject.FindProperty("m_SlideOutDirection");
            m_AutoSlideOutAmount = serializedObject.FindProperty("m_AutoSlideOutAmount");
            m_SlideOutAmount     = serializedObject.FindProperty("m_SlideOutAmount");
            m_SlideOutPercent    = serializedObject.FindProperty("m_SlideOutPercent");

            m_RippleOut          = serializedObject.FindProperty("m_RippleOut");
            m_RippleOutTweenType = serializedObject.FindProperty("m_RippleOutTweenType");
            m_RippleOutType      = serializedObject.FindProperty("m_RippleOutType");
            m_RippleOutPosition  = serializedObject.FindProperty("m_RippleOutPosition");

            m_TransitionDuration = serializedObject.FindProperty("m_TransitionDuration");

            OnShowAnimationOver = serializedObject.FindProperty("OnShowAnimationOver");
            OnHideAnimationOver = serializedObject.FindProperty("OnHideAnimationOver");
        }
Esempio n. 6
0
 public virtual bool RemoveFromScreenStack(MaterialScreen screen)
 {
     if (screen != null)
     {
         var index = m_ScreenStack.IndexOf(screen);
         if (index >= 0)
         {
             m_ScreenStack.RemoveAt(index);
             return(true);
         }
     }
     return(false);
 }
        protected void LoadAndShowScreen_Internal(string screenResourcesName, bool p_searchForScreensWithSameName, System.Action <MaterialScreen> onStackScreen)
        {
            if (ScreenView == null)
            {
                Debug.LogError("ScreenView is null");
                return;
            }
            else
            {
                MaterialScreen screenWithSameName = p_searchForScreensWithSameName ? ScreenView.GetScreenWithName(screenResourcesName) : null;
                if (screenWithSameName == null)
                {
                    ScreenManager.ShowCustomScreenAsync <MaterialScreen>(screenResourcesName,
                                                                         ScreenView != null ? ScreenView.transform : null,
                                                                         (screen) =>
                    {
                        if (onStackScreen != null)
                        {
                            onStackScreen(screen);
                        }
                    },
                                                                         null,
                                                                         false);
                }
                else
                {
                    if (ScreenView.currentScreen != screenWithSameName)
                    {
                        screenWithSameName.Show();
                    }
                    else
                    {
                        //Debug.Log("Screen already instantiated");
                        return;
                    }

                    if (onStackScreen != null)
                    {
                        onStackScreen(screenWithSameName);
                    }
                }
            }
        }
Esempio n. 8
0
        public virtual MaterialScreen PopFromScreenStack()
        {
            MaterialScreen screen = null;

            while (m_ScreenStack.Count > 0)
            {
                //Try remove last screen (do it until remove)
                var screenIndex = m_ScreenStack.Count - 1;
                screen = m_ScreenStack[screenIndex];
                //We removed the last screen
                if (m_MaterialScreens.IndexOf(screen) >= 0 && RemoveFromScreenStack(screen))
                {
                    break;
                }
                //Invalid Screen index, remove it and try again
                else
                {
                    screen = null;
                    m_ScreenStack.RemoveAt(screenIndex);
                }
            }
            return(screen);
        }
Esempio n. 9
0
 public void TransitionImmediate(MaterialScreen screen)
 {
     TransitionImmediate(screen, transitionType);
 }
Esempio n. 10
0
 public void Transition(MaterialScreen screen)
 {
     Transition(screen, transitionType);
 }
Esempio n. 11
0
 public virtual void BackToScreen(MaterialScreen screen, Type transitionType)
 {
     BackToScreen(screen, transitionType, true);
 }
Esempio n. 12
0
 public virtual void BackToScreen(MaterialScreen screen)
 {
     BackToScreen(screen, Type.Out, true);
 }
        public override void OnInspectorGUI()
        {
            m_ScreenView = (ScreenView)target;

            serializedObject.Update();

            EditorGUILayout.PropertyField(m_AutoTrackScreens);
            if (!m_AutoTrackScreens.boolValue)
            {
                EditorGUILayout.PropertyField(m_MaterialScreens, true);
            }

            EditorGUILayout.PropertyField(m_OnlyShowSelectedScreen);

            MaterialScreen[] materialScreen = m_ScreenView.materialScreen;

            if (materialScreen.Length > 0)
            {
                string[] names = new string[materialScreen.Length];

                for (int i = 0; i < materialScreen.Length; i++)
                {
                    names[i] = (i + 1) + " - " + materialScreen[i].name;
                }

                m_ScreenView.currentScreen = EditorGUILayout.Popup("Current screen", m_ScreenView.currentScreen, names);

                m_ScreenView.screensDirty = true;

                EditorGUILayout.Space();
            }

            bool controllingAnyScreenConfigs = false;

            for (int i = 0; i < m_ScreenView.materialScreen.Length; i++)
            {
                MaterialScreen t = m_ScreenView.materialScreen[i];
                if (t.optionsControlledByScreenView)
                {
                    controllingAnyScreenConfigs = true;
                    break;
                }
            }
            if (controllingAnyScreenConfigs)
            {
                bool fadeIn    = m_FadeIn.boolValue;
                bool scaleIn   = m_ScaleIn.boolValue;
                bool slideIn   = m_SlideIn.boolValue;
                bool rippleIn  = m_RippleIn.boolValue;
                bool fadeOut   = m_FadeOut.boolValue;
                bool scaleOut  = m_ScaleOut.boolValue;
                bool slideOut  = m_SlideOut.boolValue;
                bool rippleOut = m_RippleOut.boolValue;

                if (fadeIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_FadeIn);
                        EditorGUILayout.PropertyField(m_FadeInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_FadeInTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.fadeInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.fadeInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_FadeInAlpha,
                                                      new GUIContent("Initial Alpha"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_FadeIn);
                }

                if (scaleIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_ScaleIn);
                        EditorGUILayout.PropertyField(m_ScaleInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_ScaleInTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.scaleInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.scaleInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_ScaleInScale,
                                                      new GUIContent("Initial Scale"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_ScaleIn);
                }

                if (slideIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_SlideIn);
                        EditorGUILayout.PropertyField(m_SlideInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_SlideInTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.slideInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.slideInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_SlideInDirection,
                                                      new GUIContent("From the"));
                        EditorGUILayout.PropertyField(m_AutoSlideInAmount,
                                                      new GUIContent("Auto distance"));
                        if (m_AutoSlideInAmount.boolValue)
                        {
                            EditorGUILayout.PropertyField(m_SlideInPercent,
                                                          new GUIContent("Auto distance percent"));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(m_SlideInAmount,
                                                          new GUIContent("Distance"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_SlideIn);
                }

                if (rippleIn)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_RippleIn);
                        EditorGUILayout.PropertyField(m_RippleInTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_RippleInTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.rippleInCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.rippleInCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_RippleInType,
                                                      new GUIContent("Position type"));
                        if (m_RippleInType.enumValueIndex == 1)
                        {
                            EditorGUILayout.PropertyField(m_RippleInPosition,
                                                          new GUIContent("Position"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_RippleIn);
                }

                EditorGUILayout.Space();

                if (fadeOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_FadeOut);
                        EditorGUILayout.PropertyField(m_FadeOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_FadeOutTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.fadeOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.fadeOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_FadeOutAlpha,
                                                      new GUIContent("Initial Alpha"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_FadeOut);
                }

                if (scaleOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_ScaleOut);
                        EditorGUILayout.PropertyField(m_ScaleOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_ScaleOutTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.scaleOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.scaleOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_ScaleOutScale,
                                                      new GUIContent("Initial Scale"));
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_ScaleOut);
                }

                if (slideOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_SlideOut);
                        EditorGUILayout.PropertyField(m_SlideOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_SlideOutTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.slideOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.slideOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_SlideOutDirection,
                                                      new GUIContent("From the"));
                        EditorGUILayout.PropertyField(m_AutoSlideOutAmount,
                                                      new GUIContent("Auto distance"));
                        if (m_AutoSlideOutAmount.boolValue)
                        {
                            EditorGUILayout.PropertyField(m_SlideOutPercent,
                                                          new GUIContent("Auto distance percent"));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(m_SlideOutAmount,
                                                          new GUIContent("Distance"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_SlideOut);
                }

                if (rippleOut)
                {
                    using (new GUILayout.VerticalScope("Box"))
                    {
                        EditorGUILayout.PropertyField(m_RippleOut);
                        EditorGUILayout.PropertyField(m_RippleOutTweenType,
                                                      new GUIContent("Tween type"));
                        if (m_RippleOutTweenType.enumValueIndex == 0)
                        {
                            m_ScreenView.rippleOutCustomCurve =
                                Tween.CheckCurve(EditorGUILayout.CurveField(m_ScreenView.rippleOutCustomCurve));
                        }
                        EditorGUILayout.PropertyField(m_RippleOutType,
                                                      new GUIContent("Position type"));
                        if (m_RippleOutType.enumValueIndex == 1)
                        {
                            EditorGUILayout.PropertyField(m_RippleOutPosition,
                                                          new GUIContent("Position"));
                        }
                    }
                    EditorGUILayout.Space();
                }
                else
                {
                    EditorGUILayout.PropertyField(m_RippleOut);
                }

                EditorGUILayout.PropertyField(m_TransitionDuration);
                EditorGUILayout.PropertyField(m_TransitionType, new GUIContent("Default transition type"));
            }
            else
            {
                EditorGUILayout.LabelField("Not controlling any MaterialScreen settings", EditorStyles.boldLabel);
            }

            EditorGUILayout.PropertyField(m_OnScreenBeginTransition);
            EditorGUILayout.PropertyField(m_OnScreenEndTransition);

            serializedObject.ApplyModifiedProperties();
        }
        private void OnEditorUpdate()
        {
            if (IsDestroyed())
            {
                MaterialUI.EditorUpdate.onEditorUpdate -= OnEditorUpdate;
                return;
            }

            if (m_AutoTrackScreens)
            {
                MaterialScreen[] tempMaterialScreens = GetComponentsInChildren <MaterialScreen>(true);

                List <MaterialScreen> ownedTempScreens = new List <MaterialScreen>();

                for (int i = 0; i < tempMaterialScreens.Length; i++)
                {
                    if (tempMaterialScreens[i].transform.parent == transform)
                    {
                        ownedTempScreens.Add(tempMaterialScreens[i]);
                    }
                }

                materialScreen = new MaterialScreen[ownedTempScreens.Count];

                for (int i = 0; i < ownedTempScreens.Count; i++)
                {
                    materialScreen[i] = ownedTempScreens[i];
                }
            }

            if (m_OldSelectionObjects != Selection.activeGameObject)
            {
                m_OldSelectionObjects = Selection.activeGameObject;
                m_ScreensDirty        = true;
            }

            if (m_MaterialScreens.Length > 0 && m_ScreensDirty)
            {
                m_ScreensDirty = false;

                bool screenSelected = false;

                if (m_OnlyShowSelectedScreen)
                {
                    for (int i = 0; i < materialScreen.Length; i++)
                    {
                        RectTransform[] children = materialScreen[i].GetComponentsInChildren <RectTransform>(true);

                        bool objectSelected = false;

                        for (int j = 0; j < children.Length; j++)
                        {
                            if (Selection.Contains(children[j].gameObject))
                            {
                                materialScreen[i].gameObject.SetActive(true);
                                screenSelected = true;
                                objectSelected = true;
                            }
                        }
                        if (!objectSelected)
                        {
                            materialScreen[i].gameObject.SetActive(false);
                        }
                    }

                    if (!screenSelected && !m_MaterialScreens[m_CurrentScreen].gameObject.activeSelf)
                    {
                        m_MaterialScreens[m_CurrentScreen].gameObject.SetActive(true);
                    }
                }
            }
            if (m_CurrentScreen < 0)
            {
                m_CurrentScreen = 0;
            }
            else if (m_MaterialScreens.Length > 0 && m_CurrentScreen >= m_MaterialScreens.Length)
            {
                m_CurrentScreen = m_MaterialScreens.Length - 1;
            }
        }