예제 #1
0
        public void CloseSameLevelPanels(WooPanel panel, bool immediate = false, bool notify = true)
        {
            if (panel.PanelType == PanelType.Independent)
            {
                return;
            }

            var parent = GetParent(panel);

            if (parent != null)
            {
                var children = GetChildren(parent.Panel);

                for (int i = 0; i < children.Count; i++)
                {
                    if (panel != children[i].Panel && children[i].Panel.PanelType != PanelType.Independent)
                    {
                        Close(children[i].Panel, immediate, notify);
                    }
                }
            }
            else
            {
                var rootNodes = GetRootNodes(panel);

                for (int i = 0; i < rootNodes.Count; i++)
                {
                    if (rootNodes[i].Panel != panel && rootNodes[i].Panel.PanelType != PanelType.Independent)
                    {
                        Close(rootNodes[i].Panel, immediate, notify);
                    }
                }
            }
        }
예제 #2
0
        private void DrawPanelPropertiesTextures(WooPanel panel)
        {
            if (panel == null || panel.PanelProperties == null)
            {
                return;
            }

            var shouldOpenWithChild  = panel.PanelProperties.WithChild && WooPanelsEngine.Instance.GetChildren(panel) != null && WooPanelsEngine.Instance.GetChildren(panel).Count > 0;
            var shouldOpenWithParent = panel.PanelProperties.WithParent && WooPanelsEngine.Instance.GetParent(panel) != null;

            if (shouldOpenWithChild || shouldOpenWithParent || panel.PanelProperties.OnAwake)
            {
                var iconRect = panelNodes[panel].rect;
                iconRect.position += Vector2.right * (iconRect.width + 5.0f);
                iconRect.width     = openWithChildTexture.width * iconRect.height / openWithChildTexture.height;
                GUILayout.Space(30.0f);

                if (shouldOpenWithChild)
                {
                    GUI.DrawTexture(iconRect, openWithChildTexture);
                }

                if (shouldOpenWithParent)
                {
                    GUI.DrawTexture(iconRect, openWithParentTexture);
                }

                if (panel.PanelProperties.OnAwake)
                {
                    GUI.DrawTexture(iconRect, openOnAwakeTexture);
                }
            }
        }
예제 #3
0
        public void PlayOpenAnimationImmdiately(WooPanel panel, bool notify = true)
        {
            panel.gameObject.SetActive(true);

            panelNodes[panel].StopCoroutines();

            panel.PanelState = PanelState.IsOpening;
            if (notify)
            {
                panel.NotifyOpeningBegin();
            }

            panel.PanelState = PanelState.Opened;

            if (notify)
            {
                panel.NotifyOpeningEnd();
            }
            ProcessAlwaysOnTop(panel);

            panel.PanelState = PanelState.IsOpening;
            RewindToEndPanelAnimation(panel);
            SamplePanelAnimator(panel);
            panel.PanelState = PanelState.Opened;
        }
예제 #4
0
        public void PlayCloseAnimationImmdiately(WooPanel panel, bool notify = true)
        {
            panel.gameObject.SetActive(true);

            panelNodes[panel].StopCoroutines();
            panel.PanelState = PanelState.IsClosing;
            if (notify)
            {
                panel.NotifyClosingBegin();
            }

            panel.PanelState = PanelState.Closed;

            if (notify)
            {
                panel.NotifyClosingEnd();
            }

            panel.PanelState = PanelState.IsClosing;
            RewindToEndPanelAnimation(panel);
            SamplePanelAnimator(panel);
            panel.PanelState = PanelState.Closed;

            panel.gameObject.SetActive(panel.PanelProperties.ActiveWhenClosed);
        }
예제 #5
0
        public void OpenNotAnimated(WooPanel panel, bool notify = true, WooPanel target = null)
        {
            if (IsOpen(panel) || !CanBeOpened(panel))
            {
                return;
            }
            if (panel == null)
            {
                return;
            }
            RebuildIfPanelGameObjectIsNull(panel);
            panel.gameObject.SetActive(true);

            ProcessAlwaysOnTop(panel);
            TryOpeningParents(panel, true, notify, target);
            CloseSameLevelPanels(panel, true, notify);

            panelNodes[panel].IsOpening = true;
            RewindToEndPanelAnimation(panel);
            SamplePanelAnimator(panel);

            panelNodes[panel].IsOpen = true;

            if (notify)
            {
                panel.NotifyOpeningBegin();
            }

            TryOpeningChildren(panel, true, target);

            if (notify)
            {
                panel.NotifyOpeningEnd();
            }
        }
예제 #6
0
        private void DrawLinesRecursive(WooPanel panel, int level)
        {
            var children = WooPanelsEngine.Instance.GetChildren(panel);


            if (WooPanelsEngine.Instance.panelNodes[panel].Children.Count > 1)
            {
                var firstPanel = children.Find((p) => p.Panel.PanelType == PanelType.Dependent);
                var lastPanel  = children.FindLast((p) => p.Panel.PanelType == PanelType.Dependent);

                if (firstPanel != lastPanel)
                {
                    WooPanelsEngine.Instance.panelNodes[panel].Children.ForEach((p) =>
                    {
                        if (p.Panel.PanelType == PanelType.Dependent)
                        {
                            DrawDependentHandles((p as WooPanelNode).rect, LinesColor);
                        }
                    }
                                                                                );
                }


                DrawConnectionBetweenPanels(firstPanel as WooPanelNode, lastPanel as WooPanelNode, LinesColor);
            }

            for (int i = 0; i < children.Count; i++)
            {
                DrawLinesRecursive(children[i].Panel, level + 1);
            }
        }
예제 #7
0
 private void DrawAnimatorProperty(WooPanel panel)
 {
     GUILayout.BeginVertical();
     GUILayout.Space(10.0f);
     panel.GetComponent <Animator>().runtimeAnimatorController = EditorGUILayout.ObjectField(panel.GetComponent <Animator>().runtimeAnimatorController, typeof(UnityEditor.Animations.AnimatorController), false) as UnityEditor.Animations.AnimatorController;
     GUILayout.EndVertical();
 }
예제 #8
0
 private void DrawCreateButtons(WooPanel panel, int level)
 {
     if (selectedPanel != null && panelNodes.ContainsKey(selectedPanel) && panelNodes[selectedPanel] != null)
     {
         if (panelNodes[selectedPanel].Children.Count > 0 && panelNodes[panel].Parent != null)
         {
             if (panelNodes[selectedPanel].Children.Last() == panelNodes[panel])
             {
                 DrawCreatePanelButton("Create Child Panel", level, panelNodes[selectedPanel].Panel.transform);
             }
         }
         else if (panelNodes[selectedPanel].Children.Count == 0 && selectedPanel == panel)
         {
             DrawCreatePanelButton("Create Child Panel", level + 1, panel.transform);
         }
         if (panelNodes[selectedPanel].ParentTransform == panelNodes[panel].ParentTransform)
         {
             if (panelNodes[selectedPanel].Parent == null)
             {
                 if (allRootNodes[panelNodes[panel].ParentTransform].Last().Panel == panel)
                 {
                     DrawCreatePanelButton("Create Sibling Panel", level, panel.transform.parent);
                 }
             }
             else
             {
                 if (panelNodes[selectedPanel].Parent.Children.Count > 0 && panelNodes[selectedPanel].Parent.Children.Last().Panel == panel)
                 {
                     DrawCreatePanelButton("Create Sibling Panel", level, panel.transform.parent);
                 }
             }
         }
     }
 }
예제 #9
0
 private void DrawSelectedIndicator(WooPanel panel)
 {
     if (selectedPanel == panel)
     {
         DrawSelectedIndicator(panelNodes[panel].rect, WooPanelsEngine.Instance.IsOpen(panel));
     }
 }
예제 #10
0
 public void ProcessAlwaysOnTop(WooPanel panel)
 {
     if (panel.PanelProperties.AlwaysOnTop)
     {
         panel.transform.SetAsLastSibling();
     }
 }
예제 #11
0
        public void TryOpeningChildren(WooPanel panel, bool immediate = false, bool notify = false, WooPanel target = null)
        {
            var children = GetChildren(panel);

            bool foundDependent = false;

            for (int i = 0; i < children.Count; i++)
            {
                if (HasInTree(children[i].Panel, target))
                {
                    Open(children[i].Panel, immediate, notify, target);
                    if (children[i].Panel.PanelType == PanelType.Dependent)
                    {
                        foundDependent = true;
                    }
                }
            }

            for (int i = 0; i < children.Count; i++)
            {
                if (foundDependent && children[i].Panel.PanelType == PanelType.Dependent)
                {
                    continue;
                }

                if (children[i].Panel.PanelProperties.WithParent)
                {
                    Open(children[i].Panel, immediate, notify, target);
                }
            }
        }
예제 #12
0
        public void CloseNotAnimated(WooPanel panel, bool notify = true)
        {
            if (panel.IsClosed())
            {
                return;
            }

            RebuildIfPanelGameObjectIsNull(panel);

            panel.gameObject.SetActive(true);
            panel.PanelState = PanelState.IsClosing;
            var children = GetChildren(panel);

            for (int i = 0; i < children.Count; i++)
            {
                Close(children[i].Panel, true, notify);
            }

            if (notify)
            {
                panel.NotifyClosingBegin();
            }

            CloseImmediately(panel, notify);

            panel.gameObject.SetActive(panel.PanelProperties.ActiveWhenClosed);
        }
예제 #13
0
        private void DrawAnimationProgress(WooPanel panel)
        {
            var prevColor   = GUI.backgroundColor;
            var color       = new Color(0.8f, 0.8f, 0.8f, 1.0f);
            var sliderColor = LinesColor;

            var rect = panelNodes[panel].rect;

            rect.position = rect.position + Vector2.right * 1.0f - Vector2.down * rect.height + Vector2.down * 5.0f;
            rect.height   = 5.0f;
            rect.width   -= 2.0f;

            var sliderValue = 0.0f;

            if (panelNodes[panel].IsClosing || panelNodes[panel].IsClosed)
            {
                sliderValue = 1.0f - panelNodes[panel].simulatedTime;
            }
            else
            {
                sliderValue = panelNodes[panel].simulatedTime;
            }

            if (panelNodes[panel].IsWaiting)
            {
                sliderValue = (panelNodes[panel].waitingTime - panelNodes[panel].remainingWaitingTime) / panelNodes[panel].waitingTime;
                sliderColor = new Color(0.5f, 0.7f, 1.0f, 1.0f);
            }

            if (panelNodes[panel].IsClosing || panelNodes[panel].IsOpening || panelNodes[panel].IsWaiting)
            {
                GUI.backgroundColor = color;

                if (panelNodes[panel].IsWaitingToOpen)
                {
                    rect.width *= sliderValue;
                }
                else if (panelNodes[panel].IsWaitingToClose)
                {
                    rect.position += rect.width * Vector2.right * (1.0f - sliderValue);
                    rect.width    *= sliderValue;
                }

                GUI.Box(rect, "");

                if (!panelNodes[panel].IsWaiting)
                {
                    rect.width *= sliderValue;
                    if (sliderValue > Mathf.Epsilon)
                    {
                        GUI.backgroundColor = sliderColor;
                        GUI.Box(rect, "");
                    }
                }
            }

            GUI.backgroundColor = prevColor;
        }
예제 #14
0
        public float TimeToStartOpening(WooPanel panel)
        {
            if (panel == null)
            {
                return(0.0f);
            }

            return(TimeToOpenParents(panel) * panel.PanelProperties.ParentToOpen + TimeForSameLevelToClose(panel) * panel.PanelProperties.SiblingsToClose);
        }
예제 #15
0
        public bool RegisterPanel(WooPanel panel)
        {
            if (!panelNodes.ContainsKey(panel))
            {
                Rebuild();
            }

            return(false);
        }
예제 #16
0
        private void DrawNode(WooPanel panel, int level)
        {
            if (panel == null)
            {
                return;
            }
            GUILayout.BeginHorizontal();


            DrawPanelButton(panel, level);
            DrawSelectedIndicator(panel);
            DrawAlwaysOnTopIndicator(panel);

            if (showIcons)
            {
                DrawPanelPropertiesTextures(panel);
            }

            if (showControllers)
            {
                DrawAnimatorProperty(panel);
            }

            DrawAnimationProgress(panel);

            if (editAnimators)
            {
                DrawAnimatorSliders(panel);
            }

            if (showType)
            {
                DrawScriptProperty(panel);
            }
            if (showTexts)
            {
                DrawPanelPropertiesText(panel);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            var children = WooPanelsEngine.Instance.GetChildren(panel);

            if (!panelNodes[panel].Collapsed)
            {
                for (int i = 0; i < children.Count; i++)
                {
                    DrawNode(children[i].Panel, level + 1);
                }
            }

            if (!Application.isPlaying)
            {
                DrawCreateButtons(panel, level);
            }
        }
예제 #17
0
        public float TimeToClose(WooPanel panel)
        {
            float timeToClose = 0.0f;

            timeToClose += TimeForChildrenToClose(panel) * panel.PanelProperties.ChildrenToClose;
            timeToClose += panelNodes[panel].TimeToClose();

            return(timeToClose);
        }
예제 #18
0
        private void ProcessEffects()
        {
            WooPanel myScript = (WooPanel)target;

            foldout = EditorGUILayout.Foldout(foldout, "Effects", true);

            if (foldout)
            {
                blurSelected  = GUILayout.Button("Add Blur");
                whiteSelected = GUILayout.Button("Add White Background");
                darkSelected  = GUILayout.Button("Add Dark Background");
            }

            var effects = myScript.transform.Find("Effects");

            if (blurSelected || whiteSelected || darkSelected)
            {
                if (myScript.transform.Find("Effects") == null)
                {
                    effects = CreateGameObject("Effects", myScript.transform).transform;
                    effects.SetAsFirstSibling();
                }

                if (blurSelected)
                {
                    var blur = effects.Find("Blur");
                    if (blur == null)
                    {
                        var go           = CreateGameObjectWithRawImage("Blur", effects);
                        var blurMaterial = Resources.Load <Material>("WooPanels/Materials/Blurred");;

                        go.GetComponent <RawImage>().material = blurMaterial;
                    }
                }

                if (whiteSelected)
                {
                    var blur = effects.Find("Whiten");
                    if (blur == null)
                    {
                        var go = CreateGameObjectWithRawImage("Whiten", effects);
                        go.GetComponent <RawImage>().color = new Color(1.0f, 1.0f, 1.0f, 0.3f);
                    }
                }
                if (darkSelected)
                {
                    var blur = effects.Find("Darken");
                    if (blur == null)
                    {
                        var go = CreateGameObjectWithRawImage("Darken", effects);
                        go.GetComponent <RawImage>().color = new Color(0.0f, 0.0f, 0.0f, 0.3f);
                    }
                }
            }
        }
예제 #19
0
 public void Toggle(WooPanel panel, bool immediate = false, bool notify = true)
 {
     if (panel.IsOpenedOrOpening())
     {
         Close(panel, immediate, notify);
     }
     else
     {
         Open(panel, immediate, notify);
     }
 }
예제 #20
0
        public void RewindPanelAnimation(WooPanel panel)
        {
//			if (panelNodes[panel].NotDefined)
//			{
//				panelNodes[panel].simulatedTime = panel.PanelProperties.SkipFirstAnimation ? 1.0f : 0.0f;
//			}
//			else
//			{
            panelNodes[panel].simulatedTime = 1.0f - Mathf.Min(panelNodes[panel].simulatedTime, 1.0f);
//			}
        }
예제 #21
0
 public void Close(WooPanel panel, bool immediate = false, bool notify = true)
 {
     if (!immediate)
     {
         CloseAnimated(panel, notify);
     }
     else
     {
         CloseNotAnimated(panel, notify);
     }
 }
예제 #22
0
 private void Close(WooPanel panel, bool immmediate = false)
 {
     if (editAnimators && !immmediate)
     {
         WooPanelsEngine.Instance.Close(panel);
     }
     else
     {
         WooPanelsEngine.Instance.Close(panel, true);
     }
 }
예제 #23
0
        private void MakeTreeActive(WooPanel panel)
        {
            var parent = GetParent(panel);

            panel.gameObject.SetActive(true);

            if (parent != null)
            {
                MakeTreeActive(parent.Panel);
            }
        }
예제 #24
0
 private void Open(WooPanel panel)
 {
     if (editAnimators)
     {
         WooPanelsEngine.Instance.Open(panel);
     }
     else
     {
         WooPanelsEngine.Instance.Open(panel, true);
     }
 }
예제 #25
0
        private void CloseChildrenAndSelfImmediately(WooPanel panel, bool notify = true)
        {
            var children = GetChildren(panel);

            panel.gameObject.SetActive(true);
            foreach (var child in children)
            {
                CloseChildrenAndSelfImmediately(child.Panel, notify);
            }

            PlayCloseAnimationImmdiately(panel, notify);
        }
예제 #26
0
        private void RebuildIfPanelGameObjectIsNull(WooPanel panel)
        {
            if (panel.gameObject == null)
            {
                Rebuild();
            }

            if (panel.gameObject == null)
            {
                return;
            }
        }
예제 #27
0
        private void SamplePanelAnimator(WooPanel panel)
        {
            if (panel == null || panel.GetComponent <Animator>() == null)
            {
                return;
            }

            AnimationClip animation          = null;
            var           animatorController = panel.GetComponent <Animator>().runtimeAnimatorController;

            animation = panelNodes[panel].GetActiveAnimation();

            var time = panelNodes[panel].simulatedTime;

            time = Mathf.Clamp(time, 0.0f, 1.0f);

            if (panelNodes[panel].IsClosed || panelNodes[panel].IsClosing || panelNodes[panel].IsWaitingToClose)
            {
                if (panelNodes[panel].IsMirrored())
                {
                    time = 1.0f - time;
                }
            }

            if (animation != null)
            {
                                #if UNITY_EDITOR
                if (AnimationMode.InAnimationMode())
                {
                    if (!Application.isPlaying)
                    {
                        AnimationMode.SampleAnimationClip(panel.gameObject, animation, animation.length * time);
                    }
                }
                else
                {
                    if (!Application.isPlaying && panel.GetLayerIndex() != -1)
                    {
                        panel.GetAnimator().Play(animation.name, panel.GetLayerIndex(), time);
                        panel.GetAnimator().Update(Time.deltaTime);
                        panel.GetAnimator().StopPlayback();
                    }
                }
                                #endif

                if (Application.isPlaying && panel.GetLayerIndex() != -1)
                {
                    panel.GetAnimator().Play(animation.name, panel.GetLayerIndex(), time);
                    panel.GetAnimator().Update(Time.deltaTime);
                    panel.GetAnimator().StopPlayback();
                }
            }
        }
예제 #28
0
        public Transform GetRoot(WooPanel panel)
        {
            var underRootPanel     = GetParent(panel);
            var underRootTransform = panel.transform;

            if (underRootPanel != null && underRootPanel.Panel != null)
            {
                underRootTransform = underRootPanel.Panel.transform;
            }

            return(underRootTransform.parent);
        }
예제 #29
0
        public void TryOpeningParents(WooPanel panel, bool immediate = false, bool notify = true, WooPanel target = null)
        {
            var parent = GetParent(panel);

            if (parent != null)
            {
                if (parent.Panel.PanelProperties.WithChild)
                {
                    Open(parent.Panel, immediate, notify, target);
                }
            }
        }
예제 #30
0
        public float TimeToOpenParents(WooPanel panel)
        {
            float timeForParentsToOpen = 0.0f;

            var parent = GetParent(panel);

            if (parent != null)
            {
                timeForParentsToOpen += TimeToOpen(parent.Panel);
            }

            return(timeForParentsToOpen);
        }