public virtual void Setup(WindowComponent component, Layout.Component activatorInstance) {
			
			this.activatorInstance = activatorInstance;
			this.component = component;
			if (this.component != null) this.component.Setup(this);
			
		}
示例#2
0
        public void OnPreviewGUI(Color color, Rect r, GUIStyle background, bool drawInfo, bool selectable, bool hovered, WindowLayoutElement selectedElement, System.Action <WindowLayoutElement> onSelection, System.Action <WindowLayoutElement, Rect, bool> onElementGUI, List <WindowLayoutElement> highlighted)
        {
            var _target = this.target as LayoutWindowType;

            if (_target == null || _target.GetCurrentLayout() == null)
            {
                return;
            }
            var layout         = _target.GetCurrentLayout().layout;
            var layoutElements = _target.GetCurrentLayout().components;

            if (layout != null)
            {
                if (this.layoutEditor == null || this.layoutCache != layout)
                {
                    this.layoutEditor = Editor.CreateEditor(layout) as WindowLayoutEditor;
                }
                this.layoutCache = layout;
                if (this.layoutEditor != null)
                {
                    //var emptyStyle = GUIStyle.none;

                    if (Event.current.type != EventType.Layout)
                    {
                        this.layoutEditor.OnPreviewGUI(color, r, background, drawInfo, selectable: selectable, hovered: hovered, selectedElement: selectedElement, onSelection: onSelection, onElementGUI: (element, elementRect, isClicked) => {
                            if (isClicked == true)
                            {
                                var tag  = element.tag;
                                var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
                                if (comp != null)
                                {
                                    this.selectedComponent = comp;
                                }
                            }

                            /*var tag = element.tag;
                             * var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
                             * if (comp != null) {
                             *
                             *      comp.OnPreviewGUI(elementRect, emptyStyle);
                             *
                             * }*/
                        }, highlighted: highlighted);
                    }
                }
            }
        }
		public virtual void OnPreviewGUI(Color color, Rect r, GUIStyle background, bool drawInfo, bool selectable) {

			var _target = this.target as LayoutWindowType;
			var layout = _target.layout.layout;
			var layoutElements = _target.layout.components;

			if (layout != null) {

				if (this.layoutEditor == null) this.layoutEditor = Editor.CreateEditor(layout) as WindowLayoutEditor;
				if (this.layoutEditor != null) {

					//var emptyStyle = GUIStyle.none;

					if (Event.current.type != EventType.Layout) {

						this.layoutEditor.OnPreviewGUI(color, r, background, drawInfo, true, (element, elementRect, isClicked) => {

							if (isClicked == true) {

								var tag = element.tag;
								var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
								if (comp != null) {

									this.selectedComponent = comp;

								}

							}

							/*var tag = element.tag;
							var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
							if (comp != null) {

								comp.OnPreviewGUI(elementRect, emptyStyle);

							}*/

						});

					}

				}

			}

		}
        public virtual void OnPreviewGUI(Color color, Rect r, GUIStyle background, bool drawInfo, bool selectable)
        {
            var _target        = this.target as LayoutWindowType;
            var layout         = _target.layout.layout;
            var layoutElements = _target.layout.components;

            if (layout != null)
            {
                if (this.layoutEditor == null)
                {
                    this.layoutEditor = Editor.CreateEditor(layout) as WindowLayoutEditor;
                }
                if (this.layoutEditor != null)
                {
                    //var emptyStyle = GUIStyle.none;

                    if (Event.current.type != EventType.Layout)
                    {
                        this.layoutEditor.OnPreviewGUI(color, r, background, drawInfo, true, (element, elementRect, isClicked) => {
                            if (isClicked == true)
                            {
                                var tag  = element.tag;
                                var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
                                if (comp != null)
                                {
                                    this.selectedComponent = comp;
                                }
                            }

                            /*var tag = element.tag;
                             * var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
                             * if (comp != null) {
                             *
                             *      comp.OnPreviewGUI(elementRect, emptyStyle);
                             *
                             * }*/
                        });
                    }
                }
            }
        }
示例#5
0
        private void DrawLayoutItem(WindowBase screen, WindowLayout layout, Layout.Component component, float width)
        {
            if (layout == null)
            {
                return;
            }

            var tempComponent = layout.elements.FirstOrDefault((e) => e != null && e.tag == component.tag);
            var selected      = (Selection.activeGameObject == tempComponent.gameObject);
            var oldColor      = GUI.color;

            var boxStyle = new GUIStyle(EditorStyles.toolbar);

            boxStyle.fixedHeight   = 0f;
            boxStyle.stretchHeight = true;
            boxStyle.padding.right = -20;
            boxStyle.margin.right  = -20;

            var titleStyle = EditorStyles.whiteMiniLabel;

            EditorGUILayout.Separator();

            GUI.color = selected == true ? new Color(0.7f, 1f, 0.7f, 1f) : Color.white;
            EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width));

            if (GUILayout.Button(component.tag.ToString() + " (" + component.description + ")", titleStyle, GUILayout.Width(width)) == true)
            {
                Selection.activeGameObject = tempComponent.gameObject;
            }

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Order:", GUILayout.Width(50f));
            var newOrder = EditorGUILayout.IntField(component.sortingOrder, EditorStyles.miniTextField, GUILayout.Width(50f));

            if (newOrder != component.sortingOrder)
            {
                component.sortingOrder = newOrder;
                this.isScreenDirty     = true;
            }

            if (component.sortingOrder == 0)
            {
                GUILayout.Label("(Auto)", EditorStyles.miniLabel);
            }
            else
            {
                if (GUILayout.Button("Set Auto", EditorStyles.miniButton) == true)
                {
                    component.sortingOrder = 0;
                    this.isScreenDirty     = true;
                }
            }

            EditorGUILayout.EndHorizontal();

            var newComponent = EditorGUILayout.ObjectField(component.component, typeof(WindowComponent), false, GUILayout.Width(width)) as WindowComponent;

            if (newComponent != component.component)
            {
                component.component = newComponent;
                this.isScreenDirty  = true;
            }

            tempComponent.tempEditorComponent = component.component;

            EditorGUILayout.EndVertical();
            var rect = GUILayoutUtility.GetLastRect();

            if (Event.current.type == EventType.MouseUp && rect.Contains(Event.current.mousePosition) == true)
            {
                Selection.activeGameObject = tempComponent.gameObject;
            }

            GUI.color = oldColor;
        }
		public void OnPreviewGUI(Color color, Rect r, GUIStyle background, bool drawInfo, bool selectable, bool hovered, WindowLayoutElement selectedElement, System.Action<WindowLayoutElement> onSelection, System.Action<WindowLayoutElement, Rect, bool> onElementGUI, List<WindowLayoutElement> highlighted) {

			var _target = this.target as LayoutWindowType;
			var layout = _target.layout.layout;
			var layoutElements = _target.layout.components;

			if (layout != null) {

				if (this.layoutEditor == null) this.layoutEditor = Editor.CreateEditor(layout) as WindowLayoutEditor;
				if (this.layoutEditor != null) {

					//var emptyStyle = GUIStyle.none;

					if (Event.current.type != EventType.Layout) {

						this.layoutEditor.OnPreviewGUI(color, r, background, drawInfo, selectable: selectable, hovered: hovered, selectedElement: selectedElement, onSelection: onSelection, onElementGUI: (element, elementRect, isClicked) => {

							if (isClicked == true) {

								var tag = element.tag;
								var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
								if (comp != null) {

									this.selectedComponent = comp;

								}

							}

							/*var tag = element.tag;
							var comp = layoutElements.FirstOrDefault((e) => e.tag == tag);
							if (comp != null) {

								comp.OnPreviewGUI(elementRect, emptyStyle);

							}*/

						}, highlighted: highlighted);

					}

				}

			}

		}