private void BeginGUI() { preSkin = GUI.skin; preContentColor = GUI.contentColor; preBgColor = GUI.backgroundColor; preColor = GUI.color; preMat4x4 = GUI.matrix; preEnable = GUI.enabled; GUI.color = color; GUI.backgroundColor = backgroundColor; GUI.contentColor = contentColor; Vector2 tmp = new Vector2(rotateOffset.x * position.width, rotateOffset.y * position.height); GUIUtility.RotateAroundPivot(rotateAngle, position.center + tmp); bool bo = this.enable; if (bo) { GUINode d = this; while (d.parent != null) { d = d.parent; bo = d.enable && bo; if (!bo) { break; } } } GUI.enabled = bo; }
public GUINode Find(string path) { if (children.Count == 0) { return(null); } if (!path.Contains("/")) { for (int i = 0; i < children.Count; i++) { GUINode tmp = children[i] as GUINode; if (tmp.name == path) { return(tmp); } } return(null); } else { int index = path.IndexOf("/"); string tmp = path.Substring(0, index); path = path.Substring(index + 1); for (int i = 0; i < children.Count; i++) { GUINode tmpE = children[i] as GUINode; if (tmpE.name == tmp) { return(tmpE.Find(path)); } } return(null); } }
protected ParentGUINode(ParentGUINode other) : base(other) { for (int i = 0; i < other.children.Count; i++) { GUINode element = other.children[i] as GUINode; GUINode copy = Activator.CreateInstance(element.GetType(), other.children[i]) as GUINode; copy.parent = this; } }
protected virtual void OnCtrlD() { if (this.element.GetType() == typeof(GUICanvas)) { return; } GUINode copy = Activator.CreateInstance(this.element.GetType(), this.element) as GUINode; (this.element.parent as ParentGUINode).Node(copy); GUINodeSelection.copyNode = null; }
public void EleGUI(GUINode ele) { GUINodeEditor des = dic[ele.GetType()]; des.node = ele; des.OnSceneGUI(() => { for (int i = 0; i < ele.Children.Count; i++) { EleGUI(ele.Children[i] as GUINode); } }); }
private void OnCeateElement(Type type) { GUINode copy = Activator.CreateInstance(type) as GUINode; if (!this.element.GetType().IsSubclassOf(typeof(ParentGUINode))) { (this.element.parent as ParentGUINode).Node(copy); } else { (this.element as ParentGUINode).Node(copy); } }
protected virtual void OnCtrlV() { if (GUINodeSelection.copyNode == null) { return; } GUINode copy = Activator.CreateInstance(GUINodeSelection.copyNode.GetType(), GUINodeSelection.copyNode) as GUINode; if (this.element.GetType() != typeof(GUICanvas)) { (this.element.parent as ParentGUINode).Node(copy); } else { (this.element as ParentGUINode).Node(copy); } GUINodeSelection.copyNode = null; }
private void MouseDragEve(Rect r, Event e) { bool CouldPutdown = r.Contains(e.mousePosition) && GUINodeSelection.dragNode != null && GUINodeSelection.dragNode != this.element; GUINode tmp = this.element; while (tmp.parent != null) { tmp = tmp.parent; if (tmp == GUINodeSelection.dragNode) { CouldPutdown = false; break; } } if (CouldPutdown) { GUI.Box(r, "", this.element.GetType().IsSubclassOf(typeof(ParentGUINode)) && foldOn ? "SelectionRect" : "PR Insertion"); } if (CouldPutdown && e.type == EventType.MouseUp) { if (this.element.GetType().IsSubclassOf(typeof(ParentGUINode)) && foldOn) { (this.element as ParentGUINode).Node(GUINodeSelection.dragNode); } else { (this.element.parent as ParentGUINode).Node(GUINodeSelection.dragNode); GUINodeSelection.dragNode.siblingIndex = element.siblingIndex + 1; } GUINodeSelection.dragNode = null; } else if (GUINodeSelection.node == this.element) { if (e.type == EventType.MouseDrag) { GUINodeSelection.dragNode = GUINodeSelection.node; } else if (e.type == EventType.MouseUp) { GUINodeSelection.dragNode = null; } } }
public Trunk(Trunk parent, GUINode element) { nameLabel = new RenameLabelDrawer(); nameLabel.value = element.name; nameLabel.onEndEdit += (str) => { element.name = str.Trim(); }; this.element = element; this.parent = parent; children = new List <Trunk>(); if (element.Children.Count > 0) { for (int i = 0; i < element.Children.Count; i++) { children.Add(new Trunk(this, element.Children[i] as GUINode)); } } }
protected GUINode(GUINode other) { m_name = other.m_name; m_enable = other.m_enable; m_active = other.m_active; rotateAngle = other.rotateAngle; rotateOffset = other.rotateOffset; color = other.color; contentColor = other.contentColor; backgroundColor = other.backgroundColor; enableMinSize = other.enableMinSize; enableSize = other.enableSize; enableMaxSize = other.enableMaxSize; enableExpandHeight = other.enableExpandHeight; enableExpandWidth = other.enableExpandWidth; size = other.size; minSize = other.minSize; maxSize = other.maxSize; expandHeight = other.expandHeight; expandWidth = other.expandWidth; }
public override void DeSerialize(XmlElement root) { base.DeSerialize(root); children.Clear(); XmlElement ele = root.SelectSingleNode("children") as XmlElement; for (int i = 0; i < ele.ChildNodes.Count; i++) { XmlElement child = ele.ChildNodes[i] as XmlElement; Type type = GUINodes.nodeTypes.ToList().Find((tmp) => { return(tmp.Name == child.GetAttribute("ElementType")); }); if (type == null) { throw new Exception(" Type Not Found " + child.GetAttribute("ElementType")); } GUINode element = Activator.CreateInstance(type, null) as GUINode; element.DeSerialize(child); element.parent = this; } }
public void OnCanvasTreeGUI(Rect rect, Event e) { bool active = element.active; if (active) { GUINode ele = element; while (ele.parent != null) { ele = ele.parent; active = active && ele.active; if (!active) { break; } } } GUI.enabled = active; var rs = rect.HorizontalSplit(LineHeight); Rect selfRect = rs[0]; if (GUINodeSelection.node == this.element && e.type == EventType.Repaint) { new GUIStyle("SelectionRect").Draw(selfRect, false, false, false, false); } selfRect.xMin += 20 * element.depth; Rect childrenRect = rs[1]; childrenRect.xMin += 20 * element.depth; if (children.Count > 0) { var rss = selfRect.VerticalSplit(12); foldOn = EditorGUI.Foldout(rss[0], foldOn, "", false); nameLabel.OnGUI(rss[1]); //GUI.Label(rss[1], element.name); if (tree.HandleEve) { Eve(rss[1], e); } if (!foldOn) { return; } float y = 0; for (int i = 0; i < children.Count; i++) { Rect r = new Rect(rect.x, childrenRect.y + y, rect.width, children[i].Height); y += children[i].Height; children[i].OnCanvasTreeGUI(r, e); } } else { nameLabel.OnGUI(selfRect); if (tree.HandleEve) { Eve(selfRect, e); } } }