public void UpdateSize(float progress)
        {
            var popupOffset    = FlowSceneItem.POPUP_OFFSET;
            var inspectorWidth = FlowSceneView.GetInspector() ? FlowSceneView.GetInspector().GetWidth() : 0f;
            var hierarchyWidth = FlowSceneView.GetHierarchy() ? FlowSceneView.GetHierarchy().GetWidth() : 0f;

            this.popupSize = new Vector2(this.rootWindow.position.width - popupOffset * 2f - inspectorWidth - hierarchyWidth, (this.rootWindow.position.height - popupOffset * 2f) * progress);
            this.popupRect = new Rect(this.rootWindow.position.x + popupOffset + inspectorWidth, this.rootWindow.position.y + popupOffset, this.popupSize.x, this.popupSize.y);

            this.position = this.popupRect;
        }
 public override void OnClose()
 {
     FlowSceneView.Reset(this.rootWindow.OnItemProgress, onDestroy: true);
 }
Exemple #3
0
        public void OnGUI()
        {
            this.position = this.popupRect;

            var color = GUI.color;

            color.a   = this.progress;
            GUI.color = color;

            var depthOffset = 15f;

            var screen = (FlowSceneView.GetItem() != null) ? FlowSceneView.GetItem().GetScreenInstance() : null;

            UnityEngine.UI.Windows.WindowLayout layout = (FlowSceneView.GetItem() != null) ? FlowSceneView.GetItem().GetLayoutInstance() : null;

            if (layout != null || screen != null)
            {
                this.scrollPosition = EditorGUILayout.BeginScrollView(this.scrollPosition, false, false);

                var elementStyle = new GUIStyle(EditorStyles.toolbarTextField);
                elementStyle.stretchHeight = false;
                elementStyle.fixedHeight   = 0f;
                elementStyle.margin        = new RectOffset(0, 0, 0, 2);
                elementStyle.padding       = new RectOffset(10, 10, 6, 6);

                GUILayout.BeginHorizontal(elementStyle);
                if (screen != null)
                {
                    var oldBackColor = GUI.backgroundColor;
                    var backColor    = new Color(0.4f, 0.4f, 0.4f, 1f);
                    GUI.backgroundColor = backColor;

                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label(screen.name, EditorStyles.whiteLargeLabel);
                        GUILayout.Label("Screen", EditorStyles.miniLabel);
                    }
                    GUILayout.EndVertical();

                    var rect = GUILayoutUtility.GetLastRect();
                    if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) == true)
                    {
                        FlowSceneView.GetItem().SetTab(2);
                    }

                    GUI.backgroundColor = oldBackColor;
                }
                GUILayout.EndHorizontal();

                if (layout != null)
                {
                    var root = layout.root;
                    this.Traverse(root.transform, (element, depth) => {
                        var title       = string.Empty;
                        var descr       = string.Empty;
                        var headerStyle = EditorStyles.whiteLargeLabel;
                        color           = Color.white;

                        var layoutRoot = element.GetComponent <WindowLayoutRoot>();
                        if (layoutRoot != null)
                        {
                            headerStyle           = new GUIStyle(EditorStyles.whiteLargeLabel);
                            headerStyle.fontStyle = FontStyle.Bold;
                            title = "ROOT";
                            descr = "Layout Root";

                            color = new Color(0.8f, 0.8f, 0.6f, 1f);
                        }

                        var layoutElement = element.GetComponent <WindowLayoutElement>();
                        if (layoutElement != null)
                        {
                            title = layoutElement.comment;
                            descr = layoutElement.tag.ToString() + " (" + layoutElement.name + ")";
                        }

                        var maxDepth   = 10f;
                        var depthValue = depth / maxDepth;

                        var oldColor        = GUI.color;
                        var oldBackColor    = GUI.backgroundColor;
                        var backColor       = Selection.activeTransform == element ? new Color(0.7f, 1f, 0.7f, 1f) : color;
                        backColor.a         = 1f - depthValue;
                        GUI.backgroundColor = backColor;

                        GUILayout.BeginHorizontal(elementStyle);
                        {
                            GUILayout.BeginVertical();
                            {
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(string.Empty, GUILayout.Width(depthOffset * depth));
                                    GUILayout.Label(title, headerStyle);
                                }
                                GUILayout.EndVertical();
                                GUILayout.BeginHorizontal();
                                {
                                    GUILayout.Label(string.Empty, GUILayout.Width(depthOffset * depth));
                                    GUILayout.Label(descr, EditorStyles.miniLabel);
                                }
                                GUILayout.EndVertical();
                            }
                            GUILayout.EndVertical();
                        }
                        GUILayout.EndHorizontal();

                        GUI.color           = oldColor;
                        GUI.backgroundColor = oldBackColor;

                        var rect     = GUILayoutUtility.GetLastRect();
                        var contains = rect.Contains(Event.current.mousePosition);

                        if (layoutElement != null)
                        {
                            var size             = 20f;
                            var addButtonRect    = rect;
                            addButtonRect.x     += addButtonRect.width - size - elementStyle.padding.right;
                            addButtonRect.y     -= elementStyle.margin.bottom;
                            addButtonRect.width  = size;
                            addButtonRect.height = size;

                            if (GUI.Button(addButtonRect, "+", EditorStyles.toolbarButton) == true)
                            {
                                // Add New Layout Element before current
                                this.CreateLayoutElement(element);
                                return;
                            }

                            var removeButtonRect = addButtonRect;
                            removeButtonRect.x  -= removeButtonRect.width;

                            if (GUI.Button(removeButtonRect, "-", EditorStyles.toolbarButton) == true)
                            {
                                this.RemoveLayoutElement(element);
                                return;
                            }

                            contains = contains && !addButtonRect.Contains(Event.current.mousePosition);
                        }

                        if (Event.current.type == EventType.MouseDown && contains == true)
                        {
                            Selection.activeTransform = element;
                        }
                    });
                }

                EditorGUILayout.EndScrollView();
            }
            else
            {
                var style = new GUIStyle(EditorStyles.whiteLargeLabel);
                style.alignment        = TextAnchor.MiddleCenter;
                style.normal.textColor = Color.gray;

                var rect = this.position;
                rect.x = 0f;
                rect.y = 0f;
                GUI.Label(rect, "No Scene and Layout Selected", style);
            }
        }