CanHaveSubGroups() public method

public CanHaveSubGroups ( ) : bool
return bool
Example #1
0
        private void DrawHierachyNodes(TreeData treeData, List<HierachyNode> nodes, TreeGroup group, Vector2 offset, float alpha, float fade)
        {
            if (((this.dragNode != null) && this.isDragging) && (this.dragNode.group == group))
            {
                alpha = 0.5f;
                fade = 0.75f;
            }
            Vector3 vector = new Vector3(0f, this.hierachyNodeSize.y * 0.5f, 0f);
            Vector3 vector2 = new Vector3(offset.x, offset.y);
            Handles.color = new Color(0f, 0f, 0f, 0.5f * alpha);
            if (EditorGUIUtility.isProSkin)
            {
                Handles.color = new Color(0.4f, 0.4f, 0.4f, 0.5f * alpha);
            }
            HierachyNode node = null;
            for (int i = 0; i < nodes.Count; i++)
            {
                if (group == nodes[i].group)
                {
                    node = nodes[i];
                    break;
                }
            }
            if (node != null)
            {
                for (int j = 0; j < group.childGroupIDs.Length; j++)
                {
                    TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[j]);
                    for (int m = 0; m < nodes.Count; m++)
                    {
                        if (nodes[m].group == group2)
                        {
                            Handles.DrawLine((node.pos + vector2) - vector, (nodes[m].pos + vector2) + vector);
                        }
                    }
                }
                Rect position = node.rect;
                position.x += offset.x;
                position.y += offset.y;
                int index = 0;
                if (node == this.dropNode)
                {
                    index = 1;
                }
                else if (s_SelectedGroup == node.group)
                {
                    if (s_SelectedNode != null)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 1;
                    }
                }
                GUI.backgroundColor = new Color(1f, 1f, 1f, alpha);
                GUI.contentColor = new Color(1f, 1f, 1f, alpha);
                GUI.Label(position, GUIContent.none, styles.nodeBoxes[index]);
                Rect rect2 = new Rect((position.x + (position.width / 2f)) - 4f, position.y - 2f, 0f, 0f);
                Rect rect3 = new Rect((position.x + (position.width / 2f)) - 4f, (position.y + position.height) - 2f, 0f, 0f);
                Rect rect4 = new Rect(position.x + 1f, position.yMax - 36f, 32f, 32f);
                Rect rect5 = new Rect(position.xMax - 18f, position.yMax - 18f, 16f, 16f);
                Rect rect6 = new Rect(position.x, position.y, position.width - 2f, 16f);
                bool flag = true;
                int num5 = 0;
                GUIContent gUIContent = new GUIContent();
                System.Type type = group.GetType();
                if (type != typeof(TreeGroupBranch))
                {
                    if (type == typeof(TreeGroupLeaf))
                    {
                        gUIContent = TreeEditorHelper.GetGUIContent("|Leaf Group");
                        num5 = 3;
                    }
                    else if (type == typeof(TreeGroupRoot))
                    {
                        gUIContent = TreeEditorHelper.GetGUIContent("|Tree Root Node");
                        num5 = 4;
                        flag = false;
                    }
                }
                else
                {
                    gUIContent = TreeEditorHelper.GetGUIContent("|Branch Group");
                    TreeGroupBranch branch = (TreeGroupBranch) group;
                    switch (branch.geometryMode)
                    {
                        case TreeGroupBranch.GeometryMode.BranchFrond:
                            num5 = 0;
                            break;

                        case TreeGroupBranch.GeometryMode.Branch:
                            num5 = 1;
                            break;

                        case TreeGroupBranch.GeometryMode.Frond:
                            num5 = 2;
                            break;
                    }
                }
                if (flag)
                {
                    Rect hierachyNodeVisRect = this.GetHierachyNodeVisRect(position);
                    GUIContent content = TreeEditorHelper.GetGUIContent("|Show / Hide Group");
                    content.image = styles.visibilityIcons[!group.visible ? 1 : 0].image;
                    GUI.contentColor = new Color(1f, 1f, 1f, 0.7f);
                    if (GUI.Button(hierachyNodeVisRect, content, GUIStyle.none))
                    {
                        group.visible = !group.visible;
                        GUI.changed = true;
                    }
                    GUI.contentColor = Color.white;
                }
                gUIContent.image = styles.nodeIcons[num5].image;
                GUI.contentColor = new Color(1f, 1f, 1f, !group.visible ? 0.5f : 1f);
                if (GUI.Button(rect4, gUIContent, GUIStyle.none) || (this.dragNode == node))
                {
                    TreeGroup group3 = s_SelectedGroup;
                    this.SelectGroup(group);
                    if (group3 == s_SelectedGroup)
                    {
                        Tree target = base.target as Tree;
                        this.FrameSelected(target);
                    }
                }
                GUI.contentColor = Color.white;
                if (group.CanHaveSubGroups())
                {
                    GUI.Label(rect2, GUIContent.none, styles.pinLabel);
                }
                if (flag)
                {
                    GUIContent content3 = TreeEditorHelper.GetGUIContent("|Node Count");
                    content3.text = group.nodeIDs.Length.ToString();
                    GUI.Label(rect6, content3, styles.nodeLabelTop);
                    if (this.m_TreeEditorHelper.NodeHasWrongMaterial(group))
                    {
                        GUI.DrawTexture(rect5, ConsoleWindow.iconErrorSmall);
                    }
                    else if (group.lockFlags != 0)
                    {
                        GUI.DrawTexture(rect5, styles.warningIcon.image);
                    }
                    GUI.Label(rect3, GUIContent.none, styles.pinLabel);
                }
                for (int k = 0; k < group.childGroupIDs.Length; k++)
                {
                    TreeGroup group4 = treeData.GetGroup(group.childGroupIDs[k]);
                    this.DrawHierachyNodes(treeData, nodes, group4, offset, alpha * fade, fade);
                }
                GUI.backgroundColor = Color.white;
                GUI.contentColor = Color.white;
            }
        }
Example #2
0
		private void DrawHierachyNodes(TreeData treeData, List<TreeEditor.HierachyNode> nodes, TreeGroup group, Vector2 offset, float alpha, float fade)
		{
			if (this.dragNode != null && this.isDragging && this.dragNode.group == group)
			{
				alpha = 0.5f;
				fade = 0.75f;
			}
			Vector3 b = new Vector3(0f, this.hierachyNodeSize.y * 0.5f, 0f);
			Vector3 b2 = new Vector3(offset.x, offset.y);
			Handles.color = new Color(0f, 0f, 0f, 0.5f * alpha);
			if (EditorGUIUtility.isProSkin)
			{
				Handles.color = new Color(0.4f, 0.4f, 0.4f, 0.5f * alpha);
			}
			TreeEditor.HierachyNode hierachyNode = null;
			for (int i = 0; i < nodes.Count; i++)
			{
				if (group == nodes[i].group)
				{
					hierachyNode = nodes[i];
					break;
				}
			}
			if (hierachyNode == null)
			{
				return;
			}
			for (int j = 0; j < group.childGroupIDs.Length; j++)
			{
				TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[j]);
				for (int k = 0; k < nodes.Count; k++)
				{
					if (nodes[k].group == group2)
					{
						Handles.DrawLine(hierachyNode.pos + b2 - b, nodes[k].pos + b2 + b);
					}
				}
			}
			Rect rect = hierachyNode.rect;
			rect.x += offset.x;
			rect.y += offset.y;
			int num = 0;
			if (hierachyNode == this.dropNode)
			{
				num = 1;
			}
			else
			{
				if (TreeEditor.s_SelectedGroup == hierachyNode.group)
				{
					if (TreeEditor.s_SelectedNode != null)
					{
						num = 1;
					}
					else
					{
						num = 1;
					}
				}
			}
			GUI.backgroundColor = new Color(1f, 1f, 1f, alpha);
			GUI.contentColor = new Color(1f, 1f, 1f, alpha);
			GUI.Label(rect, GUIContent.none, TreeEditor.styles.nodeBoxes[num]);
			Rect position = new Rect(rect.x + rect.width / 2f - 4f, rect.y - 2f, 0f, 0f);
			Rect position2 = new Rect(rect.x + rect.width / 2f - 4f, rect.y + rect.height - 2f, 0f, 0f);
			Rect position3 = new Rect(rect.x + 1f, rect.yMax - 36f, 32f, 32f);
			Rect position4 = new Rect(rect.xMax - 18f, rect.yMax - 18f, 16f, 16f);
			Rect position5 = new Rect(rect.x, rect.y, rect.width - 2f, 16f);
			bool flag = true;
			int num2 = 0;
			GUIContent gUIContent = new GUIContent();
			Type type = group.GetType();
			if (type == typeof(TreeGroupBranch))
			{
				gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupBranch");
				TreeGroupBranch treeGroupBranch = (TreeGroupBranch)group;
				switch (treeGroupBranch.geometryMode)
				{
				case TreeGroupBranch.GeometryMode.Branch:
					num2 = 1;
					break;
				case TreeGroupBranch.GeometryMode.BranchFrond:
					num2 = 0;
					break;
				case TreeGroupBranch.GeometryMode.Frond:
					num2 = 2;
					break;
				}
			}
			else
			{
				if (type == typeof(TreeGroupLeaf))
				{
					gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupLeaf");
					num2 = 3;
				}
				else
				{
					if (type == typeof(TreeGroupRoot))
					{
						gUIContent = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.TreeGroupRoot");
						num2 = 4;
						flag = false;
					}
				}
			}
			if (flag)
			{
				Rect hierachyNodeVisRect = this.GetHierachyNodeVisRect(rect);
				GUIContent gUIContent2 = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.ShowHide");
				gUIContent2.image = TreeEditor.styles.visibilityIcons[(!group.visible) ? 1 : 0].image;
				GUI.contentColor = new Color(1f, 1f, 1f, 0.7f);
				if (GUI.Button(hierachyNodeVisRect, gUIContent2, GUIStyle.none))
				{
					group.visible = !group.visible;
					GUI.changed = true;
				}
				GUI.contentColor = Color.white;
			}
			gUIContent.image = TreeEditor.styles.nodeIcons[num2].image;
			GUI.contentColor = new Color(1f, 1f, 1f, (!group.visible) ? 0.5f : 1f);
			if (GUI.Button(position3, gUIContent, GUIStyle.none) || this.dragNode == hierachyNode)
			{
				TreeGroup treeGroup = TreeEditor.s_SelectedGroup;
				this.SelectGroup(group);
				if (treeGroup == TreeEditor.s_SelectedGroup)
				{
					Tree tree = this.target as Tree;
					this.FrameSelected(tree);
				}
			}
			GUI.contentColor = Color.white;
			if (group.CanHaveSubGroups())
			{
				GUI.Label(position, GUIContent.none, TreeEditor.styles.pinLabel);
			}
			if (flag)
			{
				GUIContent gUIContent3 = TreeEditorHelper.GetGUIContent("TreeEditor.Hierachy.NodeCount");
				gUIContent3.text = group.nodeIDs.Length.ToString();
				GUI.Label(position5, gUIContent3, TreeEditor.styles.nodeLabelTop);
				if (this.m_TreeEditorHelper.NodeHasWrongMaterial(group))
				{
					GUI.DrawTexture(position4, ConsoleWindow.iconErrorSmall);
				}
				else
				{
					if (group.lockFlags != 0)
					{
						GUI.DrawTexture(position4, TreeEditor.styles.warningIcon.image);
					}
				}
				GUI.Label(position2, GUIContent.none, TreeEditor.styles.pinLabel);
			}
			for (int l = 0; l < group.childGroupIDs.Length; l++)
			{
				TreeGroup group3 = treeData.GetGroup(group.childGroupIDs[l]);
				this.DrawHierachyNodes(treeData, nodes, group3, offset, alpha * fade, fade);
			}
			GUI.backgroundColor = Color.white;
			GUI.contentColor = Color.white;
		}