public void LoadDataInScene() { targetGameObject = new GameObject(currentData.name); currentEditor = targetGameObject.AddComponent <RoMapEditor>(); currentEditor.Initialize(currentData); currentEditor.EnterEditMode(); Selection.activeGameObject = targetGameObject; }
public void OnGUI() { if (!isInitialized || mapBrushList == null) { Initialize(); } var bigStyle = new GUIStyle(GUI.skin.label) { fontSize = 20, clipping = TextClipping.Overflow }; GUILayout.Space(10); EditorGUILayout.LabelField("Map Editor", bigStyle); GUILayout.Space(10); EditorGuiLayoutUtility.HorizontalLine(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Mesh")) { EditMode = MapEditMode.Mesh; } if (GUILayout.Button("Texture")) { EditMode = MapEditMode.Texture; } if (GUILayout.Button("Settings")) { EditMode = MapEditMode.Settings; } EditorGUILayout.EndHorizontal(); var hasMap = HasSelectedMap(); if (hasMap) { if (currentEditor.gameObject.isStatic && !currentData.IsWalkTable) { if (GUILayout.Button("Enter Edit Mode")) { currentEditor.RemoveStatic(); } LeaveEditorMode(); return; } if (currentEditor.CurrentMode == Scripts.MapEditor.EditMode.Startup) { currentEditor.CurrentMode = Scripts.MapEditor.EditMode.Height; } EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Copy")) { if (currentEditor.HasSelection) { currentData.Copy(currentEditor.SelectedRegion); } } if (GUILayout.Button("Paste")) { if (currentEditor.HasSelection && currentEditor.SelectedRegion.size == Vector2Int.one) { if (currentData.Paste(currentEditor.SelectedRegion.min, out var area)) { currentEditor.RebuildMeshInArea(area); } } } if (GUILayout.Button("Undo")) { if (currentData.UndoChange(out var changed)) { currentEditor.RebuildMeshInArea(changed.ExpandRect(1)); currentBrush.Repaint(); } } EditorGUILayout.EndHorizontal(); if (!currentData.IsWalkTable) { if (GUILayout.Button("Leave Edit Mode")) { currentEditor.MakeStatic(); currentEditor.LeaveEditMode(); return; } } } EditorGuiLayoutUtility.HorizontalLine(); scrollPosition = GUILayout.BeginScrollView(scrollPosition, false, false); if (!hasMap) { if (currentBrush != null && currentBrush.IsEnabled()) { currentBrush.OnDisable(); } if (EditMode == MapEditMode.Texture && currentData != null && currentEditor != null) { EditModeTexture(); } else { UnselectedGUI(); } GUILayout.EndScrollView(); return; } currentEditor.EnterEditMode(); EnsureBrushEnabled(); switch (EditMode) { case MapEditMode.Mesh: EditModeMesh(); break; case MapEditMode.Texture: EditModeTexture(); break; case MapEditMode.Settings: EditModeSettings(); break; } GUILayout.EndScrollView(); }