mirror of
https://github.com/AnnulusGames/Alchemy.git
synced 2025-01-22 08:18:51 -05:00
Add: hierarchy toggles
This commit is contained in:
parent
e6167d419d
commit
9d87b79807
@ -32,7 +32,9 @@ namespace Alchemy.Editor
|
||||
}
|
||||
|
||||
[SerializeField] HierarchyObjectMode hierarchyObjectMode = HierarchyObjectMode.RemoveInBuild;
|
||||
[SerializeField] bool showHierarchyToggles;
|
||||
|
||||
public HierarchyObjectMode HierarchyObjectMode => hierarchyObjectMode;
|
||||
public bool ShowHierarchyToggles => showHierarchyToggles;
|
||||
}
|
||||
}
|
@ -57,6 +57,12 @@ namespace Alchemy.Editor
|
||||
var hierarchyObjectModeField = new PropertyField(serializedObject.FindProperty("hierarchyObjectMode"));
|
||||
root.Add(hierarchyObjectModeField);
|
||||
|
||||
var showHierarchyTogglesField = new PropertyField(serializedObject.FindProperty("showHierarchyToggles"))
|
||||
{
|
||||
label = "Show Toggles"
|
||||
};
|
||||
root.Add(showHierarchyTogglesField);
|
||||
|
||||
root.Bind(serializedObject);
|
||||
root.TrackSerializedObjectValue(serializedObject, so =>
|
||||
{
|
||||
|
@ -0,0 +1,32 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Alchemy.Hierarchy;
|
||||
|
||||
namespace Alchemy.Editor
|
||||
{
|
||||
public sealed class HierarchyButtonDrawer : HierarchyDrawer
|
||||
{
|
||||
public override void OnGUI(int instanceID, Rect selectionRect)
|
||||
{
|
||||
var gameObject = EditorUtility.InstanceIDToObject(instanceID) as GameObject;
|
||||
if (gameObject == null) return;
|
||||
if (gameObject.TryGetComponent<HierarchyObject>(out _)) return;
|
||||
|
||||
if (AlchemySettings.GetOrCreateSettings().ShowHierarchyToggles)
|
||||
{
|
||||
var pos = selectionRect;
|
||||
pos.x = pos.xMax - 8f;
|
||||
pos.width = 16f;
|
||||
|
||||
var active = GUI.Toggle(pos, gameObject.activeSelf, string.Empty);
|
||||
if (active != gameObject.activeSelf)
|
||||
{
|
||||
Undo.RecordObject(gameObject, $"{(active ? "Activate" : "Deactivate")} GameObject '{gameObject.name}'");
|
||||
gameObject.SetActive(active);
|
||||
EditorUtility.SetDirty(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 527cfc72d81d34166ab175d08e86e0b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using Alchemy.Editor.Internal;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Alchemy.Editor.Internal;
|
||||
|
||||
namespace Alchemy.Editor
|
||||
{
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"hierarchyObjectMode": 2
|
||||
"hierarchyObjectMode": 2,
|
||||
"showHierarchyToggles": true
|
||||
}
|
Loading…
Reference in New Issue
Block a user