private void CheckKeys()
 {
   for (int index = 0; index < TerrainInspector.s_ToolKeys.Length; ++index)
   {
     if (TerrainInspector.s_ToolKeys[index].activated)
     {
       this.selectedTool = (TerrainTool) index;
       this.Repaint();
       Event.current.Use();
     }
   }
   if (TerrainInspector.s_PrevBrush.activated)
   {
     --this.m_SelectedBrush;
     if (this.m_SelectedBrush < 0)
       this.m_SelectedBrush = TerrainInspector.s_BrushTextures.Length - 1;
     this.Repaint();
     Event.current.Use();
   }
   if (TerrainInspector.s_NextBrush.activated)
   {
     ++this.m_SelectedBrush;
     if (this.m_SelectedBrush >= TerrainInspector.s_BrushTextures.Length)
       this.m_SelectedBrush = 0;
     this.Repaint();
     Event.current.Use();
   }
   int num = 0;
   if (TerrainInspector.s_NextTexture.activated)
     num = 1;
   if (TerrainInspector.s_PrevTexture.activated)
     num = -1;
   if (num == 0)
     return;
   switch (this.selectedTool)
   {
     case TerrainTool.PaintTexture:
       this.m_SelectedSplat = (int) Mathf.Repeat((float) (this.m_SelectedSplat + num), (float) this.m_Terrain.terrainData.splatPrototypes.Length);
       Event.current.Use();
       this.Repaint();
       break;
     case TerrainTool.PlaceTree:
       if (TreePainter.selectedTree >= 0)
         TreePainter.selectedTree = (int) Mathf.Repeat((float) (TreePainter.selectedTree + num), (float) this.m_TreeContents.Length);
       else if (num == -1 && this.m_TreeContents.Length > 0)
         TreePainter.selectedTree = this.m_TreeContents.Length - 1;
       else if (num == 1 && this.m_TreeContents.Length > 0)
         TreePainter.selectedTree = 0;
       Event.current.Use();
       this.Repaint();
       break;
     case TerrainTool.PaintDetail:
       this.m_SelectedDetail = (int) Mathf.Repeat((float) (this.m_SelectedDetail + num), (float) this.m_Terrain.terrainData.detailPrototypes.Length);
       Event.current.Use();
       this.Repaint();
       break;
   }
 }
 public static void Undo(TerrainTool tool)
 {
     m_undoRequest = true;
 }
 public override void OnInspectorGUI()
 {
   this.Initialize();
   if (TerrainInspector.styles == null)
     TerrainInspector.styles = new TerrainInspector.Styles();
   if (!(bool) ((UnityEngine.Object) this.m_Terrain.terrainData))
   {
     GUI.enabled = false;
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     GUILayout.Toolbar(-1, TerrainInspector.styles.toolIcons, TerrainInspector.styles.command, new GUILayoutOption[0]);
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     GUI.enabled = true;
     GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
     GUILayout.Label("Terrain Asset Missing");
     this.m_Terrain.terrainData = EditorGUILayout.ObjectField("Assign:", (UnityEngine.Object) this.m_Terrain.terrainData, typeof (TerrainData), false, new GUILayoutOption[0]) as TerrainData;
     GUILayout.EndVertical();
   }
   else
   {
     GUILayout.BeginHorizontal();
     GUILayout.FlexibleSpace();
     GUI.changed = false;
     int selectedTool = (int) this.selectedTool;
     this.selectedTool = (TerrainTool) GUILayout.Toolbar(selectedTool, TerrainInspector.styles.toolIcons, TerrainInspector.styles.command, new GUILayoutOption[0]);
     if (this.selectedTool != (TerrainTool) selectedTool && (UnityEngine.Object) Toolbar.get != (UnityEngine.Object) null)
       Toolbar.get.Repaint();
     GUILayout.FlexibleSpace();
     GUILayout.EndHorizontal();
     this.CheckKeys();
     GUILayout.BeginVertical(EditorStyles.helpBox, new GUILayoutOption[0]);
     if (selectedTool >= 0 && selectedTool < TerrainInspector.styles.toolIcons.Length)
     {
       GUILayout.Label(TerrainInspector.styles.toolNames[selectedTool].text);
       GUILayout.Label(TerrainInspector.styles.toolNames[selectedTool].tooltip, EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
     }
     else
     {
       GUILayout.Label("No tool selected");
       GUILayout.Label("Please select a tool", EditorStyles.wordWrappedMiniLabel, new GUILayoutOption[0]);
     }
     GUILayout.EndVertical();
     switch (selectedTool)
     {
       case 0:
         this.ShowRaiseHeight();
         break;
       case 1:
         this.ShowSetHeight();
         break;
       case 2:
         this.ShowSmoothHeight();
         break;
       case 3:
         this.ShowTextures();
         break;
       case 4:
         this.ShowTrees();
         break;
       case 5:
         this.ShowDetails();
         break;
       case 6:
         this.ShowSettings();
         break;
     }
     GUILayout.Space(5f);
   }
 }
Пример #4
0
		private void CheckKeys()
		{
			if (GUIUtility.textFieldInput)
			{
				return;
			}
			for (int i = 0; i < TerrainInspector.s_ToolKeys.Length; i++)
			{
				if (TerrainInspector.s_ToolKeys[i].activated)
				{
					this.selectedTool = (TerrainTool)i;
					base.Repaint();
					Event.current.Use();
				}
			}
			if (TerrainInspector.s_PrevBrush.activated)
			{
				this.m_SelectedBrush--;
				if (this.m_SelectedBrush < 0)
				{
					this.m_SelectedBrush = TerrainInspector.s_BrushTextures.Length - 1;
				}
				base.Repaint();
				Event.current.Use();
			}
			if (TerrainInspector.s_NextBrush.activated)
			{
				this.m_SelectedBrush++;
				if (this.m_SelectedBrush >= TerrainInspector.s_BrushTextures.Length)
				{
					this.m_SelectedBrush = 0;
				}
				base.Repaint();
				Event.current.Use();
			}
			int num = 0;
			if (TerrainInspector.s_NextTexture.activated)
			{
				num = 1;
			}
			if (TerrainInspector.s_PrevTexture.activated)
			{
				num = -1;
			}
			if (num != 0)
			{
				switch (this.selectedTool)
				{
				case TerrainTool.PaintTexture:
					this.m_SelectedSplat = (int)Mathf.Repeat((float)(this.m_SelectedSplat + num), (float)this.m_Terrain.terrainData.splatPrototypes.Length);
					Event.current.Use();
					base.Repaint();
					break;
				case TerrainTool.PlaceTree:
					TreePainter.selectedTree = (int)Mathf.Repeat((float)(TreePainter.selectedTree + num), (float)this.m_TreeContents.Length);
					Event.current.Use();
					base.Repaint();
					break;
				case TerrainTool.PaintDetail:
					this.m_SelectedDetail = (int)Mathf.Repeat((float)(this.m_SelectedDetail + num), (float)this.m_Terrain.terrainData.detailPrototypes.Length);
					Event.current.Use();
					base.Repaint();
					break;
				}
			}
		}