//NOTE: m_tilemapEditor.target changes when OnSceneGUI is called, so this method makes sure to create it again if target doesn't match private TilemapEditor GetTilemapEditor() { var targetObj = target as TilemapGroup; if (!m_tilemapEditor || !m_tilemapEditor.target || m_tilemapEditor.target != targetObj.SelectedTilemap) { if (targetObj.SelectedTilemap) { if (m_tilemapEditor) { TilemapEditor.DestroyImmediate(m_tilemapEditor); } m_tilemapEditor = TilemapEditor.CreateEditor(targetObj.SelectedTilemap) as TilemapEditor; } else { if (m_tilemapEditor) { TilemapEditor.DestroyImmediate(m_tilemapEditor); } m_tilemapEditor = null; } } return(m_tilemapEditor); }
private void OnDisable() { if (m_tilemapEditor) { TilemapEditor.DestroyImmediate(m_tilemapEditor); } }
public void OnSceneGUI() { serializedObject.Update(); Handles.BeginGUI(); // clamp index to valid value m_selectedIndexProp.intValue = Mathf.Clamp(m_selectedIndexProp.intValue, -1, m_target.Tilemaps.Count - 1); m_sceneViewTilemapRList.index = m_selectedIndexProp.intValue; GUI.color = new Color(.75f, .75f, 0.8f, 0.85f); float hOff = m_displayTilemapRList.boolValue? 40f : 20f; m_sceneViewTilemapRList.DoList(new Rect(Screen.width - 300f - 10f, Screen.height - m_sceneViewTilemapRList.GetHeight() - hOff, 300f, 1f)); GUI.color = Color.white; Handles.EndGUI(); TilemapEditor tilemapEditor = GetTilemapEditor(); if (tilemapEditor) { (tilemapEditor as TilemapEditor).OnSceneGUI(); } DoKeyboardChecks(); serializedObject.ApplyModifiedProperties(); }
public override void OnInspectorGUI() { var targetObj = target as TilemapGroup; // NOTE: this happens during undo/redo if (targetObj.transform.childCount != targetObj.Tilemaps.Count) { targetObj.Refresh(); } serializedObject.Update(); // clamp index to valid value serializedObject.FindProperty("m_selectedIndex").intValue = m_tilemapReordList.index = Mathf.Clamp(m_tilemapReordList.index, -1, targetObj.Tilemaps.Count - 1); // Draw Tilemap List m_tilemapReordList.DoLayoutList(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_unselectedColorMultiplier")); EditorGUILayout.Space(); // Draw Tilemap Inspector TilemapEditor tilemapEditor = GetTilemapEditor(); if (tilemapEditor) { tilemapEditor.OnInspectorGUI(); } serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(target); Repaint(); } }
public void OnSceneGUI() { TilemapEditor tilemapEditor = GetTilemapEditor(); if (tilemapEditor) { (tilemapEditor as TilemapEditor).OnSceneGUI(); } }
public override void OnInspectorGUI() { // NOTE: this happens during undo/redo if (m_target.transform.childCount != m_target.Tilemaps.Count) { m_target.Refresh(); } serializedObject.Update(); if (m_tilemapReordList.HasKeyboardControl()) { DoKeyboardChecks(); } // clamp index to valid value m_selectedIndexProp.intValue = Mathf.Clamp(m_selectedIndexProp.intValue, -1, m_target.Tilemaps.Count - 1); // Draw Tilemap List m_tilemapReordList.index = m_selectedIndexProp.intValue; m_tilemapReordList.DoLayoutList(); EditorGUILayout.PropertyField(serializedObject.FindProperty("m_unselectedColorMultiplier"), new GUIContent("Highlight Alpha")); EditorGUIUtility.labelWidth = 200f; EditorGUILayout.PropertyField(m_defaultTilemapWindowVisibleProperty, new GUIContent("Display Default Tilemap Window")); EditorGUIUtility.labelWidth = 0f; EditorGUILayout.Space(); // Draw Tilemap Inspector TilemapEditor tilemapEditor = GetTilemapEditor(); if (tilemapEditor) { tilemapEditor.OnInspectorGUI(); } m_displayTilemapRList.boolValue = m_sceneViewTilemapRList.elementHeight > 0f; serializedObject.ApplyModifiedProperties(); //fix: argument exception when removing the last tilemap in the list if (Event.current.type == EventType.Layout) { for (int i = 0; i < m_tilemapRemovingList.Count; ++i) { Undo.DestroyObjectImmediate(m_tilemapRemovingList[i]); } m_tilemapRemovingList.Clear(); } if (GUI.changed) { EditorUtility.SetDirty(target); Repaint(); } }
public void OnSceneGUI() { serializedObject.Update(); Handles.BeginGUI(); // clamp index to valid value m_selectedIndexProp.intValue = Mathf.Clamp(m_selectedIndexProp.intValue, -1, m_target.Tilemaps.Count - 1); m_sceneViewTilemapRList.index = m_selectedIndexProp.intValue; GUI.color = new Color(.75f, .75f, 0.8f, 0.85f); float hOff = m_displayTilemapRList.boolValue? 40f : 20f; m_sceneViewTilemapRList.DoList(new Rect(Screen.width - 300f - 10f, Screen.height - m_sceneViewTilemapRList.GetHeight() - hOff, 300f, 1f)); GUI.color = Color.white; Handles.EndGUI(); TilemapEditor tilemapEditor = GetTilemapEditor(); if (tilemapEditor) { (tilemapEditor as TilemapEditor).OnSceneGUI(); } DoKeyboardChecks(); serializedObject.ApplyModifiedProperties(); if (m_defaultTilemapWindowVisibleProperty.boolValue) { Rect rDefaultTilemapWindow = new Rect(5f, Screen.height - m_defaultTilemapsWindowRect.height - 20f, m_defaultTilemapsWindowRect.width, m_defaultTilemapsWindowRect.height); if (m_defaultTilemapWindowMinimized) { rDefaultTilemapWindow.y = Screen.height - 55f; } GUI.Window(0, rDefaultTilemapWindow, DoWindow, "Tile/Brush Default Tilemap", STEditorStyles.Instance.boldWindow); } }