private void OnEnable() { MapCreator obj = (MapCreator)target; if (obj.GetMap() == null) { obj.ClearLevel(); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.Space(); MapCreator obj = (MapCreator)target; m_MapName = EditorGUILayout.TextField("Map Name", m_MapName); if (obj.IsLevelLoaded()) { Color prev = GUI.color; if (!m_IsAddingCheckpoints && !m_IsRemovingCheckpoints) { ShowPaintCellButton(); } GUI.color = prev; if (!m_IsPaintCell && !m_IsRemovingCheckpoints) { ShowAddCheckPointsButton(); } GUI.color = prev; if (!m_IsPaintCell && !m_IsAddingCheckpoints) { ShowRemoveCheckPointsButton(); } GUI.color = prev; EditorGUILayout.Space(); if (m_IsEdited) { GUI.color = Color.green; } if (GUILayout.Button("Save Level")) { obj.SaveMap(m_MapName); m_IsEdited = false; } if (m_IsEdited) { GUI.color = prev; } EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Clear Level")) { obj.ClearLevel(); } } else { m_Width = EditorGUILayout.IntField("Map Width", m_Width); m_Height = EditorGUILayout.IntField("Map Height", m_Height); if (GUILayout.Button("Create Level")) { obj.CreateLevel(m_Width, m_Height); } else if (GUILayout.Button("Load Level")) { obj.LoadMap(m_MapName); } } }