Beispiel #1
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 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);

					}

				}

			}

		}
        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);
                             *
                             * }*/
                        });
                    }
                }
            }
        }