public Paint ( float xCenterNormalized, float yCenterNormalized, int detailIndex ) : void | ||
xCenterNormalized | float | |
yCenterNormalized | float | |
detailIndex | int | |
리턴 | void |
public void OnSceneGUI() { this.Initialize(); if (!(bool) ((UnityEngine.Object) this.m_Terrain.terrainData)) return; Event current = Event.current; this.CheckKeys(); int controlId = GUIUtility.GetControlID(TerrainInspector.s_TerrainEditorHash, FocusType.Passive); switch (current.GetTypeForControl(controlId)) { case EventType.MouseDown: case EventType.MouseDrag: if (GUIUtility.hotControl != 0 && GUIUtility.hotControl != controlId || current.GetTypeForControl(controlId) == EventType.MouseDrag && GUIUtility.hotControl != controlId || (Event.current.alt || current.button != 0 || (!this.IsModificationToolActive() || HandleUtility.nearestControl != controlId))) break; if (current.type == EventType.MouseDown) GUIUtility.hotControl = controlId; Vector2 uv; Vector3 pos; if (!this.Raycast(out uv, out pos)) break; if (this.selectedTool == TerrainTool.SetHeight && Event.current.shift) { this.m_TargetHeight.value = this.m_Terrain.terrainData.GetInterpolatedHeight(uv.x, uv.y) / this.m_Terrain.terrainData.size.y; InspectorWindow.RepaintAllInspectors(); } else if (this.selectedTool == TerrainTool.PlaceTree) { if (current.type == EventType.MouseDown) Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this.m_Terrain.terrainData, "Place Tree"); if (!Event.current.shift && !Event.current.control) TreePainter.PlaceTrees(this.m_Terrain, uv.x, uv.y); else TreePainter.RemoveTrees(this.m_Terrain, uv.x, uv.y, Event.current.control); } else if (this.selectedTool == TerrainTool.PaintTexture) { if (current.type == EventType.MouseDown) { List<UnityEngine.Object> objectList = new List<UnityEngine.Object>(); objectList.Add((UnityEngine.Object) this.m_Terrain.terrainData); objectList.AddRange((IEnumerable<UnityEngine.Object>) this.m_Terrain.terrainData.alphamapTextures); Undo.RegisterCompleteObjectUndo(objectList.ToArray(), "Detail Edit"); } SplatPainter splatPainter = new SplatPainter(); splatPainter.size = (int) this.m_Size; splatPainter.strength = (float) this.m_Strength; splatPainter.terrainData = this.m_Terrain.terrainData; splatPainter.brush = this.GetActiveBrush(splatPainter.size); splatPainter.target = (float) this.m_SplatAlpha; splatPainter.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; splatPainter.Paint(uv.x, uv.y, this.m_SelectedSplat); this.m_Terrain.terrainData.SetBasemapDirty(false); } else if (this.selectedTool == TerrainTool.PaintDetail) { if (current.type == EventType.MouseDown) Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this.m_Terrain.terrainData, "Detail Edit"); DetailPainter detailPainter = new DetailPainter(); detailPainter.size = (int) this.m_Size; detailPainter.targetStrength = (float) this.m_DetailStrength * 16f; detailPainter.opacity = (float) this.m_DetailOpacity; if (Event.current.shift || Event.current.control) detailPainter.targetStrength *= -1f; detailPainter.clearSelectedOnly = Event.current.control; detailPainter.terrainData = this.m_Terrain.terrainData; detailPainter.brush = this.GetActiveBrush(detailPainter.size); detailPainter.tool = this.selectedTool; detailPainter.randomizeDetails = true; detailPainter.Paint(uv.x, uv.y, this.m_SelectedDetail); } else { if (current.type == EventType.MouseDown) Undo.RegisterCompleteObjectUndo((UnityEngine.Object) this.m_Terrain.terrainData, "Heightmap Edit"); HeightmapPainter heightmapPainter = new HeightmapPainter(); heightmapPainter.size = (int) this.m_Size; heightmapPainter.strength = (float) this.m_Strength * 0.01f; if (this.selectedTool == TerrainTool.SmoothHeight) heightmapPainter.strength = (float) this.m_Strength; heightmapPainter.terrainData = this.m_Terrain.terrainData; heightmapPainter.brush = this.GetActiveBrush((int) this.m_Size); heightmapPainter.targetHeight = (float) this.m_TargetHeight; heightmapPainter.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; if (this.selectedTool == TerrainTool.PaintHeight && Event.current.shift) heightmapPainter.strength = -heightmapPainter.strength; heightmapPainter.PaintHeight(uv.x, uv.y); } current.Use(); break; case EventType.MouseUp: if (GUIUtility.hotControl != controlId) break; GUIUtility.hotControl = 0; if (!this.IsModificationToolActive()) break; if (this.selectedTool == TerrainTool.PaintTexture) this.m_Terrain.terrainData.SetBasemapDirty(true); this.m_Terrain.editorRenderFlags = TerrainRenderFlags.all; this.m_Terrain.ApplyDelayedHeightmapModification(); current.Use(); break; case EventType.MouseMove: if (!this.IsBrushPreviewVisible()) break; HandleUtility.Repaint(); break; case EventType.Repaint: this.DisableProjector(); break; case EventType.Layout: if (!this.IsModificationToolActive()) break; HandleUtility.AddDefaultControl(controlId); break; } }
public void OnSceneGUI() { this.Initialize(); if (this.m_Terrain.terrainData != null) { Event current = Event.current; this.CheckKeys(); int controlID = GUIUtility.GetControlID(s_TerrainEditorHash, FocusType.Passive); switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: case EventType.MouseDrag: if ((GUIUtility.hotControl == 0) || (GUIUtility.hotControl == controlID)) { if (((((current.GetTypeForControl(controlID) != EventType.MouseDrag) || (GUIUtility.hotControl == controlID)) && !Event.current.alt) && ((current.button == 0) && this.IsModificationToolActive())) && (HandleUtility.nearestControl == controlID)) { Vector2 vector; Vector3 vector2; if (current.type == EventType.MouseDown) { GUIUtility.hotControl = controlID; } if (this.Raycast(out vector, out vector2)) { if ((this.selectedTool == TerrainTool.SetHeight) && Event.current.shift) { this.m_TargetHeight.value = this.m_Terrain.terrainData.GetInterpolatedHeight(vector.x, vector.y) / this.m_Terrain.terrainData.size.y; InspectorWindow.RepaintAllInspectors(); } else if (this.selectedTool == TerrainTool.PlaceTree) { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Place Tree"); } if (!Event.current.shift && !Event.current.control) { TreePainter.PlaceTrees(this.m_Terrain, vector.x, vector.y); } else { TreePainter.RemoveTrees(this.m_Terrain, vector.x, vector.y, Event.current.control); } } else if (this.selectedTool == TerrainTool.PaintTexture) { if (current.type == EventType.MouseDown) { List<Object> list = new List<Object> { this.m_Terrain.terrainData }; list.AddRange(this.m_Terrain.terrainData.alphamapTextures); Undo.RegisterCompleteObjectUndo(list.ToArray(), "Detail Edit"); } SplatPainter painter = new SplatPainter { size = (int) this.m_Size, strength = (float) this.m_Strength, terrainData = this.m_Terrain.terrainData }; painter.brush = this.GetActiveBrush(painter.size); painter.target = (float) this.m_SplatAlpha; painter.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; painter.Paint(vector.x, vector.y, this.m_SelectedSplat); this.m_Terrain.terrainData.SetBasemapDirty(false); } else if (this.selectedTool == TerrainTool.PaintDetail) { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Detail Edit"); } DetailPainter painter2 = new DetailPainter { size = (int) this.m_Size, targetStrength = this.m_DetailStrength * 16f, opacity = (float) this.m_DetailOpacity }; if (Event.current.shift || Event.current.control) { painter2.targetStrength *= -1f; } painter2.clearSelectedOnly = Event.current.control; painter2.terrainData = this.m_Terrain.terrainData; painter2.brush = this.GetActiveBrush(painter2.size); painter2.tool = this.selectedTool; painter2.randomizeDetails = true; painter2.Paint(vector.x, vector.y, this.m_SelectedDetail); } else { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Heightmap Edit"); } HeightmapPainter painter3 = new HeightmapPainter { size = (int) this.m_Size, strength = this.m_Strength * 0.01f }; if (this.selectedTool == TerrainTool.SmoothHeight) { painter3.strength = (float) this.m_Strength; } painter3.terrainData = this.m_Terrain.terrainData; painter3.brush = this.GetActiveBrush((int) this.m_Size); painter3.targetHeight = (float) this.m_TargetHeight; painter3.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; if ((this.selectedTool == TerrainTool.PaintHeight) && Event.current.shift) { painter3.strength = -painter3.strength; } painter3.PaintHeight(vector.x, vector.y); } current.Use(); } } break; } break; case EventType.MouseUp: if (GUIUtility.hotControl == controlID) { GUIUtility.hotControl = 0; if (this.IsModificationToolActive()) { if (this.selectedTool == TerrainTool.PaintTexture) { this.m_Terrain.terrainData.SetBasemapDirty(true); } this.m_Terrain.editorRenderFlags = TerrainRenderFlags.all; this.m_Terrain.ApplyDelayedHeightmapModification(); current.Use(); } break; } break; case EventType.MouseMove: if (this.IsBrushPreviewVisible()) { HandleUtility.Repaint(); } break; case EventType.Repaint: this.DisableProjector(); break; case EventType.Layout: if (this.IsModificationToolActive()) { HandleUtility.AddDefaultControl(controlID); break; } break; } } }
public void OnSceneGUI() { this.Initialize(); if (!this.m_Terrain.terrainData) { return; } Event current = Event.current; this.CheckKeys(); int controlID = GUIUtility.GetControlID(TerrainInspector.s_TerrainEditorHash, FocusType.Passive); switch (current.GetTypeForControl(controlID)) { case EventType.MouseDown: case EventType.MouseDrag: { if (current.GetTypeForControl(controlID) == EventType.MouseDrag && GUIUtility.hotControl != controlID) { return; } if (Event.current.alt) { return; } if (current.button != 0) { return; } if (!this.IsModificationToolActive()) { return; } if (HandleUtility.nearestControl != controlID) { return; } if (current.type == EventType.MouseDown) { GUIUtility.hotControl = controlID; } Vector2 vector; Vector3 vector2; if (this.Raycast(out vector, out vector2)) { if (this.selectedTool == TerrainTool.SetHeight && Event.current.shift) { this.m_TargetHeight.value = this.m_Terrain.terrainData.GetInterpolatedHeight(vector.x, vector.y) / this.m_Terrain.terrainData.size.y; InspectorWindow.RepaintAllInspectors(); } else { if (this.selectedTool == TerrainTool.PlaceTree) { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Place Tree"); } if (!Event.current.shift && !Event.current.control) { TreePainter.PlaceTrees(this.m_Terrain, vector.x, vector.y); } else { TreePainter.RemoveTrees(this.m_Terrain, vector.x, vector.y, Event.current.control); } } else { if (this.selectedTool == TerrainTool.PaintTexture) { if (current.type == EventType.MouseDown) { List<UnityEngine.Object> list = new List<UnityEngine.Object>(); list.Add(this.m_Terrain.terrainData); list.AddRange(this.m_Terrain.terrainData.alphamapTextures); Undo.RegisterCompleteObjectUndo(list.ToArray(), "Detail Edit"); } SplatPainter splatPainter = new SplatPainter(); splatPainter.size = this.m_Size; splatPainter.strength = this.m_Strength; splatPainter.terrainData = this.m_Terrain.terrainData; splatPainter.brush = this.GetActiveBrush(splatPainter.size); splatPainter.target = this.m_SplatAlpha; splatPainter.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; splatPainter.Paint(vector.x, vector.y, this.m_SelectedSplat); this.m_Terrain.terrainData.SetBasemapDirty(false); } else { if (this.selectedTool == TerrainTool.PaintDetail) { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Detail Edit"); } DetailPainter detailPainter = new DetailPainter(); detailPainter.size = this.m_Size; detailPainter.targetStrength = this.m_DetailStrength * 16f; detailPainter.opacity = this.m_DetailOpacity; if (Event.current.shift || Event.current.control) { detailPainter.targetStrength *= -1f; } detailPainter.clearSelectedOnly = Event.current.control; detailPainter.terrainData = this.m_Terrain.terrainData; detailPainter.brush = this.GetActiveBrush(detailPainter.size); detailPainter.tool = this.selectedTool; detailPainter.randomizeDetails = true; detailPainter.Paint(vector.x, vector.y, this.m_SelectedDetail); } else { if (current.type == EventType.MouseDown) { Undo.RegisterCompleteObjectUndo(this.m_Terrain.terrainData, "Heightmap Edit"); } HeightmapPainter heightmapPainter = new HeightmapPainter(); heightmapPainter.size = this.m_Size; heightmapPainter.strength = this.m_Strength * 0.01f; if (this.selectedTool == TerrainTool.SmoothHeight) { heightmapPainter.strength = this.m_Strength; } heightmapPainter.terrainData = this.m_Terrain.terrainData; heightmapPainter.brush = this.GetActiveBrush(this.m_Size); heightmapPainter.targetHeight = this.m_TargetHeight; heightmapPainter.tool = this.selectedTool; this.m_Terrain.editorRenderFlags = TerrainRenderFlags.heightmap; if (this.selectedTool == TerrainTool.PaintHeight && Event.current.shift) { heightmapPainter.strength = -heightmapPainter.strength; } heightmapPainter.PaintHeight(vector.x, vector.y); } } } } } current.Use(); break; } case EventType.MouseUp: if (GUIUtility.hotControl != controlID) { return; } GUIUtility.hotControl = 0; if (!this.IsModificationToolActive()) { return; } if (this.selectedTool == TerrainTool.PaintTexture) { this.m_Terrain.terrainData.SetBasemapDirty(true); } this.m_Terrain.editorRenderFlags = TerrainRenderFlags.all; this.m_Terrain.ApplyDelayedHeightmapModification(); current.Use(); break; case EventType.MouseMove: if (this.IsBrushPreviewVisible()) { HandleUtility.Repaint(); } break; case EventType.Repaint: this.DisableProjector(); break; case EventType.Layout: if (!this.IsModificationToolActive()) { return; } HandleUtility.AddDefaultControl(controlID); break; } }