This commit is contained in:
Mikhail 2026-04-14 15:19:41 +08:00
parent 716df5e9c1
commit 224a689ab6
31 changed files with 295 additions and 240 deletions

View File

@ -83,7 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawTemplates() private void DrawTemplates()
{ {
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
var iterator = serializedObject.GetIterator(); var iterator = serializedObject.GetIterator();
iterator.NextVisible(true); iterator.NextVisible(true);
@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUILayout.PropertyField(iterator, true); EditorGUILayout.PropertyField(iterator, true);
} }
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
@ -102,12 +102,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons() private void DrawControlButtons()
{ {
float height = EcsGUI.EntityBarHeight; float height = DragonGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f); rect = rect.AddPadding(2f, 0f);
var (_, buttonRect) = rect.HorizontalSliceRight(height); var (_, buttonRect) = rect.HorizontalSliceRight(height);
if (EcsGUI.ValidateButton(buttonRect)) if (DragonGUI.ValidateButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {
@ -115,7 +115,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
buttonRect = RectUtility.Move(buttonRect, -height, 0); buttonRect = RectUtility.Move(buttonRect, -height, 0);
if (EcsGUI.AutosetButton(buttonRect)) if (DragonGUI.AutosetButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {

View File

@ -137,7 +137,7 @@ namespace DCFApixels.DragonECS
_entity = entity; _entity = entity;
_world = world; _world = world;
#if UNITY_EDITOR #if UNITY_EDITOR
world.Get<EcsGUI.EntityLinksComponent>().SetConnectLink(entity.GetIDUnchecked(), this); world.Get<DragonGUI.EntityLinksComponent>().SetConnectLink(entity.GetIDUnchecked(), this);
#endif #endif
_connectedEntities.Add(GetInstanceID(), this); _connectedEntities.Add(GetInstanceID(), this);
var goConnects = world.GetPool<GameObjectConnect>(); var goConnects = world.GetPool<GameObjectConnect>();

View File

@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
EditorGUILayout.PropertyField(iterator, true); EditorGUILayout.PropertyField(iterator, true);
} }
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
@ -27,7 +27,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons() private void DrawControlButtons()
{ {
float height = EcsGUI.EntityBarHeight; float height = DragonGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f); rect = rect.AddPadding(2f, 0f);
@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
//var (left, autosetCascadeRect) = rect.HorizontalSliceRight(height); //var (left, autosetCascadeRect) = rect.HorizontalSliceRight(height);
//var (_, autosetRect) = rect.HorizontalSliceRight(height); //var (_, autosetRect) = rect.HorizontalSliceRight(height);
if (EcsGUI.AutosetCascadeButton(buttonRect)) if (DragonGUI.AutosetCascadeButton(buttonRect))
{ {
foreach (AutoEntityCreator target in targets) foreach (AutoEntityCreator target in targets)
{ {
@ -44,17 +44,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
buttonRect = buttonRect.Move(-height, 0); buttonRect = buttonRect.Move(-height, 0);
if (EcsGUI.AutosetButton(buttonRect)) if (DragonGUI.AutosetButton(buttonRect))
{ {
foreach (AutoEntityCreator target in targets) foreach (AutoEntityCreator target in targets)
{ {
target.Autoset_Editor(); target.Autoset_Editor();
} }
} }
using (EcsGUI.SetEnable(Application.isPlaying)) using (DragonGUI.SetEnable(Application.isPlaying))
{ {
buttonRect = buttonRect.Move(-height, 0); buttonRect = buttonRect.Move(-height, 0);
if (EcsGUI.NewEntityButton(buttonRect)) if (DragonGUI.NewEntityButton(buttonRect))
{ {
foreach (AutoEntityCreator target in targets) foreach (AutoEntityCreator target in targets)
{ {

View File

@ -24,12 +24,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
//bool isConnected = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world); //bool isConnected = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
//EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive; //EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive;
//EcsGUI.Layout.EntityField(status, id, gen, worldID); //EcsGUI.Layout.EntityField(status, id, gen, worldID);
EcsGUI.Layout.EntityField(Target.Entity); DragonGUI.Layout.EntityField(Target.Entity);
} }
private void DrawTemplates() private void DrawTemplates()
{ {
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
var iterator = serializedObject.GetIterator(); var iterator = serializedObject.GetIterator();
iterator.NextVisible(true); iterator.NextVisible(true);
@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUILayout.PropertyField(iterator, true); EditorGUILayout.PropertyField(iterator, true);
} }
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
} }
@ -47,12 +47,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawControlButtons() private void DrawControlButtons()
{ {
float height = EcsGUI.EntityBarHeight; float height = DragonGUI.EntityBarHeight;
Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height);
EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f));
rect = rect.AddPadding(2f, 0f); rect = rect.AddPadding(2f, 0f);
var (_, buttonRect) = rect.HorizontalSliceRight(height); var (_, buttonRect) = rect.HorizontalSliceRight(height);
if (EcsGUI.AutosetCascadeButton(buttonRect)) if (DragonGUI.AutosetCascadeButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {
@ -60,17 +60,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
buttonRect = RectUtility.Move(buttonRect, -height, 0); buttonRect = RectUtility.Move(buttonRect, -height, 0);
if (EcsGUI.AutosetButton(buttonRect)) if (DragonGUI.AutosetButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {
target.Autoset_Editor(); target.Autoset_Editor();
} }
} }
using (EcsGUI.SetEnable(Application.isPlaying)) using (DragonGUI.SetEnable(Application.isPlaying))
{ {
buttonRect = buttonRect.Move(-height, 0); buttonRect = buttonRect.Move(-height, 0);
if (EcsGUI.DelEntityButton(buttonRect)) if (DragonGUI.DelEntityButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {
@ -78,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
buttonRect = buttonRect.Move(-height, 0); buttonRect = buttonRect.Move(-height, 0);
if (EcsGUI.UnlinkButton(buttonRect)) if (DragonGUI.UnlinkButton(buttonRect))
{ {
foreach (var target in Targets) foreach (var target in Targets)
{ {
@ -105,7 +105,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (world.IsNullOrDetroyed() == false) if (world.IsNullOrDetroyed() == false)
{ {
EcsGUI.Layout.DrawRuntimeComponents(entityID, world, true, true); DragonGUI.Layout.DrawRuntimeComponents(entityID, world, true, true);
} }
} }
} }

View File

@ -40,12 +40,12 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
using (EcsGUI.SetBackgroundColor(labelBackColor)) using (DragonGUI.SetBackgroundColor(labelBackColor))
{ {
GUILayout.Box("Is Empty", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true)); GUILayout.Box("Is Empty", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
} }
EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw()); DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw());
base.OnInspectorGUI(); base.OnInspectorGUI();
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUI.DrawRect(r, c); EditorGUI.DrawRect(r, c);
GUILayout.Space(10); GUILayout.Space(10);
EcsGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw()); DragonGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw());
} }
} }
} }

View File

@ -55,11 +55,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
if (drawFoldout && isExpanded) if (drawFoldout && isExpanded)
{ {
using (EcsGUI.UpIndentLevel()) using (DragonGUI.UpIndentLevel())
{ {
if (world != null && world.IsAlive(entity.id, entity.gen)) if (world != null && world.IsAlive(entity.id, entity.gen))
{ {
EcsGUI.Layout.DrawRuntimeComponents(entity.id, world, false, false); DragonGUI.Layout.DrawRuntimeComponents(entity.id, world, false, false);
if (Event.current.type == EventType.Layout) if (Event.current.type == EventType.Layout)
{ {
heightCache = GUILayoutUtility.GetLastRect().height; heightCache = GUILayoutUtility.GetLastRect().height;
@ -67,10 +67,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
} }
EcsGUI.EntityField(position, property); DragonGUI.EntityField(position, property);
using (EcsGUI.SetEnable(world != null)) using (DragonGUI.SetEnable(world != null))
{ {
EcsGUI.EntityHyperlinkButton(hyperlinkButtonRect, world, entity.id); DragonGUI.EntityHyperlinkButton(hyperlinkButtonRect, world, entity.id);
} }
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
EcsGUI.Changed = true; DragonGUI.Changed = true;
DragAndDrop.AcceptDrag(); DragAndDrop.AcceptDrag();
DragAndDrop.activeControlID = 0; DragAndDrop.activeControlID = 0;
} }

View File

@ -33,7 +33,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
//float checkBoxWidth = 20f; //float checkBoxWidth = 20f;
GUILayout.Space(20f); GUILayout.Space(20f);
using (new EcsGUI.ColorScope(Color.white * 0.5f)) using (new DragonGUI.ColorScope(Color.white * 0.5f))
GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginVertical(EditorStyles.helpBox);
//using (new EcsGUI.ColorScope(Color.white * 1.2f)) //using (new EcsGUI.ColorScope(Color.white * 1.2f))
GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f));
@ -69,7 +69,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.EndVertical(); GUILayout.EndVertical();
GUILayout.Space(20f); GUILayout.Space(20f);
using (EcsGUI.SetColor(Color.white * 0.5f)) using (DragonGUI.SetColor(Color.white * 0.5f))
{ {
GUILayout.BeginVertical(EditorStyles.helpBox); GUILayout.BeginVertical(EditorStyles.helpBox);
} }

View File

@ -12,7 +12,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
var entity = Target.Entity; var entity = Target.Entity;
bool isAlive = entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world); bool isAlive = entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
using (EcsGUI.SetEnable(isAlive)) using (DragonGUI.SetEnable(isAlive))
{ {
if (GUILayout.Button("Delete Entity", GUILayout.Height(36f))) if (GUILayout.Button("Delete Entity", GUILayout.Height(36f)))
{ {
@ -20,18 +20,18 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
//EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID); //EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
EcsGUI.Layout.EntityField(entity); DragonGUI.Layout.EntityField(entity);
var drawers = UnityEditorUtility._entityEditorBlockDrawers; var drawers = UnityEditorUtility._entityEditorBlockDrawers;
if (drawers.Length > 0) if (drawers.Length > 0)
{ {
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
bool isExpand = false; bool isExpand = false;
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data"); isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data");
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand; UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand;
} }
@ -48,7 +48,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
EcsGUI.Layout.DrawRuntimeComponents(entity, false); DragonGUI.Layout.DrawRuntimeComponents(entity, false);
} }
} }
} }

View File

@ -41,7 +41,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
else else
{ {
color = EcsGUI.SelectPanelColor(meta, i, -1).ToMetaColor(); color = DragonGUI.SelectPanelColor(meta, i, -1).ToMetaColor();
} }
name = $"{meta.Name}{SEPARATOR}{meta.TypeName}{SEPARATOR}{meta.MetaID}{SEPARATOR}{color.colorCode:X8}"; name = $"{meta.Name}{SEPARATOR}{meta.TypeName}{SEPARATOR}{meta.MetaID}{SEPARATOR}{color.colorCode:X8}";
} }
@ -71,7 +71,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
_headerStyle.fontSize = 28; _headerStyle.fontSize = 28;
} }
using (EcsGUI.Layout.BeginHorizontal()) using (DragonGUI.Layout.BeginHorizontal())
{ {
GUILayout.Label("[Systems]", _headerStyle, GUILayout.ExpandWidth(true)); GUILayout.Label("[Systems]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true))) if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -83,7 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
IsShowInterfaces = EditorGUILayout.Toggle("Show Interfaces", IsShowInterfaces); IsShowInterfaces = EditorGUILayout.Toggle("Show Interfaces", IsShowInterfaces);
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden); IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
using (EcsGUI.Layout.BeginVertical()) using (DragonGUI.Layout.BeginVertical())
{ {
int i = 0; int i = 0;
foreach (var item in Target.Pipeline.AllSystems) foreach (var item in Target.Pipeline.AllSystems)
@ -95,7 +95,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.Label("[Runners]", _headerStyle); GUILayout.Label("[Runners]", _headerStyle);
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
int i = 0; int i = 0;
foreach (var item in Target.Pipeline.AllRunners) foreach (var item in Target.Pipeline.AllRunners)
@ -114,13 +114,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.EndVertical(); GUILayout.EndVertical();
GUILayout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()); GUILayout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle());
using (EcsGUI.Layout.BeginHorizontal()) using (var scope = EcsGUI.SetAlignment(GUI.skin.label)) using (DragonGUI.Layout.BeginHorizontal()) using (var scope = DragonGUI.SetAlignment(GUI.skin.label))
{ {
scope.Target.alignment = TextAnchor.UpperLeft; scope.Target.alignment = TextAnchor.UpperLeft;
GUILayout.Label("<", GUILayout.ExpandWidth(true)); GUILayout.Label("<", GUILayout.ExpandWidth(true));
scope.Target.alignment = TextAnchor.UpperRight; scope.Target.alignment = TextAnchor.UpperRight;
using (EcsGUI.SetAlpha(0.64f)) using (DragonGUI.SetAlpha(0.64f))
{ {
GUILayout.Label($"{markerSystem.layerNameSpace}", GUILayout.ExpandWidth(false)); GUILayout.Label($"{markerSystem.layerNameSpace}", GUILayout.ExpandWidth(false));
} }
@ -128,7 +128,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -4f); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -4f);
scope.Target.alignment = TextAnchor.UpperLeft; scope.Target.alignment = TextAnchor.UpperLeft;
using (EcsGUI.SetFontStyle(scope.Target, FontStyle.Bold)) using (DragonGUI.SetFontStyle(scope.Target, FontStyle.Bold))
{ {
GUILayout.Label($"{markerSystem.layerName}", GUILayout.ExpandWidth(false)); GUILayout.Label($"{markerSystem.layerName}", GUILayout.ExpandWidth(false));
} }
@ -147,10 +147,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
string name = meta.Name; string name = meta.Name;
Color color = EcsGUI.SelectPanelColor(meta, index, -1); Color color = DragonGUI.SelectPanelColor(meta, index, -1);
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f))) using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{ {
if (IsShowInterfaces) if (IsShowInterfaces)
{ {
@ -168,9 +168,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
return; return;
} }
Color color = EcsGUI.SelectPanelColor(meta, index, -1); Color color = DragonGUI.SelectPanelColor(meta, index, -1);
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f))) using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{ {
GUILayout.Label(meta.Name, EditorStyles.boldLabel); GUILayout.Label(meta.Name, EditorStyles.boldLabel);
GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle); GUILayout.Label(string.Join(", ", runner.ProcessRaw.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);

View File

@ -61,10 +61,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
protected override void DrawCustom() protected override void DrawCustom()
{ {
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden); IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
Init(); Init();
} }
@ -104,7 +104,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
color = NormalizeGridColor(i, color); color = NormalizeGridColor(i, color);
EditorGUI.DrawRect(lineRect, color); EditorGUI.DrawRect(lineRect, color);
if (EcsGUI.HitTest(lineRect)) if (DragonGUI.HitTest(lineRect))
{ {
GUI.Button(lineRect, "", EditorStyles.selectionRect); GUI.Button(lineRect, "", EditorStyles.selectionRect);
_selectedPointMeta.process = meta; _selectedPointMeta.process = meta;
@ -135,7 +135,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
color = NormalizeGridColor(i, color); color = NormalizeGridColor(i, color);
EditorGUI.DrawRect(lineRect, color); EditorGUI.DrawRect(lineRect, color);
if (EcsGUI.HitTest(lineRect)) if (DragonGUI.HitTest(lineRect))
{ {
GUI.Button(lineRect, "", EditorStyles.selectionRect); GUI.Button(lineRect, "", EditorStyles.selectionRect);
_selectedPointMeta.system = meta; _selectedPointMeta.system = meta;

View File

@ -107,7 +107,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
_headerStyle.fontSize = 28; _headerStyle.fontSize = 28;
} }
using (EcsGUI.Layout.BeginHorizontal()) using (DragonGUI.Layout.BeginHorizontal())
{ {
GUILayout.Label("[World]", _headerStyle, GUILayout.ExpandWidth(true)); GUILayout.Label("[World]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true))) if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -117,9 +117,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
EcsGUI.Layout.DrawWorldBaseInfo(Target.World); DragonGUI.Layout.DrawWorldBaseInfo(Target.World);
EcsGUI.Layout.DrawWorldComponents(Target.World); DragonGUI.Layout.DrawWorldComponents(Target.World);
} }
} }
} }

View File

@ -185,7 +185,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
var executors = Target.MaskQueryExecutors; var executors = Target.MaskQueryExecutors;
using (EcsGUI.Layout.BeginHorizontal()) using (DragonGUI.Layout.BeginHorizontal())
{ {
GUILayout.Label("[Queries]", _headerStyle, GUILayout.ExpandWidth(true)); GUILayout.Label("[Queries]", _headerStyle, GUILayout.ExpandWidth(true));
if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true))) if (GUILayout.Button("Copy to Clipboard", GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
@ -268,7 +268,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
//using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(GetGenericPanelColor(index)))) //using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(GetGenericPanelColor(index))))
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
var mask = executor.Mask; var mask = executor.Mask;
DrawConstraint("+", mask.Incs); DrawConstraint("+", mask.Incs);
@ -294,24 +294,24 @@ namespace DCFApixels.DragonECS.Unity.Editors
return; return;
} }
using (EcsGUI.Layout.BeginHorizontal()) using (DragonGUI.Layout.BeginHorizontal())
{ {
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter)) using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter))
using (EcsGUI.SetFontStyle(value: FontStyle.Bold)) using (DragonGUI.SetFontStyle(value: FontStyle.Bold))
using (EcsGUI.SetFontSize(value: 18)) using (DragonGUI.SetFontSize(value: 18))
using (EcsGUI.SetColor(Color.white, 0.3f)) using (DragonGUI.SetColor(Color.white, 0.3f))
GUILayout.Label(title, GUILayout.Width(12)); GUILayout.Label(title, GUILayout.Width(12));
using (EcsGUI.Layout.BeginVertical()) using (DragonGUI.Layout.BeginVertical())
{ {
foreach (var inc in ids) foreach (var inc in ids)
{ {
Type type = Target.World.GetComponentType(inc); Type type = Target.World.GetComponentType(inc);
TypeMeta meta = type.GetMeta(); TypeMeta meta = type.GetMeta();
Color color = EcsGUI.SelectPanelColor(meta, i, 9); Color color = DragonGUI.SelectPanelColor(meta, i, 9);
using (EcsGUI.Layout.BeginVertical(color.SetAlpha(0.2f))) using (DragonGUI.Layout.BeginVertical(color.SetAlpha(0.2f)))
{ {
GUILayout.Label(meta.TypeName); GUILayout.Label(meta.TypeName);
} }

View File

@ -20,7 +20,7 @@ namespace DCFApixels.DragonECS.Unity.Internal
_entity = entity; _entity = entity;
#if UNITY_EDITOR #if UNITY_EDITOR
var world = entity.GetWorldUnchecked(); var world = entity.GetWorldUnchecked();
world.Get<EcsGUI.EntityLinksComponent>().SetMonitorLink(entity.GetIDUnchecked(), this); world.Get<DragonGUI.EntityLinksComponent>().SetMonitorLink(entity.GetIDUnchecked(), this);
#endif #endif
} }
} }

View File

@ -51,11 +51,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
(foldoutRect, labelField) = foldoutRect.HorizontalSliceLeft(EditorGUIUtility.labelWidth); (foldoutRect, labelField) = foldoutRect.HorizontalSliceLeft(EditorGUIUtility.labelWidth);
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label);
using (EcsGUI.SetAlignment(EditorStyles.miniLabel, TextAnchor.MiddleRight)) using (DragonGUI.SetAlignment(EditorStyles.miniLabel, TextAnchor.MiddleRight))
{ {
if (_labelCache.TryGetValue((byte)(flags.Normalize()), out string str) == false) if (_labelCache.TryGetValue((byte)(flags.Normalize()), out string str) == false)
{ {
@ -70,7 +70,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
//property.isExpanded = true; //property.isExpanded = true;
using (EcsGUI.UpIndentLevel()) using (DragonGUI.UpIndentLevel())
{ {
checkboxRects = checkboxRects.Move(EditorGUIUtility.standardVerticalSpacing, 0); checkboxRects = checkboxRects.Move(EditorGUIUtility.standardVerticalSpacing, 0);
@ -81,11 +81,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
//LayerName //LayerName
property.Next(true); property.Next(true);
using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.SetIndentLevel(0))
{ {
flags = flags.SetOverwriteLayerName(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteLayerName())); flags = flags.SetOverwriteLayerName(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteLayerName()));
} }
using (EcsGUI.SetEnable(flags.IsOverwriteLayerName())) using (DragonGUI.SetEnable(flags.IsOverwriteLayerName()))
{ {
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true); EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
} }
@ -95,11 +95,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
//SortOrder //SortOrder
property.Next(false); property.Next(false);
using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.SetIndentLevel(0))
{ {
flags = flags.SetOverwriteSortOrder(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteSortOrder())); flags = flags.SetOverwriteSortOrder(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteSortOrder()));
} }
using (EcsGUI.SetEnable(flags.IsOverwriteSortOrder())) using (DragonGUI.SetEnable(flags.IsOverwriteSortOrder()))
{ {
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true); EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
} }
@ -109,16 +109,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
//IsUnique //IsUnique
property.Next(false); property.Next(false);
using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.SetIndentLevel(0))
{ {
flags = flags.SetOverwriteIsUnique(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteIsUnique())); flags = flags.SetOverwriteIsUnique(EditorGUI.Toggle(checkboxRect, flags.IsOverwriteIsUnique()));
} }
using (EcsGUI.SetEnable(flags.IsOverwriteIsUnique())) using (DragonGUI.SetEnable(flags.IsOverwriteIsUnique()))
{ {
EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true); EditorGUI.PropertyField(fieldRect, property, UnityEditorUtility.GetLabel(property.displayName), true);
} }
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
flagsProp.enumValueFlag = (int)flags; flagsProp.enumValueFlag = (int)flags;
} }
@ -133,7 +133,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
exti:; exti:;
//EcsGUI.Changed = Event.current.type == EventType.MouseUp; //EcsGUI.Changed = Event.current.type == EventType.MouseUp;
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
property.serializedObject.ApplyModifiedProperties(); property.serializedObject.ApplyModifiedProperties();
} }

View File

@ -10,7 +10,7 @@ using UnityObject = UnityEngine.Object;
namespace DCFApixels.DragonECS.Unity.Editors namespace DCFApixels.DragonECS.Unity.Editors
{ {
internal static partial class EcsGUI internal static partial class DragonGUI
{ {
public static partial class Layout public static partial class Layout
{ {
@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
public static void ScriptAssetButton(MonoScript script, params GUILayoutOption[] options) public static void ScriptAssetButton(MonoScript script, params GUILayoutOption[] options)
{ {
EcsGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script); DragonGUI.ScriptAssetButton(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabelTemp(), EditorStyles.miniButton, options), script);
} }
@ -85,11 +85,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
public static void DrawEmptyComponentProperty(SerializedProperty property, string name, bool isDisplayEmpty) public static void DrawEmptyComponentProperty(SerializedProperty property, string name, bool isDisplayEmpty)
{ {
EcsGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabel(name), EditorStyles.label), property, name, isDisplayEmpty); DragonGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(UnityEditorUtility.GetLabel(name), EditorStyles.label), property, name, isDisplayEmpty);
} }
public static void DrawEmptyComponentProperty(SerializedProperty property, GUIContent label, bool isDisplayEmpty) public static void DrawEmptyComponentProperty(SerializedProperty property, GUIContent label, bool isDisplayEmpty)
{ {
EcsGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(label, EditorStyles.label), property, label, isDisplayEmpty); DragonGUI.DrawEmptyComponentProperty(GUILayoutUtility.GetRect(label, EditorStyles.label), property, label, isDisplayEmpty);
} }
public static void DrawWorldBaseInfo(EcsWorld world) public static void DrawWorldBaseInfo(EcsWorld world)
{ {
@ -125,7 +125,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
float width = EditorGUIUtility.currentViewWidth; float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight; float height = EntityBarHeight;
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity); DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
} }
public static void EntityField(EntitySlotInfo entity) public static void EntityField(EntitySlotInfo entity)
{ {
@ -139,7 +139,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
float width = EditorGUIUtility.currentViewWidth; float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight; float height = EntityBarHeight;
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity); DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), label, entity);
} }
public static void EntityField(SerializedProperty property) public static void EntityField(SerializedProperty property)
{ {
@ -153,21 +153,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
float width = EditorGUIUtility.currentViewWidth; float width = EditorGUIUtility.currentViewWidth;
float height = EntityBarHeight; float height = EntityBarHeight;
EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label); DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label);
} }
#endregion #endregion
public static bool AddComponentButtons(out Rect dropDownRect) public static bool AddComponentButtons(out Rect dropDownRect)
{ {
return EcsGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); return DragonGUI.AddComponentButton(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
} }
public static AddClearButton AddClearComponentButtons(out Rect dropDownRect) public static AddClearButton AddClearComponentButtons(out Rect dropDownRect)
{ {
return EcsGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); return DragonGUI.AddClearComponentButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
} }
public static AddClearButton AddClearSystemButtons(out Rect dropDownRect) public static AddClearButton AddClearSystemButtons(out Rect dropDownRect)
{ {
return EcsGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect); return DragonGUI.AddClearSystemButtons(GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, 24f), out dropDownRect);
} }
public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout, bool isRoot = true) public static void DrawRuntimeComponents(entlong entity, bool isWithFoldout, bool isRoot = true)
{ {

View File

@ -12,7 +12,7 @@ using Color = UnityEngine.Color;
namespace DCFApixels.DragonECS.Unity.Editors namespace DCFApixels.DragonECS.Unity.Editors
{ {
internal static partial class EcsGUI internal static partial class DragonGUI
{ {
#region Scores #region Scores
private static int _changedCounter = 0; private static int _changedCounter = 0;
@ -72,6 +72,20 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
} }
public static SerializedProperty CurrentTrackedArrayProperty;
public readonly struct TrackArrayPropertyScope : IDisposable
{
private readonly SerializedProperty _sp;
public TrackArrayPropertyScope(SerializedProperty sp)
{
_sp = sp;
CurrentTrackedArrayProperty = null;
}
public void Dispose()
{
CurrentTrackedArrayProperty = _sp;
}
}
public readonly struct CheckChangedScopeWithAutoApply : IDisposable public readonly struct CheckChangedScopeWithAutoApply : IDisposable
{ {
private readonly CheckChangedScope _scope; private readonly CheckChangedScope _scope;

View File

@ -9,15 +9,12 @@
#if UNITY_EDITOR #if UNITY_EDITOR
namespace DCFApixels.DragonECS.Unity.Editors namespace DCFApixels.DragonECS.Unity.Editors
{ {
using DCFApixels.DragonECS.Unity.Internal;
using global::Unity.Collections.LowLevel.Unsafe; using global::Unity.Collections.LowLevel.Unsafe;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
using UnityEngine.UIElements;
using UnityObject = UnityEngine.Object; using UnityObject = UnityEngine.Object;
@ -79,7 +76,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (AutoChechChanges) if (AutoChechChanges)
{ {
using (EcsGUI.CheckChanged(serializedObject)) using (DragonGUI.CheckChanged(serializedObject))
{ {
StaticInit(); StaticInit();
Init(); Init();
@ -154,16 +151,28 @@ namespace DCFApixels.DragonECS.Unity.Editors
private IEnumerable<Attribute> _attributes = null; private IEnumerable<Attribute> _attributes = null;
private bool? _isArrayElement = null; private Type _propertyType = null;
private bool _isArrayElement;
private SerializedProperty _trackedArrayProperty = null;
protected bool IsArrayElement protected bool IsArrayElement
{ {
get get
{ {
if (_isArrayElement == null) return _isArrayElement;
{
_isArrayElement = Attributes.Any(o => o is ArrayElementAttribute);
} }
return _isArrayElement.Value; }
protected Type PropertyType
{
get
{
return _propertyType;
}
}
protected SerializedProperty TrackedArrayProperty
{
get
{
return _trackedArrayProperty;
} }
} }
@ -218,6 +227,23 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (IsInit) { return; } if (IsInit) { return; }
_isInit = true; _isInit = true;
_isArrayElement = false;
if (fieldInfo != null)
{
_propertyType = fieldInfo.FieldType;
if (_propertyType.IsArray)
{
_propertyType = _propertyType.GetElementType();
_isArrayElement = true;
}
if (_propertyType.IsGenericType && _propertyType.GetGenericTypeDefinition() == typeof(List<>))
{
_propertyType = _propertyType.GetGenericArguments()[0];
_isArrayElement = true;
}
}
OnInit(property); OnInit(property);
} }
protected virtual void OnStaticInit() { } protected virtual void OnStaticInit() { }
@ -225,16 +251,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
public override float GetPropertyHeight(SerializedProperty property, GUIContent label) public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
_trackedArrayProperty = DragonGUI.CurrentTrackedArrayProperty;
using (new DragonGUI.TrackArrayPropertyScope(null))
{ {
StaticInit(); StaticInit();
Init(property); Init(property);
return GetCustomHeight(property, label); return GetCustomHeight(property, label);
} }
}
protected abstract float GetCustomHeight(SerializedProperty property, GUIContent label); protected abstract float GetCustomHeight(SerializedProperty property, GUIContent label);
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{ {
using (EcsGUI.CheckChanged(property.serializedObject)) _trackedArrayProperty = DragonGUI.CurrentTrackedArrayProperty;
using (new DragonGUI.TrackArrayPropertyScope(null)) using (DragonGUI.CheckChanged(property.serializedObject))
{ {
StaticInit(); StaticInit();
Init(property); Init(property);

View File

@ -274,7 +274,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
_fieldProperty.serializedObject.ApplyModifiedProperties(); _fieldProperty.serializedObject.ApplyModifiedProperties();
EcsGUI.DelayedChanged = true; DragonGUI.DelayedChanged = true;
} }
} }
} }

View File

@ -246,7 +246,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{ {
bool isNull = world == null || world.IsDestroyed || world.ID == 0; bool isNull = world == null || world.IsDestroyed || world.ID == 0;
if (isNull) { return; } if (isNull) { return; }
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout); IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout);
EditorGUILayout.EndFoldoutHeaderGroup(); EditorGUILayout.EndFoldoutHeaderGroup();
@ -271,32 +271,32 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
float padding = EditorGUIUtility.standardVerticalSpacing; float padding = EditorGUIUtility.standardVerticalSpacing;
Rect optionButton = GUILayoutUtility.GetLastRect(); Rect optionButton = GUILayoutUtility.GetLastRect();
optionButton.yMin = optionButton.yMax; optionButton.yMin = optionButton.yMax;
optionButton.yMax += EcsGUI.HeadIconsRect.height; optionButton.yMax += DragonGUI.HeadIconsRect.height;
optionButton.xMin = optionButton.xMax - 64; optionButton.xMin = optionButton.xMax - 64;
optionButton.center += Vector2.up * padding * 2f; optionButton.center += Vector2.up * padding * 2f;
//Canceling isExpanded //Canceling isExpanded
if (EcsGUI.ClickTest(optionButton)) if (DragonGUI.ClickTest(optionButton))
{ {
ref bool isExpanded = ref expandMatrix.Down(); ref bool isExpanded = ref expandMatrix.Down();
isExpanded = !isExpanded; isExpanded = !isExpanded;
} }
Color panelColor = EcsGUI.SelectPanelColor(meta, index, total); Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
using (EcsGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA))) using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
{ {
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
//Edit script button //Edit script button
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script)) if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
{ {
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.ScriptAssetButton(optionButton, script); DragonGUI.ScriptAssetButton(optionButton, script);
} }
//Description icon //Description icon
if (string.IsNullOrEmpty(meta.Description.Text) == false) if (string.IsNullOrEmpty(meta.Description.Text) == false)
{ {
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.DescriptionIcon(optionButton, meta.Description.Text); DragonGUI.DescriptionIcon(optionButton, meta.Description.Text);
} }
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name); RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
@ -336,7 +336,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
} }
private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout) private void DrawRuntimeComponents(int entityID, EcsWorld world, bool isWithFoldout)
{ {
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.SetIndentLevel(0))
{ {
if (_runtimeComponentsDepth >= RuntimeComponentsMaxDepth) if (_runtimeComponentsDepth >= RuntimeComponentsMaxDepth)
{ {
@ -350,12 +350,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
} }
if (isWithFoldout == false || IsShowRuntimeComponents) if (isWithFoldout == false || IsShowRuntimeComponents)
{ {
if (EcsGUI.Layout.AddComponentButtons(out Rect dropDownRect)) if (DragonGUI.Layout.AddComponentButtons(out Rect dropDownRect))
{ {
RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID); RuntimeComponentsUtility.GetAddComponentGenericMenu(world).Open(dropDownRect, entityID);
} }
using (EcsGUI.SetBackgroundColor(GUI.color.SetAlpha(0.16f))) using (DragonGUI.SetBackgroundColor(GUI.color.SetAlpha(0.16f)))
{ {
GUILayout.Box("", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true)); GUILayout.Box("", UnityEditorUtility.GetWhiteStyle(), GUILayout.ExpandWidth(true));
} }
@ -384,25 +384,25 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
float padding = EditorGUIUtility.standardVerticalSpacing; float padding = EditorGUIUtility.standardVerticalSpacing;
Rect optionButton = GUILayoutUtility.GetLastRect(); Rect optionButton = GUILayoutUtility.GetLastRect();
optionButton.yMin = optionButton.yMax; optionButton.yMin = optionButton.yMax;
optionButton.yMax += EcsGUI.HeadIconsRect.height; optionButton.yMax += DragonGUI.HeadIconsRect.height;
optionButton.xMin = optionButton.xMax - 64; optionButton.xMin = optionButton.xMax - 64;
optionButton.center += Vector2.up * padding * 2f; optionButton.center += Vector2.up * padding * 2f;
//Canceling isExpanded //Canceling isExpanded
if (EcsGUI.ClickTest(optionButton)) if (DragonGUI.ClickTest(optionButton))
{ {
ref bool isExpanded = ref expandMatrix.Down(); ref bool isExpanded = ref expandMatrix.Down();
isExpanded = !isExpanded; isExpanded = !isExpanded;
} }
Color panelColor = EcsGUI.SelectPanelColor(meta, index, total); Color panelColor = DragonGUI.SelectPanelColor(meta, index, total);
using (EcsGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA))) using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA)))
{ {
EditorGUI.BeginChangeCheck(); EditorGUI.BeginChangeCheck();
//Close button //Close button
optionButton.xMin = optionButton.xMax - EcsGUI.HeadIconsRect.width; optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width;
if (EcsGUI.CloseButton(optionButton)) if (DragonGUI.CloseButton(optionButton))
{ {
pool.Del(entityID); pool.Del(entityID);
return; return;
@ -410,14 +410,14 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
//Edit script button //Edit script button
if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script)) if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script))
{ {
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.ScriptAssetButton(optionButton, script); DragonGUI.ScriptAssetButton(optionButton, script);
} }
//Description icon //Description icon
if (string.IsNullOrEmpty(meta.Description.Text) == false) if (string.IsNullOrEmpty(meta.Description.Text) == false)
{ {
optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width));
EcsGUI.DescriptionIcon(optionButton, meta.Description.Text); DragonGUI.DescriptionIcon(optionButton, meta.Description.Text);
} }
RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name); RuntimeComponentReflectionCache.FieldInfoData componentInfoData = new RuntimeComponentReflectionCache.FieldInfoData(null, componentType, meta.Name);
@ -438,7 +438,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
{ {
const int DEPTH_MAX = 24; const int DEPTH_MAX = 24;
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
outData = data; outData = data;
@ -479,7 +479,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
break; break;
case DrawerType.UnitySerializableComposite: case DrawerType.UnitySerializableComposite:
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth); RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth);
wrapper.data = data; wrapper.data = data;
@ -487,7 +487,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
wrapper.IsExpanded = isExpanded; wrapper.IsExpanded = isExpanded;
EditorGUILayout.PropertyField(wrapper.Property, label, true); EditorGUILayout.PropertyField(wrapper.Property, label, true);
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
wrapper.SO.ApplyModifiedProperties(); wrapper.SO.ApplyModifiedProperties();
newData = wrapper.Data; newData = wrapper.Data;
@ -499,7 +499,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
break; break;
case DrawerType.UnityNotSerializableComposite: case DrawerType.UnityNotSerializableComposite:
GUILayout.Space(EcsGUI.Spacing); GUILayout.Space(DragonGUI.Spacing);
var foldoutStyle = EditorStyles.foldout; var foldoutStyle = EditorStyles.foldout;
Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle); Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle);
//rect.xMin += EcsGUI.Indent; //rect.xMin += EcsGUI.Indent;
@ -508,7 +508,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
if (isExpanded) if (isExpanded)
{ {
using (EcsGUI.UpIndentLevel()) using (DragonGUI.UpIndentLevel())
{ {
for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++) for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++)
{ {
@ -526,7 +526,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
break; break;
case DrawerType.UnityObject: case DrawerType.UnityObject:
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
var uobj = UnsafeUtility.As<object, UnityObject>(ref data); var uobj = UnsafeUtility.As<object, UnityObject>(ref data);
bool isComponent = typeof(UnityComponent).IsAssignableFrom(fieldInfoData.FieldType); bool isComponent = typeof(UnityComponent).IsAssignableFrom(fieldInfoData.FieldType);
@ -696,7 +696,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X
} }
expandMatrix.Up(); expandMatrix.Up();
if (childElementChanged || EcsGUI.Changed) if (childElementChanged || DragonGUI.Changed)
{ {
outData = newData; outData = newData;
return true; return true;

View File

@ -52,7 +52,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void OnReorderableListReorder(ReorderableList list) private void OnReorderableListReorder(ReorderableList list)
{ {
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
private SerializedProperty GetTargetProperty(SerializedProperty prop) private SerializedProperty GetTargetProperty(SerializedProperty prop)
@ -84,13 +84,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
private void OnReorderableComponentsListDrawElement(Rect rect, int index, bool isActive, bool isFocused) private void OnReorderableComponentsListDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{ {
if (index < 0 || Event.current.type == EventType.Used) { return; }
SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index); SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index);
GUIContent label = UnityEditorUtility.GetLabelTemp(); GUIContent label = UnityEditorUtility.GetLabelTemp();
rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
EditorGUI.PropertyField(rect, prop, label); EditorGUI.PropertyField(rect, prop, label);
return; return;
//if (index < 0 || Event.current.type == EventType.Used) { return; }
//rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); //rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
//using (EcsGUI.CheckChanged()) //using (EcsGUI.CheckChanged())
//{ //{
@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
list.serializedProperty.arraySize += 1; list.serializedProperty.arraySize += 1;
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues(); list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues();
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
private void OnReorderableListRemove(ReorderableList list) private void OnReorderableListRemove(ReorderableList list)
{ {
@ -158,7 +158,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]); list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]);
} }
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
#endregion #endregion
@ -172,7 +172,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
if (IsSO) if (IsSO)
{ {
EcsGUI.Layout.ManuallySerializeButton(targets); DragonGUI.Layout.ManuallySerializeButton(targets);
} }
if (IsMultipleTargets) if (IsMultipleTargets)
@ -185,17 +185,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
//костыль который насильно заставляет _reorderableComponentsList пересчитать высоту //костыль который насильно заставляет _reorderableComponentsList пересчитать высоту
if (_reorderableComponentsListLastCount != _reorderableComponentsList.count) if (_reorderableComponentsListLastCount != _reorderableComponentsList.count)
{ {
EcsGUI.Changed = true; DragonGUI.Changed = true;
_reorderableComponentsListLastCount = _reorderableComponentsList.count; _reorderableComponentsListLastCount = _reorderableComponentsList.count;
} }
} }
if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target)) if (IsMultipleTargets == false && SerializationUtility.HasManagedReferencesWithMissingTypes(target))
{ {
using (EcsGUI.Layout.BeginHorizontal(EditorStyles.helpBox)) using (DragonGUI.Layout.BeginHorizontal(EditorStyles.helpBox))
{ {
GUILayout.Label(UnityEditorUtility.GetLabel(Icons.Instance.WarningIcon), GUILayout.ExpandWidth(false)); GUILayout.Label(UnityEditorUtility.GetLabel(Icons.Instance.WarningIcon), GUILayout.ExpandWidth(false));
using (EcsGUI.Layout.BeginVertical()) using (DragonGUI.Layout.BeginVertical())
{ {
GUILayout.Label("This object contains SerializeReference types which are missing.", EditorStyles.miniLabel); GUILayout.Label("This object contains SerializeReference types which are missing.", EditorStyles.miniLabel);
if (GUILayout.Button("Repaire References Tool", EditorStyles.miniButton, GUILayout.MaxWidth(200f))) if (GUILayout.Button("Repaire References Tool", EditorStyles.miniButton, GUILayout.MaxWidth(200f)))
@ -209,7 +209,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
SerializedProperty iterator = serializedObject.GetIterator(); SerializedProperty iterator = serializedObject.GetIterator();
iterator.NextVisible(true); iterator.NextVisible(true);
using (EcsGUI.Disable) using (DragonGUI.Disable)
{ {
EditorGUILayout.PropertyField(iterator, true); EditorGUILayout.PropertyField(iterator, true);
} }
@ -230,7 +230,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
EditorGUILayout.PropertyField(_templatesProp, true); EditorGUILayout.PropertyField(_templatesProp, true);
} }
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
DrawTop(_componentTemplatesProp); DrawTop(_componentTemplatesProp);
_reorderableComponentsList.DoLayoutList(); _reorderableComponentsList.DoLayoutList();
@ -240,13 +240,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
GUILayout.Space(2f); GUILayout.Space(2f);
switch (EcsGUI.Layout.AddClearComponentButtons(out Rect rect)) switch (DragonGUI.Layout.AddClearComponentButtons(out Rect rect))
{ {
case EcsGUI.AddClearButton.Add: case DragonGUI.AddClearButton.Add:
Init(); Init();
_componentDropDown.OpenForArray(rect, componentsProp, true); _componentDropDown.OpenForArray(rect, componentsProp, true);
break; break;
case EcsGUI.AddClearButton.Clear: case DragonGUI.AddClearButton.Clear:
Init(); Init();
componentsProp.ClearArray(); componentsProp.ClearArray();
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();

View File

@ -51,9 +51,9 @@ namespace DCFApixels.DragonECS
public abstract void Apply(short worldID, int entityID); public abstract void Apply(short worldID, int entityID);
#endregion #endregion
protected class ComponentTemplateMetaProxy : MetaProxy protected class ComponentTemplateMetaProxy : MetaProxyBase
{ {
protected static TypeMeta Meta; protected TypeMeta Meta;
public override string Name { get { return Meta?.Name; } } public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta?.Color; } } public override MetaColor? Color { get { return Meta?.Color; } }
public override MetaGroup Group { get { return Meta?.Group; } } public override MetaGroup Group { get { return Meta?.Group; } }
@ -61,14 +61,17 @@ namespace DCFApixels.DragonECS
public override IEnumerable<string> Tags { get { return Meta?.Tags; } } public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public ComponentTemplateMetaProxy(Type type) : base(type) public ComponentTemplateMetaProxy(Type type) : base(type)
{ {
if (type.IsGenericType && type.ContainsGenericParameters == false) Meta = null;
var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
foreach (var field in fields)
{ {
var g = type.GetGenericArguments(); if (field.Name == "component")
if (g.Length == 1)
{ {
Meta = g[0].GetMeta(); Meta = field.FieldType.GetMeta();
return;
} }
} }
} }
} }
} }

View File

@ -12,7 +12,7 @@ namespace DCFApixels.DragonECS
{ {
[SerializeReference] [SerializeReference]
[ReferenceDropDown] [ReferenceDropDown]
[TypeMetaBlock] [DragonMetaBlock]
private ITemplateNode _template; private ITemplateNode _template;
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]

View File

@ -26,9 +26,7 @@ namespace DCFApixels.DragonECS
{ {
[SerializeReference] [SerializeReference]
[ReferenceDropDown(true)] [ReferenceDropDown(true)]
[TypeMetaBlock] [DragonMetaBlock]
[FormerlySerializedAs("_components")]
[ArrayElement]
private ITemplateNode[] _componentTemplates; private ITemplateNode[] _componentTemplates;
#region Methods #region Methods

View File

@ -2,6 +2,7 @@
#undef DEBUG #undef DEBUG
#endif #endif
using DCFApixels.DragonECS.Unity; using DCFApixels.DragonECS.Unity;
using DCFApixels.DragonECS.Unity.Internal;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -26,7 +27,7 @@ namespace DCFApixels.DragonECS
private ScriptableEntityTemplateBase[] _templates; private ScriptableEntityTemplateBase[] _templates;
[SerializeReference] [SerializeReference]
[ReferenceDropDown(true)] [ReferenceDropDown(true)]
[FormerlySerializedAs("_components")] [DragonMetaBlock]
private ITemplateNode[] _componentTemplates; private ITemplateNode[] _componentTemplates;
#region Methods #region Methods

View File

@ -62,7 +62,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void OnReorderableListDrawEmptyElement(Rect rect, int index, bool isActive, bool isFocused) { } private void OnReorderableListDrawEmptyElement(Rect rect, int index, bool isActive, bool isFocused) { }
private void OnReorderableListReorder(ReorderableList list) private void OnReorderableListReorder(ReorderableList list)
{ {
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
private void OnReorderableListRemove(ReorderableList list) private void OnReorderableListRemove(ReorderableList list)
{ {
@ -78,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]); list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]);
} }
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
#endregion #endregion
@ -86,11 +86,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
private static readonly HashSet<string> _defaultLayersSet = new HashSet<string>(PipelineTemplateUtility.DefaultLayers); private static readonly HashSet<string> _defaultLayersSet = new HashSet<string>(PipelineTemplateUtility.DefaultLayers);
private void OnReorderableLayersListDrawElement(Rect rect, int index, bool isActive, bool isFocused) private void OnReorderableLayersListDrawElement(Rect rect, int index, bool isActive, bool isFocused)
{ {
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
var elementProp = _layersProp.GetArrayElementAtIndex(index); var elementProp = _layersProp.GetArrayElementAtIndex(index);
string str = elementProp.stringValue; string str = elementProp.stringValue;
using (EcsGUI.SetEnable(_defaultLayersSet.Contains(str) == false)) using (DragonGUI.SetEnable(_defaultLayersSet.Contains(str) == false))
{ {
elementProp.stringValue = EditorGUI.TextField(rect, str); elementProp.stringValue = EditorGUI.TextField(rect, str);
} }
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
var added = list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1); var added = list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1);
added.stringValue = $"Layer-{DateTime.Now.Ticks}"; added.stringValue = $"Layer-{DateTime.Now.Ticks}";
added.serializedObject.ApplyModifiedProperties(); added.serializedObject.ApplyModifiedProperties();
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
#endregion #endregion
@ -111,7 +111,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (index < 0 || Event.current.type == EventType.Used) { return; } if (index < 0 || Event.current.type == EventType.Used) { return; }
rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing);
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
SerializedProperty prop = _recordsProp.GetArrayElementAtIndex(index); SerializedProperty prop = _recordsProp.GetArrayElementAtIndex(index);
var targetProp = prop.FindPropertyRelative(nameof(PipelineTemplateUtility.Record.target)); var targetProp = prop.FindPropertyRelative(nameof(PipelineTemplateUtility.Record.target));
@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
bool isNull = targetProp.managedReferenceValue == null; bool isNull = targetProp.managedReferenceValue == null;
ITypeMeta meta = isNull ? null : targetProp.managedReferenceValue.GetMeta(); ITypeMeta meta = isNull ? null : targetProp.managedReferenceValue.GetMeta();
if (EcsGUI.DrawTypeMetaElementBlock(ref rect, _recordsProp, index, prop, meta).skip) if (DragonGUI.DrawTypeMetaElementBlock(ref rect, _recordsProp, index, prop, meta).skip)
{ {
return; return;
} }
@ -130,14 +130,14 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
float result; float result;
result = EditorGUI.GetPropertyHeight(_recordsProp.GetArrayElementAtIndex(index)); result = EditorGUI.GetPropertyHeight(_recordsProp.GetArrayElementAtIndex(index));
return EcsGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f; return DragonGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f;
} }
private void OnReorderableRecordsListAdd(ReorderableList list) private void OnReorderableRecordsListAdd(ReorderableList list)
{ {
list.serializedProperty.arraySize += 1; list.serializedProperty.arraySize += 1;
list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues(); list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues();
EcsGUI.Changed = true; DragonGUI.Changed = true;
} }
#endregion #endregion
@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (IsSO) if (IsSO)
{ {
EcsGUI.Layout.ManuallySerializeButton(targets); DragonGUI.Layout.ManuallySerializeButton(targets);
} }
if (IsMultipleTargets) if (IsMultipleTargets)
@ -155,13 +155,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
return; return;
} }
EcsGUI.Changed = GUILayout.Button("Validate"); DragonGUI.Changed = GUILayout.Button("Validate");
DrawLayoutNameList(_layersProp); DrawLayoutNameList(_layersProp);
EditorGUILayout.PropertyField(_parametersProp, UnityEditorUtility.GetLabel(_parametersProp.displayName)); EditorGUILayout.PropertyField(_parametersProp, UnityEditorUtility.GetLabel(_parametersProp.displayName));
DrawRecordList(_recordsProp); DrawRecordList(_recordsProp);
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
serializedObject.ApplyModifiedProperties(); serializedObject.ApplyModifiedProperties();
Validate(); Validate();
@ -181,7 +181,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawLayoutNameList(SerializedProperty layersProp) private void DrawLayoutNameList(SerializedProperty layersProp)
{ {
using (EcsGUI.Layout.BeginVertical()) using (DragonGUI.Layout.BeginVertical())
{ {
GUILayout.Label(UnityEditorUtility.GetLabel(layersProp.displayName), EditorStyles.boldLabel); GUILayout.Label(UnityEditorUtility.GetLabel(layersProp.displayName), EditorStyles.boldLabel);
_reorderableLayersList.DoLayoutList(); _reorderableLayersList.DoLayoutList();
@ -190,16 +190,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
private void DrawRecordList(SerializedProperty recordsProp) private void DrawRecordList(SerializedProperty recordsProp)
{ {
GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel); GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel);
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle()))
{ {
GUILayout.Space(4f); GUILayout.Space(4f);
switch (EcsGUI.Layout.AddClearSystemButtons(out Rect dropDownRect)) switch (DragonGUI.Layout.AddClearSystemButtons(out Rect dropDownRect))
{ {
case EcsGUI.AddClearButton.Add: case DragonGUI.AddClearButton.Add:
_systemsDropDown.OpenForArray(dropDownRect, recordsProp); _systemsDropDown.OpenForArray(dropDownRect, recordsProp);
break; break;
case EcsGUI.AddClearButton.Clear: case DragonGUI.AddClearButton.Clear:
recordsProp.ClearArray(); recordsProp.ClearArray();
recordsProp.serializedObject.ApplyModifiedProperties(); recordsProp.serializedObject.ApplyModifiedProperties();
break; break;

View File

@ -21,7 +21,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
using (EcsGUI.SetIndentLevel(IsArrayElement ? EcsGUI.IndentLevel : EcsGUI.IndentLevel + 1)) using (DragonGUI.SetIndentLevel(IsArrayElement ? DragonGUI.IndentLevel : DragonGUI.IndentLevel + 1))
{ {
Rect subPosition = position; Rect subPosition = position;
int depth = -1; int depth = -1;

View File

@ -85,7 +85,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
GUILayout.BeginHorizontal(GUILayout.ExpandHeight(true)); GUILayout.BeginHorizontal(GUILayout.ExpandHeight(true));
MetaGroupInfo selectedGroupInfo; MetaGroupInfo selectedGroupInfo;
using (EcsGUI.Layout.BeginScrollView(ref ButtonsScrolPosition, UnityEditorUtility.GetClearBackgrounStyle(), GUILayout.Width(_buttonsWidth))) using (DragonGUI.Layout.BeginScrollView(ref ButtonsScrolPosition, UnityEditorUtility.GetClearBackgrounStyle(), GUILayout.Width(_buttonsWidth)))
{ {
selectedGroupInfo = DrawGroups(); selectedGroupInfo = DrawGroups();
} }
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -2f); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -2f);
using (EcsGUI.Layout.BeginScrollView(ref DataScrolPosition, UnityEditorUtility.GetTransperentBlackBackgrounStyle(), GUILayout.ExpandWidth(true))) using (DragonGUI.Layout.BeginScrollView(ref DataScrolPosition, UnityEditorUtility.GetTransperentBlackBackgrounStyle(), GUILayout.ExpandWidth(true)))
{ {
DrawSelectedGroupMeta(selectedGroupInfo); DrawSelectedGroupMeta(selectedGroupInfo);
} }
@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
private void DrawToolbar() private void DrawToolbar()
{ {
using (EcsGUI.SetColor(GUI.color * 0.8f)) using (DragonGUI.SetColor(GUI.color * 0.8f))
GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.BeginHorizontal(EditorStyles.toolbar);
GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f);
@ -129,12 +129,12 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
DragonDocsPrefs.instance.Save(docs); DragonDocsPrefs.instance.Save(docs);
} }
if (EcsGUI.Layout.IconButton(IsShowHidden ? Icons.Instance.VisibilityIconOn : Icons.Instance.VisibilityIconOff, 0f, IsShowHidden ? "Show Hidden" : "Don't Show Hidden", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f))) if (DragonGUI.Layout.IconButton(IsShowHidden ? Icons.Instance.VisibilityIconOn : Icons.Instance.VisibilityIconOff, 0f, IsShowHidden ? "Show Hidden" : "Don't Show Hidden", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{ {
IsShowHidden = !IsShowHidden; IsShowHidden = !IsShowHidden;
} }
if (EcsGUI.Layout.IconButton(IsUseCustomNames ? Icons.Instance.LabelIconMeta : Icons.Instance.LabelIconType, 1f, IsUseCustomNames ? "Use Meta Name" : "Use Type Name", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f))) if (DragonGUI.Layout.IconButton(IsUseCustomNames ? Icons.Instance.LabelIconMeta : Icons.Instance.LabelIconType, 1f, IsUseCustomNames ? "Use Meta Name" : "Use Type Name", EditorStyles.toolbarButton, GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{ {
IsUseCustomNames = !IsUseCustomNames; IsUseCustomNames = !IsUseCustomNames;
} }
@ -147,7 +147,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
_searchingSampleChanged = true; _searchingSampleChanged = true;
} }
if ((_searchingSampleChanged && Event.current.keyCode == KeyCode.Return) || if ((_searchingSampleChanged && Event.current.keyCode == KeyCode.Return) ||
EcsGUI.Layout.IconButton(Icons.Instance.SearchIcon, 1f, null, EditorStyles.toolbarButton, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f))) DragonGUI.Layout.IconButton(Icons.Instance.SearchIcon, 1f, null, EditorStyles.toolbarButton, GUILayout.ExpandHeight(true), GUILayout.Width(EditorGUIUtility.singleLineHeight * 1.6f)))
{ {
Searh(); Searh();
} }
@ -246,29 +246,29 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
private void DrawMeta(DragonDocsMeta meta, int index, int total) private void DrawMeta(DragonDocsMeta meta, int index, int total)
{ {
using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.SetIndentLevel(0))
{ {
Color panelColor = EcsGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE); Color panelColor = DragonGUI.SelectPanelColor(meta.Color.ToMetaColor(), meta.IsCustomColor, index, total).Desaturate(EscEditorConsts.COMPONENT_DRAWER_DESATURATE);
Color alphaPanelColor = panelColor; Color alphaPanelColor = panelColor;
alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA; alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA;
using (EcsGUI.Layout.BeginVertical(alphaPanelColor)) using (DragonGUI.Layout.BeginVertical(alphaPanelColor))
{ {
GUILayout.Space(1f); GUILayout.Space(1f);
//draw title block //draw title block
using (EcsGUI.Layout.BeginHorizontal()) using (DragonGUI.Layout.BeginHorizontal())
{ {
GUILayout.TextArea(IsUseCustomNames ? meta.Name : meta.TypeName, EditorStyles.boldLabel, GUILayout.ExpandWidth(false)); GUILayout.TextArea(IsUseCustomNames ? meta.Name : meta.TypeName, EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
if (meta.TryGetSourceType(out System.Type targetType) && ScriptsCache.TryGetScriptAsset(targetType.GetMeta(), out MonoScript script)) if (meta.TryGetSourceType(out System.Type targetType) && ScriptsCache.TryGetScriptAsset(targetType.GetMeta(), out MonoScript script))
{ {
EcsGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f)); DragonGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f));
} }
if (meta.IsCustomName) if (meta.IsCustomName)
{ {
using (EcsGUI.SetAlpha(0.64f)) using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight)) using (DragonGUI.SetAlpha(0.64f)) using (DragonGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleRight))
{ {
GUILayout.TextArea(IsUseCustomNames ? meta.TypeName : meta.Name, GUI.skin.label); GUILayout.TextArea(IsUseCustomNames ? meta.TypeName : meta.Name, GUI.skin.label);
} }
@ -282,7 +282,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
if (string.IsNullOrEmpty(meta.MetaID) == false) if (string.IsNullOrEmpty(meta.MetaID) == false)
{ {
GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing); GUILayout.Space(-EditorGUIUtility.standardVerticalSpacing);
EcsGUI.Layout.CopyMetaIDButton(meta.MetaID, GUILayout.Width(18f)); DragonGUI.Layout.CopyMetaIDButton(meta.MetaID, GUILayout.Width(18f));
} }
} }
@ -315,7 +315,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
GUILayout.Space(3f); GUILayout.Space(3f);
var tagsstring = string.Join(',', meta._tags); var tagsstring = string.Join(',', meta._tags);
using (EcsGUI.SetAlpha(0.5f)) using (DragonGUI.SetAlpha(0.5f))
{ {
GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel); GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel);
} }
@ -333,7 +333,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
var infos = Prefs.Infos; var infos = Prefs.Infos;
var isExpands = Prefs.IsExpands; var isExpands = Prefs.IsExpands;
using (EcsGUI.SetIndentLevel(0)) using (DragonGUI.SetIndentLevel(0))
{ {
int clippingDepth = int.MaxValue; int clippingDepth = int.MaxValue;
@ -363,7 +363,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
if (_searchingSample.Length == 0) if (_searchingSample.Length == 0)
{ {
EcsGUI.IndentLevel = groupInfo.Depth; DragonGUI.IndentLevel = groupInfo.Depth;
} }
GUIContent label = UnityEditorUtility.GetLabel(_searchingSample.Length == 0 ? groupInfo.Name : groupInfo.Path); GUIContent label = UnityEditorUtility.GetLabel(_searchingSample.Length == 0 ? groupInfo.Name : groupInfo.Path);
@ -374,10 +374,10 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
EditorGUI.DrawRect(r, new Color(0.12f, 0.5f, 1f, 0.40f)); EditorGUI.DrawRect(r, new Color(0.12f, 0.5f, 1f, 0.40f));
} }
using (EcsGUI.SetColor(0, 0, 0, 0)) using (EcsGUI.Disable) { GUI.Button(r, ""); } using (DragonGUI.SetColor(0, 0, 0, 0)) using (DragonGUI.Disable) { GUI.Button(r, ""); }
bool isClick = false; bool isClick = false;
if (EcsGUI.HitTest(r)) if (DragonGUI.HitTest(r))
{ {
EditorGUI.DrawRect(r, new Color(1f, 1f, 1f, 0.12f)); EditorGUI.DrawRect(r, new Color(1f, 1f, 1f, 0.12f));
if (current.type == EventType.MouseUp) if (current.type == EventType.MouseUp)
@ -391,7 +391,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
if (_searchingSample.Length != 0 || (i + 1 == infos.Length || infos[i + 1].Depth <= groupInfo.Depth)) if (_searchingSample.Length != 0 || (i + 1 == infos.Length || infos[i + 1].Depth <= groupInfo.Depth))
{ {
using (EcsGUI.SetBackgroundColor(0, 0, 0, 0)) using (DragonGUI.SetBackgroundColor(0, 0, 0, 0))
{ {
EditorGUI.Foldout(r, false, label, EditorStyles.foldout); EditorGUI.Foldout(r, false, label, EditorStyles.foldout);
} }
@ -451,7 +451,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
switch (current.type) switch (current.type)
{ {
case EventType.MouseDown: case EventType.MouseDown:
if (EcsGUI.HitTest(rect)) if (DragonGUI.HitTest(rect))
{ {
_buttonsWidthDragStartPos = current.mousePosition; _buttonsWidthDragStartPos = current.mousePosition;
_buttonsWidthDragStartValue = _buttonsWidth; _buttonsWidthDragStartValue = _buttonsWidth;

View File

@ -61,7 +61,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
if (index < 0 || index >= _cachedMissingsResolvingDatas.Length) { return; } if (index < 0 || index >= _cachedMissingsResolvingDatas.Length) { return; }
ref var data = ref _cachedMissingsResolvingDatas[index]; ref var data = ref _cachedMissingsResolvingDatas[index];
using (EcsGUI.SetAlpha(0)) using (DragonGUI.SetAlpha(0))
{ {
if (GUI.Button(rect, "")) if (GUI.Button(rect, ""))
{ {
@ -75,7 +75,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
{ {
EditorGUI.DrawRect(rect, _activedColor); EditorGUI.DrawRect(rect, _activedColor);
} }
if (EcsGUI.HitTest(rect)) if (DragonGUI.HitTest(rect))
{ {
EditorGUI.DrawRect(rect, _dragColor); EditorGUI.DrawRect(rect, _dragColor);
} }
@ -122,7 +122,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
GUI.Label(nameRect, name); GUI.Label(nameRect, name);
EditorGUI.DrawRect(oldRect, new Color(0, 0, 0, 0.16f)); EditorGUI.DrawRect(oldRect, new Color(0, 0, 0, 0.16f));
GUI.Label(oldRect, oldStr); GUI.Label(oldRect, oldStr);
using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter)) using (DragonGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter))
{ {
GUI.Label(arrowRect, "->"); GUI.Label(arrowRect, "->");
} }
@ -160,16 +160,16 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
_panel = new GUIStyle(); _panel = new GUIStyle();
_panel.padding = new RectOffset(5, 5, 5, 5); _panel.padding = new RectOffset(5, 5, 5, 5);
} }
using (EcsGUI.Layout.BeginVertical(_panel)) using (DragonGUI.Layout.BeginVertical(_panel))
{ {
const string LIST_EMPTY_MESSAGE = "List of Missings is Empty"; const string LIST_EMPTY_MESSAGE = "List of Missings is Empty";
const string COLLECT_BUTTON = "Collect Missings"; const string COLLECT_BUTTON = "Collect Missings";
if (_missingRefContainer.IsEmpty) if (_missingRefContainer.IsEmpty)
{ {
GUILayout.Label("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); GUILayout.Label("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
using (EcsGUI.SetFontSize(14)) using (DragonGUI.SetFontSize(14))
using (EcsGUI.SetFontSize(GUI.skin.button, 14)) using (DragonGUI.SetFontSize(GUI.skin.button, 14))
using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter)) using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter))
{ {
Vector2 center = GUILayoutUtility.GetLastRect().center; Vector2 center = GUILayoutUtility.GetLastRect().center;
Vector2 labelSize = GUI.skin.label.CalcSize(UnityEditorUtility.GetLabel(LIST_EMPTY_MESSAGE)); Vector2 labelSize = GUI.skin.label.CalcSize(UnityEditorUtility.GetLabel(LIST_EMPTY_MESSAGE));
@ -184,7 +184,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
r = new Rect(Vector2.zero, buttonSize); r = new Rect(Vector2.zero, buttonSize);
r.center = center; r.center = center;
r.y += buttonSize.y / 2f; r.y += buttonSize.y / 2f;
if (Event.current.type == EventType.MouseDown && EcsGUI.HitTest(r)) if (Event.current.type == EventType.MouseDown && DragonGUI.HitTest(r))
{ {
_isNoFound = false; _isNoFound = false;
} }
@ -222,8 +222,8 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
InitList(); InitList();
} }
var bc = EcsGUI.SetBackgroundColor(Color.black, 0.5f); var bc = DragonGUI.SetBackgroundColor(Color.black, 0.5f);
using (EcsGUI.Layout.BeginVertical(EditorStyles.helpBox)) using (DragonGUI.Layout.BeginVertical(EditorStyles.helpBox))
{ {
bc.Dispose(); bc.Dispose();
_scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true)); _scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true));
@ -232,7 +232,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
} }
GUILayout.Space(4f); GUILayout.Space(4f);
using (EcsGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false))) using (DragonGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false)))
{ {
//GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false)); //GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false));
@ -245,14 +245,14 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
if (data == null) if (data == null)
{ {
using (EcsGUI.SetAlignment(TextAnchor.MiddleCenter)) using (DragonGUI.SetAlignment(TextAnchor.MiddleCenter))
{ {
GUI.Label(rect, "Select any record"); GUI.Label(rect, "Select any record");
} }
} }
else else
{ {
using (EcsGUI.CheckChanged()) using (DragonGUI.CheckChanged())
{ {
rect.height = EditorGUIUtility.singleLineHeight; rect.height = EditorGUIUtility.singleLineHeight;
rect = rect.Move(0, EditorGUIUtility.standardVerticalSpacing); rect = rect.Move(0, EditorGUIUtility.standardVerticalSpacing);
@ -261,7 +261,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
string NamespaceName = DrawEditableLine(rect, "Namespace:", data.OldTypeData.NamespaceName, data.NewTypeData.NamespaceName); string NamespaceName = DrawEditableLine(rect, "Namespace:", data.OldTypeData.NamespaceName, data.NewTypeData.NamespaceName);
rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing);
string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName); string AssemblyName = DrawEditableLine(rect, "Assembly:", data.OldTypeData.AssemblyName, data.NewTypeData.AssemblyName);
if (EcsGUI.Changed) if (DragonGUI.Changed)
{ {
data.NewTypeData = new Internal.TypeData(ClassName, NamespaceName, AssemblyName); data.NewTypeData = new Internal.TypeData(ClassName, NamespaceName, AssemblyName);
} }
@ -269,7 +269,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors
} }
} }
using (EcsGUI.Layout.BeginHorizontal(GUILayout.Height(26f))) using (DragonGUI.Layout.BeginHorizontal(GUILayout.Height(26f)))
{ {
if (GUILayout.Button("Re-Collect", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false))) if (GUILayout.Button("Re-Collect", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false)))
{ {

View File

@ -31,7 +31,7 @@ namespace DCFApixels.DragonECS
Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal)); Array.Sort(predicateTypes, (a, b) => string.Compare(a.AssemblyQualifiedName, b.AssemblyQualifiedName, StringComparison.Ordinal));
} }
} }
public sealed class TypeMetaBlockAttribute : PropertyAttribute { } public sealed class DragonMetaBlockAttribute : PropertyAttribute { }
} }
@ -41,8 +41,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
using UnityEditor; using UnityEditor;
[CustomPropertyDrawer(typeof(ReferenceDropDownAttribute), true)] [CustomPropertyDrawer(typeof(ReferenceDropDownAttribute), true)]
[CustomPropertyDrawer(typeof(TypeMetaBlockAttribute), true)] [CustomPropertyDrawer(typeof(DragonMetaBlockAttribute), true)]
internal class EcsDragonFieldDrawer : ExtendedPropertyDrawer internal class DragonFieldDrawer : ExtendedPropertyDrawer
{ {
private const float DamagedComponentHeight = 18f * 2f; private const float DamagedComponentHeight = 18f * 2f;
private DragonFieldDropDown _dropDown; private DragonFieldDropDown _dropDown;
@ -50,13 +50,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
private ReferenceDropDownAttribute ReferenceDropDownAttribute; private ReferenceDropDownAttribute ReferenceDropDownAttribute;
private ReferenceDropDownWithoutAttribute ReferenceDropDownWithoutAttribute; private ReferenceDropDownWithoutAttribute ReferenceDropDownWithoutAttribute;
private TypeMetaBlockAttribute TypeMetaBlockAttribute; private DragonMetaBlockAttribute TypeMetaBlockAttribute;
private bool _isInit = false; private bool _isInit = false;
private bool _hasSerializableData; private bool _hasSerializableData;
// this is a damn hack to prevent the drawer from being called recursively when multiple attributes are attached to it // this is a damn hack to prevent the drawer from being called recursively when multiple attributes are attached to it
private static GUIContent _unrecursiveLable; private static GUIContent _unrecursiveLabel;
#region Properties #region Properties
private float Padding => Spacing; private float Padding => Spacing;
@ -68,9 +68,9 @@ namespace DCFApixels.DragonECS.Unity.Editors
#region Init #region Init
protected override void OnStaticInit() protected override void OnStaticInit()
{ {
if(_unrecursiveLable == null) if(_unrecursiveLabel == null)
{ {
_unrecursiveLable = new GUIContent(); _unrecursiveLabel = new GUIContent();
} }
} }
protected override void OnInit(SerializedProperty property) protected override void OnInit(SerializedProperty property)
@ -78,6 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
PredicateTypesKey key; PredicateTypesKey key;
_hasSerializableData = true; _hasSerializableData = true;
if (fieldInfo != null) if (fieldInfo != null)
{ {
if (property.propertyType == SerializedPropertyType.ManagedReference) if (property.propertyType == SerializedPropertyType.ManagedReference)
@ -90,14 +91,13 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
case ReferenceDropDownAttribute atr: ReferenceDropDownAttribute = atr; break; case ReferenceDropDownAttribute atr: ReferenceDropDownAttribute = atr; break;
case ReferenceDropDownWithoutAttribute atr: ReferenceDropDownWithoutAttribute = atr; break; case ReferenceDropDownWithoutAttribute atr: ReferenceDropDownWithoutAttribute = atr; break;
case TypeMetaBlockAttribute atr: TypeMetaBlockAttribute = atr; break; case DragonMetaBlockAttribute atr: TypeMetaBlockAttribute = atr; break;
} }
} }
} }
if (_predicateOverride == null && fieldInfo != null) if (_predicateOverride == null && PropertyType != null)
{ {
var targetType = PropertyType;
var targetType = fieldInfo.FieldType;
if (ReferenceDropDownAttribute != null) if (ReferenceDropDownAttribute != null)
{ {
Type[] withOutTypes = ReferenceDropDownWithoutAttribute != null ? ReferenceDropDownWithoutAttribute.PredicateTypes : Type.EmptyTypes; Type[] withOutTypes = ReferenceDropDownWithoutAttribute != null ? ReferenceDropDownWithoutAttribute.PredicateTypes : Type.EmptyTypes;
@ -149,16 +149,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
currentProperty.isExpanded = false; currentProperty.isExpanded = false;
} }
currentProperty.serializedObject.ApplyModifiedProperties(); currentProperty.serializedObject.ApplyModifiedProperties();
EcsGUI.DelayedChanged = true; DragonGUI.DelayedChanged = true;
} }
#endregion #endregion
protected override float GetCustomHeight(SerializedProperty property, GUIContent label) protected override float GetCustomHeight(SerializedProperty property, GUIContent label)
{ {
if (ReferenceEquals(_unrecursiveLable, label)) { return EditorGUI.GetPropertyHeight(property, label); } if (ReferenceEquals(_unrecursiveLabel, label)) { return EditorGUI.GetPropertyHeight(property, label); }
_unrecursiveLable.text = label.text; _unrecursiveLabel.text = label.text;
_unrecursiveLable.tooltip = label.tooltip; _unrecursiveLabel.tooltip = label.tooltip;
label = _unrecursiveLable; label = _unrecursiveLabel;
//if (CheckSkip()) { return EditorGUI.GetPropertyHeight(property, label); } //if (CheckSkip()) { return EditorGUI.GetPropertyHeight(property, label); }
bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference; bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
@ -221,10 +221,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
protected override void DrawCustom(Rect rect, SerializedProperty property, GUIContent label) protected override void DrawCustom(Rect rect, SerializedProperty property, GUIContent label)
{ {
if (ReferenceEquals(_unrecursiveLable, label)) { EditorGUI.PropertyField(rect, property, label, true); return; } if (ReferenceEquals(_unrecursiveLabel, label)) { EditorGUI.PropertyField(rect, property, label, true); return; }
_unrecursiveLable.text = label.text; _unrecursiveLabel.text = label.text;
_unrecursiveLable.tooltip = label.tooltip; _unrecursiveLabel.tooltip = label.tooltip;
label = _unrecursiveLable; label = _unrecursiveLabel;
//if (CheckSkip()) { EditorGUI.PropertyField(rect, property, label, true); return; } //if (CheckSkip()) { EditorGUI.PropertyField(rect, property, label, true); return; }
bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference; bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
@ -236,6 +236,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
bool isDrawProperty = true; bool isDrawProperty = true;
bool isDrawDropDown = IsDrawDropDown && isSerializeReference; bool isDrawDropDown = IsDrawDropDown && isSerializeReference;
Rect srcRect = rect;
if (isSerializeReference) if (isSerializeReference)
{ {
var template = property.managedReferenceValue; var template = property.managedReferenceValue;
@ -295,7 +296,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
if (IsDrawMetaBlock) if (IsDrawMetaBlock)
{ {
ref var r = ref rect; ref var r = ref rect;
var (skip, optionsWidth) = EcsGUI.DrawTypeMetaBlock(ref r, rootProperty, meta); var (skip, optionsWidth) = DragonGUI.DrawTypeMetaBlock(ref r, rootProperty, meta);
selectionButtonRightOffset = optionsWidth; selectionButtonRightOffset = optionsWidth;
if (skip) if (skip)
{ {
@ -339,7 +340,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
var labelRect = rect; var labelRect = rect;
labelRect.width = EditorGUIUtility.labelWidth; labelRect.width = EditorGUIUtility.labelWidth;
labelRect.xMin -= 20f; labelRect.xMin -= 20f;
if (e.type == EventType.Used && EcsGUI.HitTest(labelRect, e) == false) if (e.type == EventType.Used && DragonGUI.HitTest(labelRect, e) == false)
{ {
e.type = et; e.type = et;
} }
@ -350,15 +351,11 @@ namespace DCFApixels.DragonECS.Unity.Editors
EditorGUI.LabelField(rect, label); EditorGUI.LabelField(rect, label);
} }
if (isDrawDropDown) if (isDrawDropDown)
{ {
rect.xMax -= selectionButtonRightOffset; srcRect.xMax -= selectionButtonRightOffset;
DrawSelectionDropDown(rect, property, label); DrawSelectionDropDown(srcRect, property, label);
} }
} }
@ -369,8 +366,19 @@ namespace DCFApixels.DragonECS.Unity.Editors
{ {
if (rect.width < 0) { return; } if (rect.width < 0) { return; }
var position = IsArrayElement ? rect : rect.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f); bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference;
Rect position;
if (string.IsNullOrEmpty(label.text))
{
position = rect;
}
else
{
position = rect.AddPadding(EditorGUIUtility.labelWidth, 0f, 0f, 0f);
}
position.height = OneLineHeight; position.height = OneLineHeight;
position.y += Spacing * 2;
bool isHideButtonIfNotNull = ReferenceDropDownAttribute.IsHideButtonIfNotNull; bool isHideButtonIfNotNull = ReferenceDropDownAttribute.IsHideButtonIfNotNull;
object obj = property.hasMultipleDifferentValues ? null : property.managedReferenceValue; object obj = property.hasMultipleDifferentValues ? null : property.managedReferenceValue;