com.amanotes.magictilescore 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +240 -0
- package/CHANGELOG.md.meta +7 -0
- package/Docs/Class-Hierarchy.md +729 -0
- package/Docs/Class-Hierarchy.md.meta +7 -0
- package/Docs/Component-Architecture.md +43 -0
- package/Docs/Component-Architecture.md.meta +7 -0
- package/Docs/File-Structure.md +327 -0
- package/Docs/File-Structure.md.meta +7 -0
- package/Docs/Game-Architecture.md +41 -0
- package/Docs/Game-Architecture.md.meta +7 -0
- package/Docs/Input-System-Guide.md +419 -0
- package/Docs/Input-System-Guide.md.meta +7 -0
- package/Docs/Knot-System-Guide.md +309 -0
- package/Docs/Knot-System-Guide.md.meta +7 -0
- package/Docs/Meta-System-Guide.md +249 -0
- package/Docs/Meta-System-Guide.md.meta +7 -0
- package/Docs/New-Game-Checklist.md +102 -0
- package/Docs/New-Game-Checklist.md.meta +7 -0
- package/Docs/README.md +37 -0
- package/Docs/README.md.meta +7 -0
- package/Docs/RhythmCore-Architecture.md +373 -0
- package/Docs/RhythmCore-Architecture.md.meta +7 -0
- package/Docs/RhythmCore-Customize-Guide.md +391 -0
- package/Docs/RhythmCore-Customize-Guide.md.meta +7 -0
- package/Docs/Understanding-Rhythm-Core.md +483 -0
- package/Docs/Understanding-Rhythm-Core.md.meta +7 -0
- package/Docs/VisualWarp-System-Guide.md +377 -0
- package/Docs/VisualWarp-System-Guide.md.meta +7 -0
- package/Docs/Widget2D-System-Guide.md +450 -0
- package/Docs/Widget2D-System-Guide.md.meta +7 -0
- package/Docs.meta +8 -0
- package/Editor/AdjustHueEditor.cs +90 -0
- package/Editor/AdjustHueEditor.cs.meta +11 -0
- package/Editor/ClassInstanceDrawer.cs +256 -0
- package/Editor/ClassInstanceDrawer.cs.meta +11 -0
- package/Editor/CollapsibleGroupEditor.cs +142 -0
- package/Editor/CollapsibleGroupEditor.cs.meta +11 -0
- package/Editor/ListSongNoteEditor.cs +317 -0
- package/Editor/ListSongNoteEditor.cs.meta +11 -0
- package/Editor/MagicTilesCore.Editor.asmdef +20 -0
- package/Editor/MagicTilesCore.Editor.asmdef.meta +7 -0
- package/Editor/MetaLogicDrawer.cs +488 -0
- package/Editor/MetaLogicDrawer.cs.meta +11 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs +46 -0
- package/Editor/RhythmContextEditor.EditorDrawer.cs.meta +3 -0
- package/Editor/RhythmContextEditor.cs +587 -0
- package/Editor/RhythmContextEditor.cs.meta +3 -0
- package/Editor/RhythmGameEditor.cs +45 -0
- package/Editor/RhythmGameEditor.cs.meta +11 -0
- package/Editor/RhythmTileEditor.cs +93 -0
- package/Editor/RhythmTileEditor.cs.meta +11 -0
- package/Editor/TagConfigDrawer.cs +30 -0
- package/Editor/TagConfigDrawer.cs.meta +11 -0
- package/Editor.meta +8 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/README.md +88 -0
- package/README.md.meta +7 -0
- package/Runtime/AssemblyInfo.cs +4 -0
- package/Runtime/AssemblyInfo.cs.meta +11 -0
- package/Runtime/Input/Base/BaseTileInput.cs +44 -0
- package/Runtime/Input/Base/BaseTileInput.cs.meta +11 -0
- package/Runtime/Input/Base/IInputHandler.cs +11 -0
- package/Runtime/Input/Base/IInputHandler.cs.meta +11 -0
- package/Runtime/Input/Base/InputData.cs +94 -0
- package/Runtime/Input/Base/InputData.cs.meta +3 -0
- package/Runtime/Input/Base/InputDirection.cs +17 -0
- package/Runtime/Input/Base/InputDirection.cs.meta +3 -0
- package/Runtime/Input/Base/InputPhase.cs +4 -0
- package/Runtime/Input/Base/InputPhase.cs.meta +3 -0
- package/Runtime/Input/Base.meta +3 -0
- package/Runtime/Input/Components/DragInput.cs +44 -0
- package/Runtime/Input/Components/DragInput.cs.meta +11 -0
- package/Runtime/Input/Components/HoldInput.cs +75 -0
- package/Runtime/Input/Components/HoldInput.cs.meta +12 -0
- package/Runtime/Input/Components/SwipeInput.cs +45 -0
- package/Runtime/Input/Components/SwipeInput.cs.meta +12 -0
- package/Runtime/Input/Components/TouchInput.cs +31 -0
- package/Runtime/Input/Components/TouchInput.cs.meta +11 -0
- package/Runtime/Input/Components.meta +8 -0
- package/Runtime/Input.meta +8 -0
- package/Runtime/MagicTilesCore.asmdef +24 -0
- package/Runtime/MagicTilesCore.asmdef.meta +7 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs +12 -0
- package/Runtime/MoodChange/AdjustHue.ComponentInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs +115 -0
- package/Runtime/MoodChange/AdjustHue.MaterialInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs +36 -0
- package/Runtime/MoodChange/AdjustHue.ParticleSystemInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs +28 -0
- package/Runtime/MoodChange/AdjustHue.SpriteRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs +37 -0
- package/Runtime/MoodChange/AdjustHue.TrailRendererInfo.cs.meta +3 -0
- package/Runtime/MoodChange/AdjustHue.cs +219 -0
- package/Runtime/MoodChange/AdjustHue.cs.meta +11 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs +227 -0
- package/Runtime/MoodChange/ColorHueExtensions.cs.meta +3 -0
- package/Runtime/MoodChange/HueCache.cs +167 -0
- package/Runtime/MoodChange/HueCache.cs.meta +11 -0
- package/Runtime/MoodChange/MoodChange.cs +52 -0
- package/Runtime/MoodChange/MoodChange.cs.meta +3 -0
- package/Runtime/MoodChange.meta +3 -0
- package/Runtime/Physics/TriggerCallback.cs +21 -0
- package/Runtime/Physics/TriggerCallback.cs.meta +3 -0
- package/Runtime/Physics.meta +8 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs +153 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.cs.meta +11 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab +145 -0
- package/Runtime/Preset/AudioSourcePlayer/AudioSourcePlayer.prefab.meta +7 -0
- package/Runtime/Preset/AudioSourcePlayer.meta +8 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs +22 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.cs.meta +11 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab +188 -0
- package/Runtime/Preset/AudioTimeText/AudioTimeText.prefab.meta +7 -0
- package/Runtime/Preset/AudioTimeText.meta +8 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs +32 -0
- package/Runtime/Preset/ParticleSystemPlayer/ParticleSystemPlayer.cs.meta +11 -0
- package/Runtime/Preset/ParticleSystemPlayer.meta +8 -0
- package/Runtime/Preset/RendererAlpha.cs +56 -0
- package/Runtime/Preset/RendererAlpha.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim +198 -0
- package/Runtime/Preset/ScoreText/ScoreText.anim.meta +8 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs +32 -0
- package/Runtime/Preset/ScoreText/ScoreText.cs.meta +11 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab +170 -0
- package/Runtime/Preset/ScoreText/ScoreText_2D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab +206 -0
- package/Runtime/Preset/ScoreText/ScoreText_3D.prefab.meta +7 -0
- package/Runtime/Preset/ScoreText.meta +8 -0
- package/Runtime/Preset/StartHint/StartHint.cs +26 -0
- package/Runtime/Preset/StartHint/StartHint.cs.meta +3 -0
- package/Runtime/Preset/StartHint.meta +8 -0
- package/Runtime/Preset/WowText/WowText.cs +38 -0
- package/Runtime/Preset/WowText/WowText.cs.meta +3 -0
- package/Runtime/Preset/WowText.meta +8 -0
- package/Runtime/Preset.meta +8 -0
- package/Runtime/Rhythm/Components/Controls.meta +8 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs +28 -0
- package/Runtime/Rhythm/Components/Helper/CameraFollow.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs +89 -0
- package/Runtime/Rhythm/Components/Helper/MeshSpriteSorter.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs +74 -0
- package/Runtime/Rhythm/Components/Helper/RecycleLayoutZ.cs.meta +11 -0
- package/Runtime/Rhythm/Components/Helper.meta +8 -0
- package/Runtime/Rhythm/Components.meta +8 -0
- package/Runtime/Rhythm/Core/GameMode.cs +10 -0
- package/Runtime/Rhythm/Core/GameMode.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs +16 -0
- package/Runtime/Rhythm/Core/IAudioPlayer.cs.meta +3 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs +10 -0
- package/Runtime/Rhythm/Core/IRhythmBehaviour.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs +57 -0
- package/Runtime/Rhythm/Core/RhythmBehaviour.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs +48 -0
- package/Runtime/Rhythm/Core/RhythmDebug.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs +323 -0
- package/Runtime/Rhythm/Core/RhythmGameT.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs +65 -0
- package/Runtime/Rhythm/Core/RhythmMatch.cs.meta +11 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs +77 -0
- package/Runtime/Rhythm/Core/RhythmTile.cs.meta +3 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs +59 -0
- package/Runtime/Rhythm/Core/RhythmTileHandler.cs.meta +3 -0
- package/Runtime/Rhythm/Core.meta +8 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs +120 -0
- package/Runtime/Rhythm/Extensions/CollectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs +27 -0
- package/Runtime/Rhythm/Extensions/ColliderExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs +56 -0
- package/Runtime/Rhythm/Extensions/GameHandlerExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs +61 -0
- package/Runtime/Rhythm/Extensions/GameObjectExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs +76 -0
- package/Runtime/Rhythm/Extensions/InputDirectionExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs +127 -0
- package/Runtime/Rhythm/Extensions/MTCListExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs +81 -0
- package/Runtime/Rhythm/Extensions/MeshRendererExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs +54 -0
- package/Runtime/Rhythm/Extensions/ParticleSystemExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Extensions.meta +8 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs +40 -0
- package/Runtime/Rhythm/Game/MTCSongAutoStart.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs +68 -0
- package/Runtime/Rhythm/Game/RhythmConfig.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs +533 -0
- package/Runtime/Rhythm/Game/RhythmContext.Api.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs +121 -0
- package/Runtime/Rhythm/Game/RhythmContext.Dev.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs +114 -0
- package/Runtime/Rhythm/Game/RhythmContext.Initialization.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs +126 -0
- package/Runtime/Rhythm/Game/RhythmContext.Runtime.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs +221 -0
- package/Runtime/Rhythm/Game/RhythmContext.State.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs +90 -0
- package/Runtime/Rhythm/Game/RhythmContext.Tile.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs +315 -0
- package/Runtime/Rhythm/Game/RhythmContext.TimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs +312 -0
- package/Runtime/Rhythm/Game/RhythmContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs +91 -0
- package/Runtime/Rhythm/Game/RhythmContextExtensions.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs +7 -0
- package/Runtime/Rhythm/Game/Tile/ITileProgress.cs.meta +3 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs +194 -0
- package/Runtime/Rhythm/Game/Tile/TileContext.cs.meta +11 -0
- package/Runtime/Rhythm/Game/Tile.meta +3 -0
- package/Runtime/Rhythm/Game.meta +3 -0
- package/Runtime/Rhythm/Math/Parabol.cs +35 -0
- package/Runtime/Rhythm/Math/Parabol.cs.meta +11 -0
- package/Runtime/Rhythm/Math.meta +8 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs +82 -0
- package/Runtime/Rhythm/System/Event/GameEvent.cs.meta +3 -0
- package/Runtime/Rhythm/System/Event.meta +8 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs +121 -0
- package/Runtime/Rhythm/System/Meta/MetaLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs +132 -0
- package/Runtime/Rhythm/System/Meta/VisualSpeedMeta.cs.meta +11 -0
- package/Runtime/Rhythm/System/Meta.meta +8 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs +45 -0
- package/Runtime/Rhythm/System/SongData/ListSongNote.cs.meta +3 -0
- package/Runtime/Rhythm/System/SongData.meta +8 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs +22 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.State.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs +138 -0
- package/Runtime/Rhythm/System/StateMachine/RhythmStateMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/StateMachine.meta +8 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs +135 -0
- package/Runtime/Rhythm/System/TimeKnot/ListTimeKnots.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeKnot.meta +8 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs +365 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeInterpolator.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs +107 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeMarker.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs +14 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs +21 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.TimeSpanNode.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs +28 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.ZLaneSpeed.cs.meta +3 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs +131 -0
- package/Runtime/Rhythm/System/TimeMachine/MTCTimeMachine.cs.meta +11 -0
- package/Runtime/Rhythm/System/TimeMachine.meta +8 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs +160 -0
- package/Runtime/Rhythm/System/VisualKnot/VisualKnotLogic.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualKnot.meta +8 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs +10 -0
- package/Runtime/Rhythm/System/VisualWarp/IVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs +27 -0
- package/Runtime/Rhythm/System/VisualWarp/LinearVisualWarp.cs.meta +11 -0
- package/Runtime/Rhythm/System/VisualWarp.meta +8 -0
- package/Runtime/Rhythm/System.meta +8 -0
- package/Runtime/Rhythm.meta +8 -0
- package/Runtime.meta +8 -0
- package/package.json +12 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using System.Linq;
|
|
3
|
+
using System.Reflection;
|
|
4
|
+
using UnityEditor;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
|
|
7
|
+
namespace Amanotes.MagicTilesCore
|
|
8
|
+
{
|
|
9
|
+
public class ClassInstanceDrawer
|
|
10
|
+
{
|
|
11
|
+
private System.Type _type;
|
|
12
|
+
private List<(string name, PropertyInfo property, FieldInfo field)> _members;
|
|
13
|
+
private List<(string name, PropertyInfo property, FieldInfo field)> _forceDrawMembers;
|
|
14
|
+
private readonly bool _drawProperties;
|
|
15
|
+
private readonly HashSet<string> _forceShowMembers;
|
|
16
|
+
private readonly HashSet<string> _forceHideMembers;
|
|
17
|
+
private bool _isExpanded = true;
|
|
18
|
+
private bool _isInitialized = false;
|
|
19
|
+
private float _maxLabelWidth = 0f; // Calculated max width needed for all labels
|
|
20
|
+
|
|
21
|
+
private readonly Dictionary<string, ClassInstanceDrawer> _forceDrawSubDrawers = new Dictionary<string, ClassInstanceDrawer>();
|
|
22
|
+
|
|
23
|
+
public ClassInstanceDrawer(System.Type type, bool drawProperties = true, HashSet<string> forceShowMembers = null, HashSet<string> forceHideMembers = null)
|
|
24
|
+
{
|
|
25
|
+
_type = type;
|
|
26
|
+
_drawProperties = drawProperties;
|
|
27
|
+
_forceShowMembers = forceShowMembers ?? new HashSet<string>();
|
|
28
|
+
_forceHideMembers = forceHideMembers ?? new HashSet<string>();
|
|
29
|
+
InitializeMembers();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public ClassInstanceDrawer(bool drawProperties = true, HashSet<string> forceShowMembers = null, HashSet<string> forceHideMembers = null)
|
|
33
|
+
{
|
|
34
|
+
_drawProperties = drawProperties;
|
|
35
|
+
_forceShowMembers = forceShowMembers ?? new HashSet<string>();
|
|
36
|
+
_forceHideMembers = forceHideMembers ?? new HashSet<string>();
|
|
37
|
+
_members = new List<(string name, PropertyInfo property, FieldInfo field)>();
|
|
38
|
+
_forceDrawMembers = new List<(string name, PropertyInfo property, FieldInfo field)>();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
private void InitializeMembers()
|
|
42
|
+
{
|
|
43
|
+
if (_isInitialized || _type == null) return;
|
|
44
|
+
|
|
45
|
+
_members = new List<(string name, PropertyInfo property, FieldInfo field)>();
|
|
46
|
+
_forceDrawMembers = new List<(string name, PropertyInfo property, FieldInfo field)>();
|
|
47
|
+
|
|
48
|
+
var properties = _type.GetProperties(BindingFlags.Public | BindingFlags.Instance)
|
|
49
|
+
.Where(p => p.CanRead && !p.GetIndexParameters().Any())
|
|
50
|
+
.OrderBy(p => p.Name);
|
|
51
|
+
|
|
52
|
+
var fields = _type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)
|
|
53
|
+
.OrderBy(f => f.Name);
|
|
54
|
+
|
|
55
|
+
var allFields = fields.ToArray();
|
|
56
|
+
|
|
57
|
+
if (_drawProperties)
|
|
58
|
+
{
|
|
59
|
+
foreach (var prop in properties)
|
|
60
|
+
{
|
|
61
|
+
if (_forceShowMembers.Contains(prop.Name))
|
|
62
|
+
{
|
|
63
|
+
_forceDrawMembers.Add((prop.Name, prop, null));
|
|
64
|
+
_forceDrawSubDrawers[prop.Name] = new ClassInstanceDrawer(prop.PropertyType, drawProperties: false);
|
|
65
|
+
}
|
|
66
|
+
else if (ShouldShowMember(prop.PropertyType, prop.Name) && !HasBackingField(prop, allFields))
|
|
67
|
+
{
|
|
68
|
+
_members.Add((prop.Name, prop, null));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
foreach (var field in fields)
|
|
74
|
+
{
|
|
75
|
+
if (_forceShowMembers.Contains(field.Name))
|
|
76
|
+
{
|
|
77
|
+
_forceDrawMembers.Add((field.Name, null, field));
|
|
78
|
+
_forceDrawSubDrawers[field.Name] = new ClassInstanceDrawer(field.FieldType, drawProperties: false);
|
|
79
|
+
}
|
|
80
|
+
else if (!_members.Any(m => m.name == field.Name) && ShouldShowMember(field.FieldType, field.Name))
|
|
81
|
+
{
|
|
82
|
+
_members.Add((field.Name, null, field));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
_isInitialized = true;
|
|
87
|
+
|
|
88
|
+
// Calculate max label width needed
|
|
89
|
+
CalculateMaxLabelWidth();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private bool ShouldShowMember(System.Type type, string memberName)
|
|
93
|
+
{
|
|
94
|
+
if (_forceHideMembers.Contains(memberName)) return false;
|
|
95
|
+
if (_forceShowMembers.Contains(memberName)) return true;
|
|
96
|
+
|
|
97
|
+
if (type.IsPrimitive || type.IsValueType || type.IsEnum || type == typeof(string)) return true;
|
|
98
|
+
if (typeof(UnityEngine.Object).IsAssignableFrom(type)) return true;
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private bool HasBackingField(PropertyInfo property, FieldInfo[] allFields)
|
|
104
|
+
{
|
|
105
|
+
var propertyName = property.Name;
|
|
106
|
+
var backingFieldName = $"<{propertyName}>k__BackingField";
|
|
107
|
+
var underscoreFieldName = $"_{char.ToLower(propertyName[0])}{propertyName.Substring(1)}";
|
|
108
|
+
|
|
109
|
+
return allFields.Any(f => f.Name == backingFieldName || f.Name == underscoreFieldName);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private void CalculateMaxLabelWidth()
|
|
113
|
+
{
|
|
114
|
+
_maxLabelWidth = 0f;
|
|
115
|
+
|
|
116
|
+
// Check all member labels
|
|
117
|
+
foreach (var (name, _, _) in _members)
|
|
118
|
+
{
|
|
119
|
+
var textWidth = EditorStyles.label.CalcSize(new GUIContent(name)).x;
|
|
120
|
+
_maxLabelWidth = Mathf.Max(_maxLabelWidth, textWidth);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check all force draw member labels
|
|
124
|
+
foreach (var (name, _, _) in _forceDrawMembers)
|
|
125
|
+
{
|
|
126
|
+
var textWidth = EditorStyles.label.CalcSize(new GUIContent(name)).x;
|
|
127
|
+
_maxLabelWidth = Mathf.Max(_maxLabelWidth, textWidth);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
_maxLabelWidth += 16f;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
public void Draw(object instance, string foldoutTitle = "Instance Data")
|
|
134
|
+
{
|
|
135
|
+
if (_type == null && instance != null)
|
|
136
|
+
{
|
|
137
|
+
_type = instance.GetType();
|
|
138
|
+
InitializeMembers();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (string.IsNullOrEmpty(foldoutTitle))
|
|
142
|
+
{
|
|
143
|
+
if (instance == null)
|
|
144
|
+
{
|
|
145
|
+
EditorGUILayout.HelpBox("Instance is null", MessageType.Warning);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
DrawFields(instance);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (!string.IsNullOrEmpty(foldoutTitle))
|
|
154
|
+
{
|
|
155
|
+
_isExpanded = EditorGUILayout.Foldout(_isExpanded, foldoutTitle, true);
|
|
156
|
+
if (!_isExpanded) return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (instance == null)
|
|
160
|
+
{
|
|
161
|
+
EditorGUILayout.HelpBox("Instance is null", MessageType.Warning);
|
|
162
|
+
}
|
|
163
|
+
else
|
|
164
|
+
{
|
|
165
|
+
DrawFields(instance);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
private void DrawFields(object instance)
|
|
170
|
+
{
|
|
171
|
+
if (_members.Count == 0 && _forceDrawMembers.Count == 0)
|
|
172
|
+
{
|
|
173
|
+
EditorGUILayout.HelpBox("No readable properties or fields found", MessageType.Info);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
// Save current label width
|
|
180
|
+
var originalLabelWidth = EditorGUIUtility.labelWidth;
|
|
181
|
+
|
|
182
|
+
// Set the calculated max label width
|
|
183
|
+
EditorGUIUtility.labelWidth = _maxLabelWidth;
|
|
184
|
+
EditorGUILayout.BeginHorizontal();
|
|
185
|
+
{
|
|
186
|
+
EditorGUILayout.BeginVertical();
|
|
187
|
+
if (_members.Count > 0)
|
|
188
|
+
{
|
|
189
|
+
var halfCount = (_members.Count + 1) / 2;
|
|
190
|
+
for (int i = 0; i < halfCount; i++)
|
|
191
|
+
{
|
|
192
|
+
var (name, property, field) = _members[i];
|
|
193
|
+
DrawField(instance, name, property, field);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
EditorGUILayout.EndVertical();
|
|
197
|
+
|
|
198
|
+
EditorGUILayout.BeginVertical();
|
|
199
|
+
if (_members.Count > 0)
|
|
200
|
+
{
|
|
201
|
+
var halfCount = (_members.Count + 1) / 2;
|
|
202
|
+
for (int i = halfCount; i < _members.Count; i++)
|
|
203
|
+
{
|
|
204
|
+
var (name, property, field) = _members[i];
|
|
205
|
+
DrawField(instance, name, property, field);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
EditorGUILayout.EndVertical();
|
|
209
|
+
}
|
|
210
|
+
EditorGUILayout.EndHorizontal();
|
|
211
|
+
EditorGUIUtility.labelWidth = originalLabelWidth;
|
|
212
|
+
|
|
213
|
+
// Draw sub-drawers as collapsible groups
|
|
214
|
+
foreach (var (name, property, field) in _forceDrawMembers)
|
|
215
|
+
{
|
|
216
|
+
object value = property != null ? property.GetValue(instance) : field.GetValue(instance);
|
|
217
|
+
var subDrawer = _forceDrawSubDrawers[name];
|
|
218
|
+
subDrawer.Draw(value, name);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
private void DrawField(object instance, string name, PropertyInfo property, FieldInfo field)
|
|
223
|
+
{
|
|
224
|
+
EditorGUILayout.BeginHorizontal();
|
|
225
|
+
{
|
|
226
|
+
object value = property != null ? property.GetValue(instance) : field.GetValue(instance);
|
|
227
|
+
System.Type type = property != null ? property.PropertyType : field.FieldType;
|
|
228
|
+
|
|
229
|
+
if (_forceDrawSubDrawers.TryGetValue(name, out var subDrawer))
|
|
230
|
+
{
|
|
231
|
+
subDrawer.Draw(value, "");
|
|
232
|
+
}
|
|
233
|
+
else
|
|
234
|
+
{
|
|
235
|
+
EditorGUI.BeginDisabledGroup(true);
|
|
236
|
+
DrawValue(name, value, type);
|
|
237
|
+
EditorGUI.EndDisabledGroup();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
EditorGUILayout.EndHorizontal();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private void DrawValue(string title, object value, System.Type type)
|
|
244
|
+
{
|
|
245
|
+
if (value == null) EditorGUILayout.TextField(new GUIContent(title),"null");
|
|
246
|
+
else if (type == typeof(int) || type == typeof(int?)) EditorGUILayout.IntField(new GUIContent(title), (int)value);
|
|
247
|
+
else if (type == typeof(float) || type == typeof(float?)) EditorGUILayout.FloatField(new GUIContent(title),(float)value);
|
|
248
|
+
else if (type == typeof(bool) || type == typeof(bool?)) EditorGUILayout.Toggle(new GUIContent(title),(bool)value);
|
|
249
|
+
else if (type == typeof(Vector3)) EditorGUILayout.Vector3Field(new GUIContent(title), (Vector3)value);
|
|
250
|
+
else if (type == typeof(string)) EditorGUILayout.TextField(new GUIContent(title), (string)value);
|
|
251
|
+
else if (typeof(UnityEngine.Object).IsAssignableFrom(type)) EditorGUILayout.ObjectField(new GUIContent(title), (UnityEngine.Object)value, type, true);
|
|
252
|
+
else if (type.IsEnum) EditorGUILayout.EnumPopup(new GUIContent(title), (System.Enum)value);
|
|
253
|
+
else EditorGUILayout.TextField(new GUIContent(title),value.ToString());
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Linq;
|
|
4
|
+
using System.Reflection;
|
|
5
|
+
using UnityEditor;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace Amanotes.MagicTilesCore
|
|
9
|
+
{
|
|
10
|
+
public abstract class CollapsibleGroupEditor : Editor
|
|
11
|
+
{
|
|
12
|
+
private Dictionary<Type, bool> _foldoutStates = new Dictionary<Type, bool>();
|
|
13
|
+
private Dictionary<Type, List<SerializedProperty>> _groupedProperties = new Dictionary<Type, List<SerializedProperty>>();
|
|
14
|
+
|
|
15
|
+
protected virtual void OnEnable()
|
|
16
|
+
{
|
|
17
|
+
GroupPropertiesByInheritanceLevel();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private void GroupPropertiesByInheritanceLevel()
|
|
21
|
+
{
|
|
22
|
+
_groupedProperties.Clear();
|
|
23
|
+
|
|
24
|
+
var targetType = target.GetType();
|
|
25
|
+
var inheritanceChain = GetInheritanceChain(targetType);
|
|
26
|
+
|
|
27
|
+
var serializedObject = this.serializedObject;
|
|
28
|
+
var iterator = serializedObject.GetIterator();
|
|
29
|
+
|
|
30
|
+
if (iterator.NextVisible(true))
|
|
31
|
+
{
|
|
32
|
+
while (iterator.NextVisible(false))
|
|
33
|
+
{
|
|
34
|
+
var fieldInfo = GetFieldInfo(targetType, iterator.propertyPath);
|
|
35
|
+
if (fieldInfo != null)
|
|
36
|
+
{
|
|
37
|
+
var declaringType = fieldInfo.DeclaringType;
|
|
38
|
+
var groupType = inheritanceChain.FirstOrDefault(type =>
|
|
39
|
+
declaringType == type || declaringType.IsSubclassOf(type));
|
|
40
|
+
|
|
41
|
+
if (groupType != null)
|
|
42
|
+
{
|
|
43
|
+
if (!_groupedProperties.ContainsKey(groupType))
|
|
44
|
+
{
|
|
45
|
+
_groupedProperties[groupType] = new List<SerializedProperty>();
|
|
46
|
+
_foldoutStates[groupType] = true;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
_groupedProperties[groupType].Add(iterator.Copy());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private List<Type> GetInheritanceChain(Type type)
|
|
57
|
+
{
|
|
58
|
+
var chain = new List<Type>();
|
|
59
|
+
var current = type;
|
|
60
|
+
|
|
61
|
+
while (current != null && current != typeof(ScriptableObject) && current != typeof(UnityEngine.Object))
|
|
62
|
+
{
|
|
63
|
+
chain.Add(current);
|
|
64
|
+
current = current.BaseType;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
chain.Reverse();
|
|
68
|
+
return chain;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private FieldInfo GetFieldInfo(Type type, string propertyPath)
|
|
72
|
+
{
|
|
73
|
+
var parts = propertyPath.Split('.');
|
|
74
|
+
var currentType = type;
|
|
75
|
+
FieldInfo fieldInfo = null;
|
|
76
|
+
|
|
77
|
+
foreach (var part in parts)
|
|
78
|
+
{
|
|
79
|
+
fieldInfo = currentType.GetField(part, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
|
|
80
|
+
if (fieldInfo == null) break;
|
|
81
|
+
|
|
82
|
+
currentType = fieldInfo.FieldType;
|
|
83
|
+
|
|
84
|
+
if (currentType.IsArray)
|
|
85
|
+
{
|
|
86
|
+
currentType = currentType.GetElementType();
|
|
87
|
+
}
|
|
88
|
+
else if (currentType.IsGenericType && currentType.GetGenericTypeDefinition() == typeof(List<>))
|
|
89
|
+
{
|
|
90
|
+
currentType = currentType.GetGenericArguments()[0];
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return fieldInfo;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public override void OnInspectorGUI()
|
|
98
|
+
{
|
|
99
|
+
serializedObject.Update();
|
|
100
|
+
|
|
101
|
+
// Draw each group as a collapsible foldout
|
|
102
|
+
foreach (var kvp in _groupedProperties.OrderBy(x => GetInheritanceChain(target.GetType()).IndexOf(x.Key)))
|
|
103
|
+
{
|
|
104
|
+
var groupType = kvp.Key;
|
|
105
|
+
var properties = kvp.Value;
|
|
106
|
+
|
|
107
|
+
if (properties.Count == 0) continue;
|
|
108
|
+
|
|
109
|
+
var groupName = GetGroupDisplayName(groupType);
|
|
110
|
+
_foldoutStates[groupType] = EditorGUILayout.BeginFoldoutHeaderGroup(_foldoutStates[groupType], groupName);
|
|
111
|
+
|
|
112
|
+
if (_foldoutStates[groupType])
|
|
113
|
+
{
|
|
114
|
+
EditorGUI.indentLevel++;
|
|
115
|
+
foreach (var property in properties)
|
|
116
|
+
{
|
|
117
|
+
EditorGUILayout.PropertyField(property, true);
|
|
118
|
+
}
|
|
119
|
+
EditorGUI.indentLevel--;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
EditorGUILayout.EndFoldoutHeaderGroup();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
serializedObject.ApplyModifiedProperties();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
protected virtual string GetGroupDisplayName(Type type)
|
|
129
|
+
{
|
|
130
|
+
// Remove common suffixes and prefixes for cleaner names
|
|
131
|
+
var name = type.Name;
|
|
132
|
+
|
|
133
|
+
if (name.EndsWith("Config"))
|
|
134
|
+
name = name.Substring(0, name.Length - 6);
|
|
135
|
+
|
|
136
|
+
if (name.StartsWith("MT"))
|
|
137
|
+
name = name.Substring(2);
|
|
138
|
+
|
|
139
|
+
return name;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|