GetGroup() public method

public GetGroup ( int id ) : TreeGroup
id int
return TreeGroup
Beispiel #1
0
 private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
 {
     if (group is TreeGroupBranch)
     {
         TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBranch, barkShaders, leafShaders);
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBreak, barkShaders, leafShaders);
         TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialFrond, barkShaders, leafShaders);
     }
     else
     {
         if (group is TreeGroupLeaf)
         {
             TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
             TreeEditorHelper.AddShaderFromMaterial(treeGroupLeaf.materialLeaf, barkShaders, leafShaders);
         }
     }
     int[] childGroupIDs = group.childGroupIDs;
     for (int i = 0; i < childGroupIDs.Length; i++)
     {
         int       id     = childGroupIDs[i];
         TreeGroup group2 = treeData.GetGroup(id);
         TreeEditorHelper.GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
     }
 }
Beispiel #2
0
 private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, TreeEditorHelper.NodeType nodeType)
 {
     if (group is TreeGroupBranch && nodeType == TreeEditorHelper.NodeType.BarkNode)
     {
         TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBranch, shader);
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBreak, shader);
         TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialFrond, shader);
     }
     else
     {
         if (group is TreeGroupLeaf && nodeType == TreeEditorHelper.NodeType.LeafNode)
         {
             TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
             TreeEditorHelper.ChangeShaderOnMaterial(treeGroupLeaf.materialLeaf, shader);
         }
     }
     int[] childGroupIDs = group.childGroupIDs;
     for (int i = 0; i < childGroupIDs.Length; i++)
     {
         int       id     = childGroupIDs[i];
         TreeGroup group2 = treeData.GetGroup(id);
         TreeEditorHelper.ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
     }
 }
 private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, NodeType nodeType)
 {
     if ((group is TreeGroupBranch) && (nodeType == NodeType.BarkNode))
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         ChangeShaderOnMaterial(branch.materialBranch, shader);
         ChangeShaderOnMaterial(branch.materialBreak, shader);
         ChangeShaderOnMaterial(branch.materialFrond, shader);
     }
     else if ((group is TreeGroupLeaf) && (nodeType == NodeType.LeafNode))
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         ChangeShaderOnMaterial(leaf.materialLeaf, shader);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
     }
 }
 private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, NodeType nodeType)
 {
     if ((group is TreeGroupBranch) && (nodeType == NodeType.BarkNode))
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         ChangeShaderOnMaterial(branch.materialBranch, shader);
         ChangeShaderOnMaterial(branch.materialBreak, shader);
         ChangeShaderOnMaterial(branch.materialFrond, shader);
     }
     else if ((group is TreeGroupLeaf) && (nodeType == NodeType.LeafNode))
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         ChangeShaderOnMaterial(leaf.materialLeaf, shader);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
     }
 }
 private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
 {
     if (group is TreeGroupBranch)
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         AddShaderFromMaterial(branch.materialBranch, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialBreak, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialFrond, barkShaders, leafShaders);
     }
     else if (group is TreeGroupLeaf)
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         AddShaderFromMaterial(leaf.materialLeaf, barkShaders, leafShaders);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
     }
 }
        private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, NodeType nodeType)
        {
            if (group is TreeGroupBranch && nodeType == NodeType.BarkNode)
            {
                TreeGroupBranch tgb = group as TreeGroupBranch;
                ChangeShaderOnMaterial(tgb.materialBranch, shader);
                ChangeShaderOnMaterial(tgb.materialBreak, shader);
                ChangeShaderOnMaterial(tgb.materialFrond, shader);
            }
            else if (group is TreeGroupLeaf && nodeType == NodeType.LeafNode)
            {
                TreeGroupLeaf tgl = group as TreeGroupLeaf;
                ChangeShaderOnMaterial(tgl.materialLeaf, shader);
            }

            foreach (int id in group.childGroupIDs)
            {
                TreeGroup childGroup = treeData.GetGroup(id);
                ChangeShaderOnMaterials(treeData, shader, childGroup, nodeType);
            }
        }
        private static void GetAllTreeShaders(TreeData treeData, List <string> barkShaders, List <string> leafShaders, TreeGroup group)
        {
            if (group is TreeGroupBranch)
            {
                TreeGroupBranch tgb = group as TreeGroupBranch;
                AddShaderFromMaterial(tgb.materialBranch, barkShaders, leafShaders);
                AddShaderFromMaterial(tgb.materialBreak, barkShaders, leafShaders);
                AddShaderFromMaterial(tgb.materialFrond, barkShaders, leafShaders);
            }
            else if (group is TreeGroupLeaf)
            {
                TreeGroupLeaf tgl = group as TreeGroupLeaf;
                AddShaderFromMaterial(tgl.materialLeaf, barkShaders, leafShaders);
            }

            foreach (int id in group.childGroupIDs)
            {
                TreeGroup childGroup = treeData.GetGroup(id);
                GetAllTreeShaders(treeData, barkShaders, leafShaders, childGroup);
            }
        }
		private void HandleDragHierachyNodes(TreeData treeData, List<TreeEditor.HierachyNode> nodes)
		{
			if (this.dragNode == null)
			{
				this.isDragging = false;
				this.dropNode = null;
			}
			int controlID = GUIUtility.GetControlID(FocusType.Passive);
			EventType typeForControl = Event.current.GetTypeForControl(controlID);
			if (typeForControl == EventType.MouseDown && Event.current.button == 0)
			{
				for (int i = 0; i < nodes.Count; i++)
				{
					if (nodes[i].rect.Contains(Event.current.mousePosition))
					{
						if (!this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition))
						{
							if (!(nodes[i].group is TreeGroupRoot))
							{
								this.dragClickPos = Event.current.mousePosition;
								this.dragNode = nodes[i];
								GUIUtility.hotControl = controlID;
								Event.current.Use();
								break;
							}
						}
					}
				}
			}
			if (this.dragNode != null)
			{
				this.dropNode = null;
				for (int j = 0; j < nodes.Count; j++)
				{
					if (nodes[j].rect.Contains(Event.current.mousePosition))
					{
						TreeGroup group = this.dragNode.group;
						TreeGroup group2 = nodes[j].group;
						if (group2 != group)
						{
							if (group2.CanHaveSubGroups())
							{
								if (treeData.GetGroup(group.parentGroupID) != group2)
								{
									if (!treeData.IsAncestor(group, group2))
									{
										this.dropNode = nodes[j];
										break;
									}
								}
							}
						}
					}
				}
				if (typeForControl == EventType.MouseMove || typeForControl == EventType.MouseDrag)
				{
					if ((this.dragClickPos - Event.current.mousePosition).magnitude > 10f)
					{
						this.isDragging = true;
					}
					Event.current.Use();
				}
				else
				{
					if (typeForControl == EventType.MouseUp && GUIUtility.hotControl == controlID)
					{
						if (this.dropNode != null)
						{
							this.UndoStoreSelected(TreeEditor.EditMode.Everything);
							TreeGroup group3 = this.dragNode.group;
							TreeGroup group4 = this.dropNode.group;
							treeData.SetGroupParent(group3, group4);
							this.m_WantCompleteUpdate = true;
						}
						else
						{
							base.Repaint();
						}
						this.dragNode = null;
						this.dropNode = null;
						GUIUtility.hotControl = 0;
						Event.current.Use();
					}
				}
			}
		}
		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;
		}
Beispiel #10
0
 private void VerifySelection(TreeData treeData)
 {
     TreeGroup g = s_SelectedGroup;
     TreeNode node = s_SelectedNode;
     if (g != null)
     {
         g = treeData.GetGroup(g.uniqueID);
     }
     if (node != null)
     {
         node = treeData.GetNode(node.uniqueID);
     }
     if (((g != treeData.root) && (g != null)) && !treeData.IsAncestor(treeData.root, g))
     {
         g = null;
         node = null;
     }
     if ((node != null) && (treeData.GetGroup(node.groupID) != g))
     {
         node = null;
     }
     if (g == null)
     {
         g = treeData.root;
     }
     if ((s_SelectedGroup == null) || (g != s_SelectedGroup))
     {
         this.SelectGroup(g);
         if (node != null)
         {
             this.SelectNode(node, treeData);
         }
     }
 }
Beispiel #11
0
		public void InspectorBranch(TreeData treeData, TreeGroupBranch group)
		{
			this.InspectorEditTools(this.target as Tree);
			GUIContent[] names = new GUIContent[]
			{
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupBranch.Distribution"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupBranch.Geometry"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupBranch.Shape"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupBranch.Fronds"),
				TreeEditorHelper.GetGUIContent("TreeEditor.TreeGroupBranch.Animation")
			};
			string str = "TreeEditor.TreeGroupBranch.";
			bool enabled = GUI.enabled;
			if (TreeEditor.s_SelectedGroup.lockFlags != 0)
			{
				this.GUIunlockbox(treeData);
			}
			TreeEditor.BeginSettingsSection(0, names);
			this.InspectorDistribution(treeData, group);
			TreeEditor.EndSettingsSection();
			TreeEditor.BeginSettingsSection(1, names);
			this.PrepareSpacing(false);
			group.lodQualityMultiplier = this.GUISlider(TreeEditor.PropertyType.Normal, str + "LODQuality", group.lodQualityMultiplier, 0f, 2f, false);
			string[] optionIDs = new string[]
			{
				"BranchOnly",
				"BranchAndFronds",
				"FrondsOnly"
			};
			group.geometryMode = (TreeGroupBranch.GeometryMode)this.GUIPopup(TreeEditor.PropertyType.FullUpdate, str + "GeometryMode", str + "GeometryModeOption", optionIDs, (int)group.geometryMode, false);
			if (group.geometryMode != TreeGroupBranch.GeometryMode.Frond)
			{
				group.materialBranch = this.GUIMaterialField(TreeEditor.PropertyType.FullUpdate, group.uniqueID, str + "BranchMaterial", group.materialBranch, TreeEditorHelper.NodeType.BarkNode);
			}
			group.materialBreak = this.GUIMaterialField(TreeEditor.PropertyType.FullUpdate, group.uniqueID, str + "BreakMaterial", group.materialBreak, TreeEditorHelper.NodeType.BarkNode);
			if (group.geometryMode != TreeGroupBranch.GeometryMode.Branch)
			{
				group.materialFrond = this.GUIMaterialField(TreeEditor.PropertyType.FullUpdate, group.uniqueID, str + "FrondMaterial", group.materialFrond, TreeEditorHelper.NodeType.BarkNode);
			}
			TreeEditor.EndSettingsSection();
			TreeEditor.BeginSettingsSection(2, names);
			this.PrepareSpacing(true);
			GUI.enabled = (group.lockFlags == 0);
			group.height = this.GUIMinMaxSlider(TreeEditor.PropertyType.Normal, str + "Length", group.height, 0.1f, 50f, false);
			GUI.enabled = (group.geometryMode != TreeGroupBranch.GeometryMode.Frond);
			group.radiusMode = this.GUIToggle(TreeEditor.PropertyType.Normal, str + "IsLengthRelative", group.radiusMode, false);
			GUI.enabled = (group.geometryMode != TreeGroupBranch.GeometryMode.Frond);
			group.radius = this.GUISlider(TreeEditor.PropertyType.Normal, str + "Radius", group.radius, 0.1f, 5f, true);
			AnimationCurve animationCurve = group.radiusCurve;
			if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA))
			{
				group.radiusCurve = animationCurve;
			}
			GUI.enabled = (group.geometryMode != TreeGroupBranch.GeometryMode.Frond);
			group.capSmoothing = this.GUISlider(TreeEditor.PropertyType.Normal, str + "CapSmoothing", group.capSmoothing, 0f, 1f, false);
			GUI.enabled = true;
			EditorGUILayout.Space();
			GUI.enabled = (group.lockFlags == 0);
			group.crinklyness = this.GUISlider(TreeEditor.PropertyType.Normal, str + "Crinklyness", group.crinklyness, 0f, 1f, true);
			animationCurve = group.crinkCurve;
			if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA))
			{
				group.crinkCurve = animationCurve;
			}
			GUI.enabled = (group.lockFlags == 0);
			group.seekBlend = this.GUISlider(TreeEditor.PropertyType.Normal, str + "SeekSunGround", group.seekBlend, 0f, 1f, true);
			animationCurve = group.seekCurve;
			if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesB))
			{
				group.seekCurve = animationCurve;
			}
			GUI.enabled = true;
			EditorGUILayout.Space();
			GUI.enabled = (group.geometryMode != TreeGroupBranch.GeometryMode.Frond);
			group.noise = this.GUISlider(TreeEditor.PropertyType.Normal, str + "Noise", group.noise, 0f, 1f, true);
			animationCurve = group.noiseCurve;
			if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA))
			{
				group.noiseCurve = animationCurve;
			}
			group.noiseScaleU = this.GUISlider(TreeEditor.PropertyType.Normal, str + "NoiseScaleU", group.noiseScaleU, 0f, 1f, false);
			group.noiseScaleV = this.GUISlider(TreeEditor.PropertyType.Normal, str + "NoiseScaleV", group.noiseScaleV, 0f, 1f, false);
			EditorGUILayout.Space();
			GUI.enabled = (group.geometryMode != TreeGroupBranch.GeometryMode.Frond);
			if (treeData.GetGroup(group.parentGroupID) == treeData.root)
			{
				group.flareSize = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FlareRadius", group.flareSize, 0f, 5f, false);
				group.flareHeight = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FlareHeight", group.flareHeight, 0f, 1f, false);
				group.flareNoise = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FlareNoise", group.flareNoise, 0f, 1f, false);
			}
			else
			{
				group.weldHeight = this.GUISlider(TreeEditor.PropertyType.Normal, str + "WeldHeight", group.weldHeight, 0.01f, 1f, false);
				group.weldSpreadTop = this.GUISlider(TreeEditor.PropertyType.Normal, str + "WeldSpreadTop", group.weldSpreadTop, 0f, 1f, false);
				group.weldSpreadBottom = this.GUISlider(TreeEditor.PropertyType.Normal, str + "WeldSpreadBottom", group.weldSpreadBottom, 0f, 1f, false);
			}
			EditorGUILayout.Space();
			group.breakingChance = this.GUISlider(TreeEditor.PropertyType.Normal, str + "BreakChance", group.breakingChance, 0f, 1f, false);
			group.breakingSpot = this.GUIMinMaxSlider(TreeEditor.PropertyType.Normal, str + "BreakLocation", group.breakingSpot, 0f, 1f, false);
			TreeEditor.EndSettingsSection();
			if (group.geometryMode != TreeGroupBranch.GeometryMode.Branch)
			{
				TreeEditor.BeginSettingsSection(3, names);
				this.PrepareSpacing(true);
				group.frondCount = this.GUIIntSlider(TreeEditor.PropertyType.Normal, str + "FrondCount", group.frondCount, 1, 16, false);
				group.frondWidth = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FrondWidth", group.frondWidth, 0.1f, 10f, true);
				animationCurve = group.frondCurve;
				if (this.GUICurve(TreeEditor.PropertyType.Normal, animationCurve, this.m_CurveRangesA))
				{
					group.frondCurve = animationCurve;
				}
				group.frondRange = this.GUIMinMaxSlider(TreeEditor.PropertyType.Normal, str + "FrondRange", group.frondRange, 0f, 1f, false);
				group.frondRotation = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FrondRotation", group.frondRotation, 0f, 1f, false);
				group.frondCrease = this.GUISlider(TreeEditor.PropertyType.Normal, str + "FrondCrease", group.frondCrease, -1f, 1f, false);
				GUI.enabled = true;
				TreeEditor.EndSettingsSection();
			}
			TreeEditor.BeginSettingsSection(4, names);
			this.InspectorAnimation(treeData, group);
			TreeEditor.EndSettingsSection();
			GUI.enabled = enabled;
			EditorGUILayout.Space();
		}
Beispiel #12
0
		private void VerifySelection(TreeData treeData)
		{
			TreeGroup treeGroup = TreeEditor.s_SelectedGroup;
			TreeNode treeNode = TreeEditor.s_SelectedNode;
			if (treeGroup != null)
			{
				treeGroup = treeData.GetGroup(treeGroup.uniqueID);
			}
			if (treeNode != null)
			{
				treeNode = treeData.GetNode(treeNode.uniqueID);
			}
			if (treeGroup != treeData.root && treeGroup != null && !treeData.IsAncestor(treeData.root, treeGroup))
			{
				treeGroup = null;
				treeNode = null;
			}
			if (treeNode != null && treeData.GetGroup(treeNode.groupID) != treeGroup)
			{
				treeNode = null;
			}
			if (treeGroup == null)
			{
				treeGroup = treeData.root;
			}
			if (TreeEditor.s_SelectedGroup != null && treeGroup == TreeEditor.s_SelectedGroup)
			{
				return;
			}
			this.SelectGroup(treeGroup);
			if (treeNode != null)
			{
				this.SelectNode(treeNode, treeData);
			}
		}
Beispiel #13
0
 private void DeleteSelected(TreeData treeData)
 {
     this.UndoStoreSelected(EditMode.Delete);
     if (s_SelectedNode != null)
     {
         if (s_SelectedPoint >= 1)
         {
             if (s_SelectedNode.spline.nodes.Length > 2)
             {
                 if (s_SelectedGroup.lockFlags == 0)
                 {
                     s_SelectedGroup.Lock();
                 }
                 s_SelectedNode.spline.RemoveNode(s_SelectedPoint);
                 s_SelectedPoint = Mathf.Max(s_SelectedPoint - 1, 0);
             }
         }
         else
         {
             if ((s_SelectedGroup != null) && (s_SelectedGroup.nodeIDs.Length == 1))
             {
                 s_SelectedNode = null;
                 this.DeleteSelected(treeData);
                 return;
             }
             treeData.DeleteNode(s_SelectedNode);
             s_SelectedGroup.Lock();
             this.SelectGroup(s_SelectedGroup);
         }
     }
     else if (s_SelectedGroup != null)
     {
         TreeGroup group = treeData.GetGroup(s_SelectedGroup.parentGroupID);
         if (group == null)
         {
             return;
         }
         treeData.DeleteGroup(s_SelectedGroup);
         this.SelectGroup(group);
     }
     this.m_WantCompleteUpdate = true;
     UpdateMesh(base.target as Tree);
     this.m_WantCompleteUpdate = false;
 }
Beispiel #14
0
 private void BuildHierachyNodes(TreeData treeData, List<HierachyNode> nodes, TreeGroup group, int depth)
 {
     HierachyNode item = new HierachyNode {
         group = group,
         pos = new Vector3(0f, depth * this.hierachySpread.y, 0f)
     };
     nodes.Add(item);
     for (int i = 0; i < group.childGroupIDs.Length; i++)
     {
         TreeGroup group2 = treeData.GetGroup(group.childGroupIDs[i]);
         this.BuildHierachyNodes(treeData, nodes, group2, depth - 1);
     }
 }
		private static void ChangeShaderOnMaterials(TreeData treeData, Shader shader, TreeGroup group, TreeEditorHelper.NodeType nodeType)
		{
			if (group is TreeGroupBranch && nodeType == TreeEditorHelper.NodeType.BarkNode)
			{
				TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
				TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBranch, shader);
				TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialBreak, shader);
				TreeEditorHelper.ChangeShaderOnMaterial(treeGroupBranch.materialFrond, shader);
			}
			else
			{
				if (group is TreeGroupLeaf && nodeType == TreeEditorHelper.NodeType.LeafNode)
				{
					TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
					TreeEditorHelper.ChangeShaderOnMaterial(treeGroupLeaf.materialLeaf, shader);
				}
			}
			int[] childGroupIDs = group.childGroupIDs;
			for (int i = 0; i < childGroupIDs.Length; i++)
			{
				int id = childGroupIDs[i];
				TreeGroup group2 = treeData.GetGroup(id);
				TreeEditorHelper.ChangeShaderOnMaterials(treeData, shader, group2, nodeType);
			}
		}
		private static void GetAllTreeShaders(TreeData treeData, List<string> barkShaders, List<string> leafShaders, TreeGroup group)
		{
			if (group is TreeGroupBranch)
			{
				TreeGroupBranch treeGroupBranch = group as TreeGroupBranch;
				TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBranch, barkShaders, leafShaders);
				TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialBreak, barkShaders, leafShaders);
				TreeEditorHelper.AddShaderFromMaterial(treeGroupBranch.materialFrond, barkShaders, leafShaders);
			}
			else
			{
				if (group is TreeGroupLeaf)
				{
					TreeGroupLeaf treeGroupLeaf = group as TreeGroupLeaf;
					TreeEditorHelper.AddShaderFromMaterial(treeGroupLeaf.materialLeaf, barkShaders, leafShaders);
				}
			}
			int[] childGroupIDs = group.childGroupIDs;
			for (int i = 0; i < childGroupIDs.Length; i++)
			{
				int id = childGroupIDs[i];
				TreeGroup group2 = treeData.GetGroup(id);
				TreeEditorHelper.GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
			}
		}
Beispiel #17
0
		private Bounds CalcBounds(TreeData treeData, Matrix4x4 objMatrix, TreeNode node)
		{
			Matrix4x4 matrix4x = objMatrix * node.matrix;
			Bounds result;
			if (treeData.GetGroup(node.groupID).GetType() == typeof(TreeGroupBranch) && node.spline != null && node.spline.nodes.Length > 0)
			{
				result = new Bounds(matrix4x.MultiplyPoint(node.spline.nodes[0].point), Vector3.zero);
				for (int i = 1; i < node.spline.nodes.Length; i++)
				{
					result.Encapsulate(matrix4x.MultiplyPoint(node.spline.nodes[i].point));
				}
			}
			else
			{
				result = new Bounds(matrix4x.MultiplyPoint(Vector3.zero), Vector3.zero);
			}
			return result;
		}
Beispiel #18
0
 public void InspectorAnimation(TreeData treeData, TreeGroup group)
 {
     if (group != null)
     {
         this.PrepareSpacing(false);
         group.animationPrimary = this.GUISlider(PropertyType.Normal, group.MainWindString, group.animationPrimary, 0f, 1f, false);
         if (treeData.GetGroup(group.parentGroupID) != treeData.root)
         {
             group.animationSecondary = this.GUISlider(PropertyType.Normal, group.MainTurbulenceString, group.animationSecondary, 0f, 1f, false);
         }
         GUI.enabled = true;
         if (!(group is TreeGroupBranch) || ((group as TreeGroupBranch).geometryMode != TreeGroupBranch.GeometryMode.Branch))
         {
             group.animationEdge = this.GUISlider(PropertyType.Normal, group.EdgeTurbulenceString, group.animationEdge, 0f, 1f, false);
         }
         this.GUIPropBegin();
         if (GUILayout.Button(TreeEditorHelper.GetGUIContent("Create Wind Zone|Creates a default wind zone, which is required for animating trees while playing the game."), new GUILayoutOption[0]))
         {
             CreateDefaultWindZone();
         }
         this.GUIPropEnd();
     }
 }
Beispiel #19
0
 private float FindClosestOffset(TreeData data, Matrix4x4 objMatrix, TreeNode node, Ray mouseRay, ref float rotation)
 {
     TreeGroup group = data.GetGroup(node.groupID);
     if (group == null)
     {
         return 0f;
     }
     if (group.GetType() != typeof(TreeGroupBranch))
     {
         return 0f;
     }
     data.ValidateReferences();
     Matrix4x4 matrixx = objMatrix * node.matrix;
     float num2 = 1f / (node.spline.GetNodeCount() * 10f);
     float time = 0f;
     float num4 = 1E+07f;
     Vector3 zero = Vector3.zero;
     Vector3 closestRay = Vector3.zero;
     Vector3 vector3 = matrixx.MultiplyPoint(node.spline.GetPositionAtTime(0f));
     for (float i = num2; i <= 1f; i += num2)
     {
         Vector3 vector4 = matrixx.MultiplyPoint(node.spline.GetPositionAtTime(i));
         float squaredDist = 0f;
         float s = 0f;
         zero = MathUtils.ClosestPtSegmentRay(vector3, vector4, mouseRay, out squaredDist, out s, out closestRay);
         if (squaredDist < num4)
         {
             time = (i - num2) + (num2 * s);
             num4 = squaredDist;
             float radiusAtTime = node.GetRadiusAtTime(time);
             float t = 0f;
             if (MathUtils.ClosestPtRaySphere(mouseRay, zero, radiusAtTime, ref t, ref closestRay))
             {
                 Matrix4x4 matrixx3 = matrixx * node.GetLocalMatrixAtTime(time);
                 Matrix4x4 inverse = matrixx3.inverse;
                 Vector3 v = closestRay - zero;
                 v = inverse.MultiplyVector(v);
                 rotation = Mathf.Atan2(v.x, v.z) * 57.29578f;
             }
         }
         vector3 = vector4;
     }
     data.ClearReferences();
     return time;
 }
Beispiel #20
0
 public void InspectorBranch(TreeData treeData, TreeGroupBranch group)
 {
     this.InspectorEditTools(base.target as Tree);
     GUIContent[] names = new GUIContent[] { TreeEditorHelper.GetGUIContent("Distribution|Adjusts the count and placement of branches in the group. Use the curves to fine tune position, rotation and scale. The curves are relative to the parent branch or to the area spread in case of a trunk."), TreeEditorHelper.GetGUIContent("Geometry|Select what type of geometry is generated for this branch group and which materials are applied. LOD Multiplier allows you to adjust the quality of this group relative to tree's LOD Quality."), TreeEditorHelper.GetGUIContent("Shape|Adjusts the shape and growth of the branches. Use the curves to fine tune the shape, all curves are relative to the branch itself."), TreeEditorHelper.GetGUIContent("Fronds|"), TreeEditorHelper.GetGUIContent("Wind|Adjusts the parameters used for animating this group of branches. The wind zones are only active in Play Mode.") };
     bool enabled = GUI.enabled;
     if (s_SelectedGroup.lockFlags != 0)
     {
         this.GUIunlockbox(treeData);
     }
     BeginSettingsSection(0, names);
     this.InspectorDistribution(treeData, group);
     EndSettingsSection();
     BeginSettingsSection(1, names);
     this.PrepareSpacing(false);
     group.lodQualityMultiplier = this.GUISlider(PropertyType.Normal, lodMultiplierString, group.lodQualityMultiplier, 0f, 2f, false);
     group.geometryMode = (TreeGroupBranch.GeometryMode) this.GUIPopup(PropertyType.FullUpdate, geometryModeString, categoryNamesOptions, (int) group.geometryMode, false);
     if (group.geometryMode != TreeGroupBranch.GeometryMode.Frond)
     {
         group.materialBranch = this.GUIMaterialField(PropertyType.FullUpdate, group.uniqueID, branchMaterialString, group.materialBranch, TreeEditorHelper.NodeType.BarkNode);
     }
     group.materialBreak = this.GUIMaterialField(PropertyType.FullUpdate, group.uniqueID, breakMaterialString, group.materialBreak, TreeEditorHelper.NodeType.BarkNode);
     if (group.geometryMode != TreeGroupBranch.GeometryMode.Branch)
     {
         group.materialFrond = this.GUIMaterialField(PropertyType.FullUpdate, group.uniqueID, frondMaterialString, group.materialFrond, TreeEditorHelper.NodeType.BarkNode);
     }
     EndSettingsSection();
     BeginSettingsSection(2, names);
     this.PrepareSpacing(true);
     GUI.enabled = group.lockFlags == 0;
     group.height = this.GUIMinMaxSlider(PropertyType.Normal, lengthString, group.height, 0.1f, 50f, false);
     GUI.enabled = group.geometryMode != TreeGroupBranch.GeometryMode.Frond;
     group.radiusMode = this.GUIToggle(PropertyType.Normal, relativeLengthString, group.radiusMode, false);
     GUI.enabled = group.geometryMode != TreeGroupBranch.GeometryMode.Frond;
     group.radius = this.GUISlider(PropertyType.Normal, radiusString, group.radius, 0.1f, 5f, true);
     AnimationCurve radiusCurve = group.radiusCurve;
     if (this.GUICurve(PropertyType.Normal, radiusCurve, this.m_CurveRangesA))
     {
         group.radiusCurve = radiusCurve;
     }
     GUI.enabled = group.geometryMode != TreeGroupBranch.GeometryMode.Frond;
     group.capSmoothing = this.GUISlider(PropertyType.Normal, capSmoothingString, group.capSmoothing, 0f, 1f, false);
     GUI.enabled = true;
     EditorGUILayout.Space();
     GUI.enabled = group.lockFlags == 0;
     group.crinklyness = this.GUISlider(PropertyType.Normal, crinklynessString, group.crinklyness, 0f, 1f, true);
     radiusCurve = group.crinkCurve;
     if (this.GUICurve(PropertyType.Normal, radiusCurve, this.m_CurveRangesA))
     {
         group.crinkCurve = radiusCurve;
     }
     GUI.enabled = group.lockFlags == 0;
     group.seekBlend = this.GUISlider(PropertyType.Normal, seekSunString, group.seekBlend, 0f, 1f, true);
     radiusCurve = group.seekCurve;
     if (this.GUICurve(PropertyType.Normal, radiusCurve, this.m_CurveRangesB))
     {
         group.seekCurve = radiusCurve;
     }
     GUI.enabled = true;
     EditorGUILayout.Space();
     GUI.enabled = group.geometryMode != TreeGroupBranch.GeometryMode.Frond;
     group.noise = this.GUISlider(PropertyType.Normal, noiseString, group.noise, 0f, 1f, true);
     radiusCurve = group.noiseCurve;
     if (this.GUICurve(PropertyType.Normal, radiusCurve, this.m_CurveRangesA))
     {
         group.noiseCurve = radiusCurve;
     }
     group.noiseScaleU = this.GUISlider(PropertyType.Normal, noiseScaleUString, group.noiseScaleU, 0f, 1f, false);
     group.noiseScaleV = this.GUISlider(PropertyType.Normal, noiseScaleVString, group.noiseScaleV, 0f, 1f, false);
     EditorGUILayout.Space();
     GUI.enabled = group.geometryMode != TreeGroupBranch.GeometryMode.Frond;
     if (treeData.GetGroup(group.parentGroupID) == treeData.root)
     {
         group.flareSize = this.GUISlider(PropertyType.Normal, flareRadiusString, group.flareSize, 0f, 5f, false);
         group.flareHeight = this.GUISlider(PropertyType.Normal, flareHeightString, group.flareHeight, 0f, 1f, false);
         group.flareNoise = this.GUISlider(PropertyType.Normal, flareNoiseString, group.flareNoise, 0f, 1f, false);
     }
     else
     {
         group.weldHeight = this.GUISlider(PropertyType.Normal, weldLengthString, group.weldHeight, 0.01f, 1f, false);
         group.weldSpreadTop = this.GUISlider(PropertyType.Normal, spreadTopString, group.weldSpreadTop, 0f, 1f, false);
         group.weldSpreadBottom = this.GUISlider(PropertyType.Normal, spreadBottomString, group.weldSpreadBottom, 0f, 1f, false);
     }
     EditorGUILayout.Space();
     group.breakingChance = this.GUISlider(PropertyType.Normal, breakChanceString, group.breakingChance, 0f, 1f, false);
     group.breakingSpot = this.GUIMinMaxSlider(PropertyType.Normal, breakLocationString, group.breakingSpot, 0f, 1f, false);
     EndSettingsSection();
     if (group.geometryMode != TreeGroupBranch.GeometryMode.Branch)
     {
         BeginSettingsSection(3, names);
         this.PrepareSpacing(true);
         group.frondCount = this.GUIIntSlider(PropertyType.Normal, frondCountString, group.frondCount, 1, 0x10, false);
         group.frondWidth = this.GUISlider(PropertyType.Normal, frondWidthString, group.frondWidth, 0.1f, 10f, true);
         radiusCurve = group.frondCurve;
         if (this.GUICurve(PropertyType.Normal, radiusCurve, this.m_CurveRangesA))
         {
             group.frondCurve = radiusCurve;
         }
         group.frondRange = this.GUIMinMaxSlider(PropertyType.Normal, frondRangeString, group.frondRange, 0f, 1f, false);
         group.frondRotation = this.GUISlider(PropertyType.Normal, frondRotationString, group.frondRotation, 0f, 1f, false);
         group.frondCrease = this.GUISlider(PropertyType.Normal, frondCreaseString, group.frondCrease, -1f, 1f, false);
         GUI.enabled = true;
         EndSettingsSection();
     }
     BeginSettingsSection(4, names);
     this.InspectorAnimation(treeData, group);
     EndSettingsSection();
     GUI.enabled = enabled;
     EditorGUILayout.Space();
 }
Beispiel #21
0
		private float FindClosestOffset(TreeData data, Matrix4x4 objMatrix, TreeNode node, Ray mouseRay, ref float rotation)
		{
			TreeGroup group = data.GetGroup(node.groupID);
			if (group == null)
			{
				return 0f;
			}
			if (group.GetType() != typeof(TreeGroupBranch))
			{
				return 0f;
			}
			data.ValidateReferences();
			Matrix4x4 lhs = objMatrix * node.matrix;
			float num = 1f / ((float)node.spline.GetNodeCount() * 10f);
			float num2 = 0f;
			float num3 = 1E+07f;
			Vector3 vector = Vector3.zero;
			Vector3 zero = Vector3.zero;
			Vector3 p = lhs.MultiplyPoint(node.spline.GetPositionAtTime(0f));
			for (float num4 = num; num4 <= 1f; num4 += num)
			{
				Vector3 vector2 = lhs.MultiplyPoint(node.spline.GetPositionAtTime(num4));
				float num5 = 0f;
				float num6 = 0f;
				vector = MathUtils.ClosestPtSegmentRay(p, vector2, mouseRay, out num5, out num6, out zero);
				if (num5 < num3)
				{
					num2 = num4 - num + num * num6;
					num3 = num5;
					float radiusAtTime = node.GetRadiusAtTime(num2);
					float num7 = 0f;
					if (MathUtils.ClosestPtRaySphere(mouseRay, vector, radiusAtTime, ref num7, ref zero))
					{
						Matrix4x4 inverse = (lhs * node.GetLocalMatrixAtTime(num2)).inverse;
						Vector3 v = zero - vector;
						v = inverse.MultiplyVector(v);
						rotation = Mathf.Atan2(v.x, v.z) * 57.29578f;
					}
				}
				p = vector2;
			}
			data.ClearReferences();
			return num2;
		}
Beispiel #22
0
 private Bounds CalcBounds(TreeData treeData, Matrix4x4 objMatrix, TreeNode node)
 {
     Matrix4x4 matrixx = objMatrix * node.matrix;
     if (((treeData.GetGroup(node.groupID).GetType() == typeof(TreeGroupBranch)) && (node.spline != null)) && (node.spline.nodes.Length > 0))
     {
         Bounds bounds = new Bounds(matrixx.MultiplyPoint(node.spline.nodes[0].point), Vector3.zero);
         for (int i = 1; i < node.spline.nodes.Length; i++)
         {
             bounds.Encapsulate(matrixx.MultiplyPoint(node.spline.nodes[i].point));
         }
         return bounds;
     }
     return new Bounds(matrixx.MultiplyPoint(Vector3.zero), Vector3.zero);
 }
 private static void GetAllTreeShaders(TreeData treeData, List<string> barkShaders, List<string> leafShaders, TreeGroup group)
 {
     if (group is TreeGroupBranch)
     {
         TreeGroupBranch branch = group as TreeGroupBranch;
         AddShaderFromMaterial(branch.materialBranch, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialBreak, barkShaders, leafShaders);
         AddShaderFromMaterial(branch.materialFrond, barkShaders, leafShaders);
     }
     else if (group is TreeGroupLeaf)
     {
         TreeGroupLeaf leaf = group as TreeGroupLeaf;
         AddShaderFromMaterial(leaf.materialLeaf, barkShaders, leafShaders);
     }
     foreach (int num in group.childGroupIDs)
     {
         TreeGroup group2 = treeData.GetGroup(num);
         GetAllTreeShaders(treeData, barkShaders, leafShaders, group2);
     }
 }
Beispiel #24
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;
            }
        }
Beispiel #25
0
 private void SelectNode(TreeNode node, TreeData treeData)
 {
     this.SelectGroup((node != null) ? treeData.GetGroup(node.groupID) : treeData.root);
     s_SelectedNode = node;
     s_SelectedPoint = -1;
 }
Beispiel #26
0
 private void HandleDragHierachyNodes(TreeData treeData, List<HierachyNode> nodes)
 {
     if (this.dragNode == null)
     {
         this.isDragging = false;
         this.dropNode = null;
     }
     int controlID = GUIUtility.GetControlID(FocusType.Passive);
     EventType typeForControl = Event.current.GetTypeForControl(controlID);
     if ((typeForControl == EventType.MouseDown) && (Event.current.button == 0))
     {
         for (int i = 0; i < nodes.Count; i++)
         {
             if ((nodes[i].rect.Contains(Event.current.mousePosition) && !this.GetHierachyNodeVisRect(nodes[i].rect).Contains(Event.current.mousePosition)) && !(nodes[i].group is TreeGroupRoot))
             {
                 this.dragClickPos = Event.current.mousePosition;
                 this.dragNode = nodes[i];
                 GUIUtility.hotControl = controlID;
                 Event.current.Use();
                 break;
             }
         }
     }
     if (this.dragNode != null)
     {
         this.dropNode = null;
         for (int j = 0; j < nodes.Count; j++)
         {
             if (nodes[j].rect.Contains(Event.current.mousePosition))
             {
                 TreeGroup ancestor = this.dragNode.group;
                 TreeGroup group = nodes[j].group;
                 if (((group != ancestor) && group.CanHaveSubGroups()) && ((treeData.GetGroup(ancestor.parentGroupID) != group) && !treeData.IsAncestor(ancestor, group)))
                 {
                     this.dropNode = nodes[j];
                     break;
                 }
             }
         }
         switch (typeForControl)
         {
             case EventType.MouseMove:
             case EventType.MouseDrag:
             {
                 Vector2 vector = this.dragClickPos - Event.current.mousePosition;
                 if (vector.magnitude > 10f)
                 {
                     this.isDragging = true;
                 }
                 Event.current.Use();
                 break;
             }
             default:
                 if ((typeForControl == EventType.MouseUp) && (GUIUtility.hotControl == controlID))
                 {
                     if (this.dropNode != null)
                     {
                         this.UndoStoreSelected(EditMode.Everything);
                         TreeGroup g = this.dragNode.group;
                         TreeGroup parent = this.dropNode.group;
                         treeData.SetGroupParent(g, parent);
                         this.m_WantCompleteUpdate = true;
                     }
                     else
                     {
                         base.Repaint();
                     }
                     this.dragNode = null;
                     this.dropNode = null;
                     GUIUtility.hotControl = 0;
                     Event.current.Use();
                 }
                 break;
         }
     }
 }
Beispiel #27
0
		public void InspectorAnimation(TreeData treeData, TreeGroup group)
		{
			if (group == null)
			{
				return;
			}
			this.PrepareSpacing(false);
			string str = "TreeEditor." + group.GetType().Name + ".";
			group.animationPrimary = this.GUISlider(TreeEditor.PropertyType.Normal, str + "MainWind", group.animationPrimary, 0f, 1f, false);
			if (treeData.GetGroup(group.parentGroupID) != treeData.root)
			{
				group.animationSecondary = this.GUISlider(TreeEditor.PropertyType.Normal, str + "MainTurbulence", group.animationSecondary, 0f, 1f, false);
			}
			GUI.enabled = true;
			if (!(group is TreeGroupBranch) || (group as TreeGroupBranch).geometryMode != TreeGroupBranch.GeometryMode.Branch)
			{
				group.animationEdge = this.GUISlider(TreeEditor.PropertyType.Normal, str + "EdgeTurbulence", group.animationEdge, 0f, 1f, false);
			}
			this.GUIPropBegin();
			if (GUILayout.Button(TreeEditorHelper.GetGUIContent("TreeEditor.WindZone.Create"), new GUILayoutOption[0]))
			{
				TreeEditor.CreateDefaultWindZone();
			}
			this.GUIPropEnd();
		}