public override void OnInspectorGUI() { _navTileBanner.Draw(); serializedObject.Update(); // Multi editing not supported as it would not make sense, since every NavLink should be unique. using (new EditorGUI.DisabledGroupScope(targets.Length > 1)) { EditorGUI.BeginChangeCheck(); EditorGUILayout.PropertyField(_linkedTileProperty); if (EditorGUI.EndChangeCheck()) { // Record the NavLink dictionary for undo. Undo.RecordObject(NavTileManager.Instance, Undo.GetCurrentGroupName()); TileBase newTile = (TileBase)_linkedTileProperty.objectReferenceValue; // Callback for the tile change. if (_linkedTileProperty.objectReferenceValue != Tile.LinkedTile) { Tile.OnTileChanged(Tile.LinkedTile, newTile); } } } // Area index. EditorHelper.DrawCompressedPopup(_areaIndexProperty, NavTileManager.Instance.AreaManager.AllAreaNames); // Buttons. GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("View Links")) { NavTileWindow.OpenLinksTab(); } if (GUILayout.Button("Edit Areas")) { NavTileWindow.OpenAreasTab(); } GUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); }
/// <summary> /// Draws the custom inspector. /// </summary> public override void OnInspectorGUI() { _navTileBanner.Draw(); DoTilePreview(Tile.sprite, Tile.color, Matrix4x4.identity); serializedObject.Update(); EditorGUILayout.PropertyField(_spriteProperty); using (new EditorGUI.DisabledGroupScope(_spriteProperty.objectReferenceValue == null)) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Sprite Editor")) { Selection.activeObject = _spriteProperty.objectReferenceValue; EditorApplication.ExecuteMenuItem("Window/2D/Sprite Editor"); } GUILayout.EndHorizontal(); } EditorGUILayout.PropertyField(_colorProperty); EditorGUILayout.PropertyField(_colliderTypeProperty); EditorHelper.DrawCompressedPopup(_areaIndexProperty, NavTileManager.Instance.AreaManager.AllAreaNames); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Edit Areas")) { NavTileWindow.OpenAreasTab(); } GUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); }