diff --git a/src/Buildin/Editor/EcsRootUnityEditor.cs b/src/Buildin/Editor/EcsRootUnityEditor.cs index d7e7a55..453ff7b 100644 --- a/src/Buildin/Editor/EcsRootUnityEditor.cs +++ b/src/Buildin/Editor/EcsRootUnityEditor.cs @@ -83,7 +83,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawTemplates() { - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { var iterator = serializedObject.GetIterator(); iterator.NextVisible(true); @@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS.Unity.Editors EditorGUILayout.PropertyField(iterator, true); } - if (EcsGUI.Changed) + if (DragonGUI.Changed) { serializedObject.ApplyModifiedProperties(); } @@ -102,12 +102,12 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawControlButtons() { - float height = EcsGUI.EntityBarHeight; + float height = DragonGUI.EntityBarHeight; Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); rect = rect.AddPadding(2f, 0f); var (_, buttonRect) = rect.HorizontalSliceRight(height); - if (EcsGUI.ValidateButton(buttonRect)) + if (DragonGUI.ValidateButton(buttonRect)) { foreach (var target in Targets) { @@ -115,7 +115,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } } buttonRect = RectUtility.Move(buttonRect, -height, 0); - if (EcsGUI.AutosetButton(buttonRect)) + if (DragonGUI.AutosetButton(buttonRect)) { foreach (var target in Targets) { diff --git a/src/Connectors/EcsEntityConnect.cs b/src/Connectors/EcsEntityConnect.cs index ecf9a13..6a4d3f4 100644 --- a/src/Connectors/EcsEntityConnect.cs +++ b/src/Connectors/EcsEntityConnect.cs @@ -137,7 +137,7 @@ namespace DCFApixels.DragonECS _entity = entity; _world = world; #if UNITY_EDITOR - world.Get().SetConnectLink(entity.GetIDUnchecked(), this); + world.Get().SetConnectLink(entity.GetIDUnchecked(), this); #endif _connectedEntities.Add(GetInstanceID(), this); var goConnects = world.GetPool(); diff --git a/src/Connectors/Editor/AutoEntityCreatorEditor.cs b/src/Connectors/Editor/AutoEntityCreatorEditor.cs index 00873f5..cecc217 100644 --- a/src/Connectors/Editor/AutoEntityCreatorEditor.cs +++ b/src/Connectors/Editor/AutoEntityCreatorEditor.cs @@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { EditorGUILayout.PropertyField(iterator, true); } - if (EcsGUI.Changed) + if (DragonGUI.Changed) { serializedObject.ApplyModifiedProperties(); } @@ -27,7 +27,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawControlButtons() { - float height = EcsGUI.EntityBarHeight; + float height = DragonGUI.EntityBarHeight; Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); rect = rect.AddPadding(2f, 0f); @@ -36,7 +36,7 @@ namespace DCFApixels.DragonECS.Unity.Editors //var (left, autosetCascadeRect) = rect.HorizontalSliceRight(height); //var (_, autosetRect) = rect.HorizontalSliceRight(height); - if (EcsGUI.AutosetCascadeButton(buttonRect)) + if (DragonGUI.AutosetCascadeButton(buttonRect)) { foreach (AutoEntityCreator target in targets) { @@ -44,17 +44,17 @@ namespace DCFApixels.DragonECS.Unity.Editors } } buttonRect = buttonRect.Move(-height, 0); - if (EcsGUI.AutosetButton(buttonRect)) + if (DragonGUI.AutosetButton(buttonRect)) { foreach (AutoEntityCreator target in targets) { target.Autoset_Editor(); } } - using (EcsGUI.SetEnable(Application.isPlaying)) + using (DragonGUI.SetEnable(Application.isPlaying)) { buttonRect = buttonRect.Move(-height, 0); - if (EcsGUI.NewEntityButton(buttonRect)) + if (DragonGUI.NewEntityButton(buttonRect)) { foreach (AutoEntityCreator target in targets) { diff --git a/src/Connectors/Editor/EcsEntityConnectEditor.cs b/src/Connectors/Editor/EcsEntityConnectEditor.cs index 1416cb1..027295b 100644 --- a/src/Connectors/Editor/EcsEntityConnectEditor.cs +++ b/src/Connectors/Editor/EcsEntityConnectEditor.cs @@ -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); //EcsGUI.EntityStatus status = IsMultipleTargets ? EcsGUI.EntityStatus.Undefined : isConnected ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive; //EcsGUI.Layout.EntityField(status, id, gen, worldID); - EcsGUI.Layout.EntityField(Target.Entity); + DragonGUI.Layout.EntityField(Target.Entity); } private void DrawTemplates() { - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { var iterator = serializedObject.GetIterator(); iterator.NextVisible(true); @@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors EditorGUILayout.PropertyField(iterator, true); } - if (EcsGUI.Changed) + if (DragonGUI.Changed) { serializedObject.ApplyModifiedProperties(); } @@ -47,12 +47,12 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawControlButtons() { - float height = EcsGUI.EntityBarHeight; + float height = DragonGUI.EntityBarHeight; Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.currentViewWidth, height); EditorGUI.DrawRect(rect, new Color(0f, 0f, 0f, 0.1f)); rect = rect.AddPadding(2f, 0f); var (_, buttonRect) = rect.HorizontalSliceRight(height); - if (EcsGUI.AutosetCascadeButton(buttonRect)) + if (DragonGUI.AutosetCascadeButton(buttonRect)) { foreach (var target in Targets) { @@ -60,17 +60,17 @@ namespace DCFApixels.DragonECS.Unity.Editors } } buttonRect = RectUtility.Move(buttonRect, -height, 0); - if (EcsGUI.AutosetButton(buttonRect)) + if (DragonGUI.AutosetButton(buttonRect)) { foreach (var target in Targets) { target.Autoset_Editor(); } } - using (EcsGUI.SetEnable(Application.isPlaying)) + using (DragonGUI.SetEnable(Application.isPlaying)) { buttonRect = buttonRect.Move(-height, 0); - if (EcsGUI.DelEntityButton(buttonRect)) + if (DragonGUI.DelEntityButton(buttonRect)) { foreach (var target in Targets) { @@ -78,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } } buttonRect = buttonRect.Move(-height, 0); - if (EcsGUI.UnlinkButton(buttonRect)) + if (DragonGUI.UnlinkButton(buttonRect)) { foreach (var target in Targets) { @@ -105,7 +105,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { if (world.IsNullOrDetroyed() == false) { - EcsGUI.Layout.DrawRuntimeComponents(entityID, world, true, true); + DragonGUI.Layout.DrawRuntimeComponents(entityID, world, true, true); } } } diff --git a/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs b/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs index b10c1a0..254bbba 100644 --- a/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs +++ b/src/Connectors/Editor/EcsWorldProviderBaseEditor.cs @@ -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)); } - EcsGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw()); + DragonGUI.Layout.DrawWorldBaseInfo(Target.GetCurrentWorldRaw()); base.OnInspectorGUI(); @@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS.Unity.Editors EditorGUI.DrawRect(r, c); GUILayout.Space(10); - EcsGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw()); + DragonGUI.Layout.DrawWorldComponents(Target.GetCurrentWorldRaw()); } } } diff --git a/src/DebugUtils/Editor/EntlongDrawer.cs b/src/DebugUtils/Editor/EntlongDrawer.cs index c178b96..1132815 100644 --- a/src/DebugUtils/Editor/EntlongDrawer.cs +++ b/src/DebugUtils/Editor/EntlongDrawer.cs @@ -55,11 +55,11 @@ namespace DCFApixels.DragonECS.Unity.Editors if (drawFoldout && isExpanded) { - using (EcsGUI.UpIndentLevel()) + using (DragonGUI.UpIndentLevel()) { 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) { heightCache = GUILayoutUtility.GetLastRect().height; @@ -67,10 +67,10 @@ namespace DCFApixels.DragonECS.Unity.Editors } } } - EcsGUI.EntityField(position, property); - using (EcsGUI.SetEnable(world != null)) + DragonGUI.EntityField(position, property); + 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.activeControlID = 0; } diff --git a/src/DebugUtils/Editor/SettingsEditor.cs b/src/DebugUtils/Editor/SettingsEditor.cs index 22b7045..889425c 100644 --- a/src/DebugUtils/Editor/SettingsEditor.cs +++ b/src/DebugUtils/Editor/SettingsEditor.cs @@ -33,7 +33,7 @@ namespace DCFApixels.DragonECS.Unity.Editors //float checkBoxWidth = 20f; GUILayout.Space(20f); - using (new EcsGUI.ColorScope(Color.white * 0.5f)) + using (new DragonGUI.ColorScope(Color.white * 0.5f)) GUILayout.BeginVertical(EditorStyles.helpBox); //using (new EcsGUI.ColorScope(Color.white * 1.2f)) GUILayout.Label("", EditorStyles.toolbar, GUILayout.ExpandWidth(true), GUILayout.Height(22f)); @@ -69,7 +69,7 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.EndVertical(); GUILayout.Space(20f); - using (EcsGUI.SetColor(Color.white * 0.5f)) + using (DragonGUI.SetColor(Color.white * 0.5f)) { GUILayout.BeginVertical(EditorStyles.helpBox); } diff --git a/src/DebugUtils/Monitors/Editor/EntityMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/EntityMonitorEditor.cs index f794872..19cb5d3 100644 --- a/src/DebugUtils/Monitors/Editor/EntityMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/EntityMonitorEditor.cs @@ -12,7 +12,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { var entity = Target.Entity; 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))) { @@ -20,18 +20,18 @@ namespace DCFApixels.DragonECS.Unity.Editors } } //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; if (drawers.Length > 0) { - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { bool isExpand = false; - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data"); - if (EcsGUI.Changed) + if (DragonGUI.Changed) { UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand; } @@ -48,7 +48,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } - EcsGUI.Layout.DrawRuntimeComponents(entity, false); + DragonGUI.Layout.DrawRuntimeComponents(entity, false); } } } diff --git a/src/DebugUtils/Monitors/Editor/PipelineMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/PipelineMonitorEditor.cs index 3c1c2ca..c2cfcca 100644 --- a/src/DebugUtils/Monitors/Editor/PipelineMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/PipelineMonitorEditor.cs @@ -41,7 +41,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } 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}"; } @@ -71,7 +71,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _headerStyle.fontSize = 28; } - using (EcsGUI.Layout.BeginHorizontal()) + using (DragonGUI.Layout.BeginHorizontal()) { GUILayout.Label("[Systems]", _headerStyle, GUILayout.ExpandWidth(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); IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden); - using (EcsGUI.Layout.BeginVertical()) + using (DragonGUI.Layout.BeginVertical()) { int i = 0; foreach (var item in Target.Pipeline.AllSystems) @@ -95,7 +95,7 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.Label("[Runners]", _headerStyle); - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { int i = 0; foreach (var item in Target.Pipeline.AllRunners) @@ -114,13 +114,13 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.EndVertical(); 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; GUILayout.Label("<", GUILayout.ExpandWidth(true)); scope.Target.alignment = TextAnchor.UpperRight; - using (EcsGUI.SetAlpha(0.64f)) + using (DragonGUI.SetAlpha(0.64f)) { GUILayout.Label($"{markerSystem.layerNameSpace}", GUILayout.ExpandWidth(false)); } @@ -128,7 +128,7 @@ namespace DCFApixels.DragonECS.Unity.Editors GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * -4f); 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)); } @@ -147,10 +147,10 @@ namespace DCFApixels.DragonECS.Unity.Editors } 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) { @@ -168,9 +168,9 @@ namespace DCFApixels.DragonECS.Unity.Editors { 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(string.Join(", ", runner.ProcessRaw.Cast().Select(o => o.GetType().Name)), systemsListStyle); diff --git a/src/DebugUtils/Monitors/Editor/PipelineProcessesMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/PipelineProcessesMonitorEditor.cs index 751b026..f4efc58 100644 --- a/src/DebugUtils/Monitors/Editor/PipelineProcessesMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/PipelineProcessesMonitorEditor.cs @@ -61,10 +61,10 @@ namespace DCFApixels.DragonECS.Unity.Editors protected override void DrawCustom() { - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden); - if (EcsGUI.Changed) + if (DragonGUI.Changed) { Init(); } @@ -104,7 +104,7 @@ namespace DCFApixels.DragonECS.Unity.Editors color = NormalizeGridColor(i, color); EditorGUI.DrawRect(lineRect, color); - if (EcsGUI.HitTest(lineRect)) + if (DragonGUI.HitTest(lineRect)) { GUI.Button(lineRect, "", EditorStyles.selectionRect); _selectedPointMeta.process = meta; @@ -135,7 +135,7 @@ namespace DCFApixels.DragonECS.Unity.Editors color = NormalizeGridColor(i, color); EditorGUI.DrawRect(lineRect, color); - if (EcsGUI.HitTest(lineRect)) + if (DragonGUI.HitTest(lineRect)) { GUI.Button(lineRect, "", EditorStyles.selectionRect); _selectedPointMeta.system = meta; diff --git a/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs index 88e1e8d..e2fab01 100644 --- a/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/WorldMonitorEditor.cs @@ -107,7 +107,7 @@ namespace DCFApixels.DragonECS.Unity.Editors _headerStyle.fontSize = 28; } - using (EcsGUI.Layout.BeginHorizontal()) + using (DragonGUI.Layout.BeginHorizontal()) { GUILayout.Label("[World]", _headerStyle, GUILayout.ExpandWidth(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); } } } diff --git a/src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs b/src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs index bafc311..b26e510 100644 --- a/src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs +++ b/src/DebugUtils/Monitors/Editor/WorldQueriesMonitorEditor.cs @@ -185,7 +185,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } var executors = Target.MaskQueryExecutors; - using (EcsGUI.Layout.BeginHorizontal()) + using (DragonGUI.Layout.BeginHorizontal()) { GUILayout.Label("[Queries]", _headerStyle, GUILayout.ExpandWidth(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.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { var mask = executor.Mask; DrawConstraint("+", mask.Incs); @@ -294,24 +294,24 @@ namespace DCFApixels.DragonECS.Unity.Editors return; } - using (EcsGUI.Layout.BeginHorizontal()) + using (DragonGUI.Layout.BeginHorizontal()) { - using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter)) - using (EcsGUI.SetFontStyle(value: FontStyle.Bold)) - using (EcsGUI.SetFontSize(value: 18)) - using (EcsGUI.SetColor(Color.white, 0.3f)) + using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter)) + using (DragonGUI.SetFontStyle(value: FontStyle.Bold)) + using (DragonGUI.SetFontSize(value: 18)) + using (DragonGUI.SetColor(Color.white, 0.3f)) GUILayout.Label(title, GUILayout.Width(12)); - using (EcsGUI.Layout.BeginVertical()) + using (DragonGUI.Layout.BeginVertical()) { foreach (var inc in ids) { Type type = Target.World.GetComponentType(inc); 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); } diff --git a/src/DebugUtils/Monitors/EntityMonitor.cs b/src/DebugUtils/Monitors/EntityMonitor.cs index 3c17697..c30dfe4 100644 --- a/src/DebugUtils/Monitors/EntityMonitor.cs +++ b/src/DebugUtils/Monitors/EntityMonitor.cs @@ -20,7 +20,7 @@ namespace DCFApixels.DragonECS.Unity.Internal _entity = entity; #if UNITY_EDITOR var world = entity.GetWorldUnchecked(); - world.Get().SetMonitorLink(entity.GetIDUnchecked(), this); + world.Get().SetMonitorLink(entity.GetIDUnchecked(), this); #endif } } diff --git a/src/Internal/AddParamsDrawer.cs b/src/Internal/AddParamsDrawer.cs index 3763124..f83c0da 100644 --- a/src/Internal/AddParamsDrawer.cs +++ b/src/Internal/AddParamsDrawer.cs @@ -51,11 +51,11 @@ namespace DCFApixels.DragonECS.Unity.Editors (foldoutRect, labelField) = foldoutRect.HorizontalSliceLeft(EditorGUIUtility.labelWidth); - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { 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) { @@ -70,7 +70,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } //property.isExpanded = true; - using (EcsGUI.UpIndentLevel()) + using (DragonGUI.UpIndentLevel()) { checkboxRects = checkboxRects.Move(EditorGUIUtility.standardVerticalSpacing, 0); @@ -81,11 +81,11 @@ namespace DCFApixels.DragonECS.Unity.Editors //LayerName property.Next(true); - using (EcsGUI.SetIndentLevel(0)) + using (DragonGUI.SetIndentLevel(0)) { 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); } @@ -95,11 +95,11 @@ namespace DCFApixels.DragonECS.Unity.Editors //SortOrder property.Next(false); - using (EcsGUI.SetIndentLevel(0)) + using (DragonGUI.SetIndentLevel(0)) { 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); } @@ -109,16 +109,16 @@ namespace DCFApixels.DragonECS.Unity.Editors //IsUnique property.Next(false); - using (EcsGUI.SetIndentLevel(0)) + using (DragonGUI.SetIndentLevel(0)) { 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); } - if (EcsGUI.Changed) + if (DragonGUI.Changed) { flagsProp.enumValueFlag = (int)flags; } @@ -133,7 +133,7 @@ namespace DCFApixels.DragonECS.Unity.Editors exti:; //EcsGUI.Changed = Event.current.type == EventType.MouseUp; - if (EcsGUI.Changed) + if (DragonGUI.Changed) { property.serializedObject.ApplyModifiedProperties(); } diff --git a/src/Internal/Editor/EcsGUI.Layout.cs b/src/Internal/Editor/DragonGUI.Layout.cs similarity index 88% rename from src/Internal/Editor/EcsGUI.Layout.cs rename to src/Internal/Editor/DragonGUI.Layout.cs index 341dfa0..8e397f9 100644 --- a/src/Internal/Editor/EcsGUI.Layout.cs +++ b/src/Internal/Editor/DragonGUI.Layout.cs @@ -10,7 +10,7 @@ using UnityObject = UnityEngine.Object; namespace DCFApixels.DragonECS.Unity.Editors { - internal static partial class EcsGUI + internal static partial class DragonGUI { public static partial class Layout { @@ -38,7 +38,7 @@ namespace DCFApixels.DragonECS.Unity.Editors 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) { - 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) { - 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) { @@ -125,7 +125,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { float width = EditorGUIUtility.currentViewWidth; 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) { @@ -139,7 +139,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { float width = EditorGUIUtility.currentViewWidth; 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) { @@ -153,21 +153,21 @@ namespace DCFApixels.DragonECS.Unity.Editors { float width = EditorGUIUtility.currentViewWidth; float height = EntityBarHeight; - EcsGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label); + DragonGUI.EntityField(GUILayoutUtility.GetRect(width, height), property, label); } #endregion 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) { - 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) { - 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) { diff --git a/src/Internal/Editor/EcsGUI.Layout.cs.meta b/src/Internal/Editor/DragonGUI.Layout.cs.meta similarity index 100% rename from src/Internal/Editor/EcsGUI.Layout.cs.meta rename to src/Internal/Editor/DragonGUI.Layout.cs.meta diff --git a/src/Internal/Editor/EcsGUI.cs b/src/Internal/Editor/DragonGUI.cs similarity index 98% rename from src/Internal/Editor/EcsGUI.cs rename to src/Internal/Editor/DragonGUI.cs index 1d17bdd..353a433 100644 --- a/src/Internal/Editor/EcsGUI.cs +++ b/src/Internal/Editor/DragonGUI.cs @@ -12,7 +12,7 @@ using Color = UnityEngine.Color; namespace DCFApixels.DragonECS.Unity.Editors { - internal static partial class EcsGUI + internal static partial class DragonGUI { #region Scores 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 { private readonly CheckChangedScope _scope; diff --git a/src/Internal/Editor/EcsGUI.cs.meta b/src/Internal/Editor/DragonGUI.cs.meta similarity index 100% rename from src/Internal/Editor/EcsGUI.cs.meta rename to src/Internal/Editor/DragonGUI.cs.meta diff --git a/src/Internal/Editor/ExtendedEditor.cs b/src/Internal/Editor/ExtendedEditor.cs index 720e7d6..5cb90d9 100644 --- a/src/Internal/Editor/ExtendedEditor.cs +++ b/src/Internal/Editor/ExtendedEditor.cs @@ -9,15 +9,12 @@ #if UNITY_EDITOR namespace DCFApixels.DragonECS.Unity.Editors { - using DCFApixels.DragonECS.Unity.Internal; using global::Unity.Collections.LowLevel.Unsafe; using System; using System.Collections.Generic; - using System.Linq; using System.Reflection; using UnityEditor; using UnityEngine; - using UnityEngine.UIElements; using UnityObject = UnityEngine.Object; @@ -79,7 +76,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { if (AutoChechChanges) { - using (EcsGUI.CheckChanged(serializedObject)) + using (DragonGUI.CheckChanged(serializedObject)) { StaticInit(); Init(); @@ -154,16 +151,28 @@ namespace DCFApixels.DragonECS.Unity.Editors private IEnumerable _attributes = null; - private bool? _isArrayElement = null; + private Type _propertyType = null; + private bool _isArrayElement; + private SerializedProperty _trackedArrayProperty = null; protected bool IsArrayElement { get { - if (_isArrayElement == null) - { - _isArrayElement = Attributes.Any(o => o is ArrayElementAttribute); - } - return _isArrayElement.Value; + return _isArrayElement; + } + } + protected Type PropertyType + { + get + { + return _propertyType; + } + } + protected SerializedProperty TrackedArrayProperty + { + get + { + return _trackedArrayProperty; } } @@ -218,6 +227,23 @@ namespace DCFApixels.DragonECS.Unity.Editors { if (IsInit) { return; } _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); } protected virtual void OnStaticInit() { } @@ -226,15 +252,20 @@ namespace DCFApixels.DragonECS.Unity.Editors public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { - StaticInit(); - Init(property); - return GetCustomHeight(property, label); + _trackedArrayProperty = DragonGUI.CurrentTrackedArrayProperty; + using (new DragonGUI.TrackArrayPropertyScope(null)) + { + StaticInit(); + Init(property); + return GetCustomHeight(property, label); + } } protected abstract float GetCustomHeight(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(); Init(property); diff --git a/src/Internal/Editor/MetaObjectsDropDown.cs b/src/Internal/Editor/MetaObjectsDropDown.cs index d4d9761..9d396d0 100644 --- a/src/Internal/Editor/MetaObjectsDropDown.cs +++ b/src/Internal/Editor/MetaObjectsDropDown.cs @@ -274,7 +274,7 @@ namespace DCFApixels.DragonECS.Unity.Editors } _fieldProperty.serializedObject.ApplyModifiedProperties(); - EcsGUI.DelayedChanged = true; + DragonGUI.DelayedChanged = true; } } } diff --git a/src/Internal/Editor/RuntimeComponentsDrawer.cs b/src/Internal/Editor/RuntimeComponentsDrawer.cs index fb6ca78..a07365e 100644 --- a/src/Internal/Editor/RuntimeComponentsDrawer.cs +++ b/src/Internal/Editor/RuntimeComponentsDrawer.cs @@ -246,7 +246,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X { bool isNull = world == null || world.IsDestroyed || world.ID == 0; if (isNull) { return; } - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { IsShowRuntimeComponents = EditorGUILayout.BeginFoldoutHeaderGroup(IsShowRuntimeComponents, "RUNTIME COMPONENTS", EditorStyles.foldout); EditorGUILayout.EndFoldoutHeaderGroup(); @@ -271,32 +271,32 @@ namespace DCFApixels.DragonECS.Unity.Editors.X float padding = EditorGUIUtility.standardVerticalSpacing; Rect optionButton = GUILayoutUtility.GetLastRect(); optionButton.yMin = optionButton.yMax; - optionButton.yMax += EcsGUI.HeadIconsRect.height; + optionButton.yMax += DragonGUI.HeadIconsRect.height; optionButton.xMin = optionButton.xMax - 64; optionButton.center += Vector2.up * padding * 2f; //Canceling isExpanded - if (EcsGUI.ClickTest(optionButton)) + if (DragonGUI.ClickTest(optionButton)) { ref bool isExpanded = ref expandMatrix.Down(); isExpanded = !isExpanded; } - Color panelColor = EcsGUI.SelectPanelColor(meta, index, total); - using (EcsGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA))) + Color panelColor = DragonGUI.SelectPanelColor(meta, index, total); + using (DragonGUI.Layout.BeginVertical(panelColor.SetAlpha(EscEditorConsts.COMPONENT_DRAWER_ALPHA))) { EditorGUI.BeginChangeCheck(); //Edit script button if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script)) { - optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); - EcsGUI.ScriptAssetButton(optionButton, script); + optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + DragonGUI.ScriptAssetButton(optionButton, script); } //Description icon if (string.IsNullOrEmpty(meta.Description.Text) == false) { - optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); - EcsGUI.DescriptionIcon(optionButton, meta.Description.Text); + optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + DragonGUI.DescriptionIcon(optionButton, meta.Description.Text); } 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) { - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (EcsGUI.SetIndentLevel(0)) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) using (DragonGUI.SetIndentLevel(0)) { if (_runtimeComponentsDepth >= RuntimeComponentsMaxDepth) { @@ -350,12 +350,12 @@ namespace DCFApixels.DragonECS.Unity.Editors.X } if (isWithFoldout == false || IsShowRuntimeComponents) { - if (EcsGUI.Layout.AddComponentButtons(out Rect dropDownRect)) + if (DragonGUI.Layout.AddComponentButtons(out Rect dropDownRect)) { 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)); } @@ -384,25 +384,25 @@ namespace DCFApixels.DragonECS.Unity.Editors.X float padding = EditorGUIUtility.standardVerticalSpacing; Rect optionButton = GUILayoutUtility.GetLastRect(); optionButton.yMin = optionButton.yMax; - optionButton.yMax += EcsGUI.HeadIconsRect.height; + optionButton.yMax += DragonGUI.HeadIconsRect.height; optionButton.xMin = optionButton.xMax - 64; optionButton.center += Vector2.up * padding * 2f; //Canceling isExpanded - if (EcsGUI.ClickTest(optionButton)) + if (DragonGUI.ClickTest(optionButton)) { ref bool isExpanded = ref expandMatrix.Down(); 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(); //Close button - optionButton.xMin = optionButton.xMax - EcsGUI.HeadIconsRect.width; - if (EcsGUI.CloseButton(optionButton)) + optionButton.xMin = optionButton.xMax - DragonGUI.HeadIconsRect.width; + if (DragonGUI.CloseButton(optionButton)) { pool.Del(entityID); return; @@ -410,14 +410,14 @@ namespace DCFApixels.DragonECS.Unity.Editors.X //Edit script button if (ScriptsCache.TryGetScriptAsset(meta, out MonoScript script)) { - optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); - EcsGUI.ScriptAssetButton(optionButton, script); + optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + DragonGUI.ScriptAssetButton(optionButton, script); } //Description icon if (string.IsNullOrEmpty(meta.Description.Text) == false) { - optionButton = EcsGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); - EcsGUI.DescriptionIcon(optionButton, meta.Description.Text); + optionButton = DragonGUI.HeadIconsRect.MoveTo(optionButton.center - (Vector2.right * optionButton.width)); + DragonGUI.DescriptionIcon(optionButton, meta.Description.Text); } 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; - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { outData = data; @@ -479,7 +479,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X break; case DrawerType.UnitySerializableComposite: - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { RefEditorWrapper wrapper = cache.GetWrapper(_runtimeComponentsDepth); wrapper.data = data; @@ -487,7 +487,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X wrapper.IsExpanded = isExpanded; EditorGUILayout.PropertyField(wrapper.Property, label, true); - if (EcsGUI.Changed) + if (DragonGUI.Changed) { wrapper.SO.ApplyModifiedProperties(); newData = wrapper.Data; @@ -499,7 +499,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X break; case DrawerType.UnityNotSerializableComposite: - GUILayout.Space(EcsGUI.Spacing); + GUILayout.Space(DragonGUI.Spacing); var foldoutStyle = EditorStyles.foldout; Rect rect = GUILayoutUtility.GetRect(label, foldoutStyle); //rect.xMin += EcsGUI.Indent; @@ -508,7 +508,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X if (isExpanded) { - using (EcsGUI.UpIndentLevel()) + using (DragonGUI.UpIndentLevel()) { for (int j = 0, jMax = cache.Fields.Length; j < jMax; j++) { @@ -526,7 +526,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X break; case DrawerType.UnityObject: - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { var uobj = UnsafeUtility.As(ref data); bool isComponent = typeof(UnityComponent).IsAssignableFrom(fieldInfoData.FieldType); @@ -696,7 +696,7 @@ namespace DCFApixels.DragonECS.Unity.Editors.X } expandMatrix.Up(); - if (childElementChanged || EcsGUI.Changed) + if (childElementChanged || DragonGUI.Changed) { outData = newData; return true; diff --git a/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs b/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs index 725b784..6a8f0d7 100644 --- a/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs +++ b/src/Templates/EntityTemplate/Editor/EntityTemplateEditor.cs @@ -52,7 +52,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private void OnReorderableListReorder(ReorderableList list) { - EcsGUI.Changed = true; + DragonGUI.Changed = true; } 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) { + if (index < 0 || Event.current.type == EventType.Used) { return; } SerializedProperty prop = _componentTemplatesProp.GetArrayElementAtIndex(index); GUIContent label = UnityEditorUtility.GetLabelTemp(); rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); EditorGUI.PropertyField(rect, prop, label); return; - //if (index < 0 || Event.current.type == EventType.Used) { return; } //rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); //using (EcsGUI.CheckChanged()) //{ @@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { list.serializedProperty.arraySize += 1; list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues(); - EcsGUI.Changed = true; + DragonGUI.Changed = true; } private void OnReorderableListRemove(ReorderableList list) { @@ -158,7 +158,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]); } - EcsGUI.Changed = true; + DragonGUI.Changed = true; } #endregion @@ -172,7 +172,7 @@ namespace DCFApixels.DragonECS.Unity.Editors if (IsSO) { - EcsGUI.Layout.ManuallySerializeButton(targets); + DragonGUI.Layout.ManuallySerializeButton(targets); } if (IsMultipleTargets) @@ -185,17 +185,17 @@ namespace DCFApixels.DragonECS.Unity.Editors //костыль который насильно заставляет _reorderableComponentsList пересчитать высоту if (_reorderableComponentsListLastCount != _reorderableComponentsList.count) { - EcsGUI.Changed = true; + DragonGUI.Changed = true; _reorderableComponentsListLastCount = _reorderableComponentsList.count; } } 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)); - using (EcsGUI.Layout.BeginVertical()) + using (DragonGUI.Layout.BeginVertical()) { GUILayout.Label("This object contains SerializeReference types which are missing.", EditorStyles.miniLabel); if (GUILayout.Button("Repaire References Tool", EditorStyles.miniButton, GUILayout.MaxWidth(200f))) @@ -209,7 +209,7 @@ namespace DCFApixels.DragonECS.Unity.Editors SerializedProperty iterator = serializedObject.GetIterator(); iterator.NextVisible(true); - using (EcsGUI.Disable) + using (DragonGUI.Disable) { EditorGUILayout.PropertyField(iterator, true); } @@ -230,7 +230,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { EditorGUILayout.PropertyField(_templatesProp, true); } - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { DrawTop(_componentTemplatesProp); _reorderableComponentsList.DoLayoutList(); @@ -240,13 +240,13 @@ namespace DCFApixels.DragonECS.Unity.Editors { 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(); _componentDropDown.OpenForArray(rect, componentsProp, true); break; - case EcsGUI.AddClearButton.Clear: + case DragonGUI.AddClearButton.Clear: Init(); componentsProp.ClearArray(); serializedObject.ApplyModifiedProperties(); diff --git a/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs b/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs index e416802..5fc5fb0 100644 --- a/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs +++ b/src/Templates/EntityTemplate/Templates/ComponentTemplateBase.cs @@ -51,9 +51,9 @@ namespace DCFApixels.DragonECS public abstract void Apply(short worldID, int entityID); #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 MetaColor? Color { get { return Meta?.Color; } } public override MetaGroup Group { get { return Meta?.Group; } } @@ -61,14 +61,17 @@ namespace DCFApixels.DragonECS public override IEnumerable Tags { get { return Meta?.Tags; } } 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 (g.Length == 1) + if (field.Name == "component") { - Meta = g[0].GetMeta(); + Meta = field.FieldType.GetMeta(); + return; } } + } } } diff --git a/src/Templates/EntityTemplate/Templates/ComponentTemplateProperty.cs b/src/Templates/EntityTemplate/Templates/ComponentTemplateProperty.cs index ce7406e..7a08c3e 100644 --- a/src/Templates/EntityTemplate/Templates/ComponentTemplateProperty.cs +++ b/src/Templates/EntityTemplate/Templates/ComponentTemplateProperty.cs @@ -12,7 +12,7 @@ namespace DCFApixels.DragonECS { [SerializeReference] [ReferenceDropDown] - [TypeMetaBlock] + [DragonMetaBlock] private ITemplateNode _template; [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs b/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs index 0ffeb80..198e499 100644 --- a/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs +++ b/src/Templates/EntityTemplate/Templates/MonoEntityTemplate.cs @@ -26,9 +26,7 @@ namespace DCFApixels.DragonECS { [SerializeReference] [ReferenceDropDown(true)] - [TypeMetaBlock] - [FormerlySerializedAs("_components")] - [ArrayElement] + [DragonMetaBlock] private ITemplateNode[] _componentTemplates; #region Methods diff --git a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs index e4a7d84..10f94de 100644 --- a/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs +++ b/src/Templates/EntityTemplate/Templates/ScriptableEntityTemplate.cs @@ -2,6 +2,7 @@ #undef DEBUG #endif using DCFApixels.DragonECS.Unity; +using DCFApixels.DragonECS.Unity.Internal; using System; using System.Collections.Generic; using System.Linq; @@ -26,7 +27,7 @@ namespace DCFApixels.DragonECS private ScriptableEntityTemplateBase[] _templates; [SerializeReference] [ReferenceDropDown(true)] - [FormerlySerializedAs("_components")] + [DragonMetaBlock] private ITemplateNode[] _componentTemplates; #region Methods diff --git a/src/Templates/PipelineTemplate/Editor/PipelineTemplateEditor.cs b/src/Templates/PipelineTemplate/Editor/PipelineTemplateEditor.cs index cf9f890..c3914a0 100644 --- a/src/Templates/PipelineTemplate/Editor/PipelineTemplateEditor.cs +++ b/src/Templates/PipelineTemplate/Editor/PipelineTemplateEditor.cs @@ -62,7 +62,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private void OnReorderableListDrawEmptyElement(Rect rect, int index, bool isActive, bool isFocused) { } private void OnReorderableListReorder(ReorderableList list) { - EcsGUI.Changed = true; + DragonGUI.Changed = true; } private void OnReorderableListRemove(ReorderableList list) { @@ -78,7 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { list.serializedProperty.DeleteArrayElementAtIndex(list.selectedIndices[i]); } - EcsGUI.Changed = true; + DragonGUI.Changed = true; } #endregion @@ -86,11 +86,11 @@ namespace DCFApixels.DragonECS.Unity.Editors private static readonly HashSet _defaultLayersSet = new HashSet(PipelineTemplateUtility.DefaultLayers); private void OnReorderableLayersListDrawElement(Rect rect, int index, bool isActive, bool isFocused) { - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { var elementProp = _layersProp.GetArrayElementAtIndex(index); string str = elementProp.stringValue; - using (EcsGUI.SetEnable(_defaultLayersSet.Contains(str) == false)) + using (DragonGUI.SetEnable(_defaultLayersSet.Contains(str) == false)) { elementProp.stringValue = EditorGUI.TextField(rect, str); } @@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS.Unity.Editors var added = list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1); added.stringValue = $"Layer-{DateTime.Now.Ticks}"; added.serializedObject.ApplyModifiedProperties(); - EcsGUI.Changed = true; + DragonGUI.Changed = true; } #endregion @@ -111,7 +111,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { if (index < 0 || Event.current.type == EventType.Used) { return; } rect = rect.AddPadding(OneLineHeight + Spacing, Spacing * 2f, Spacing, Spacing); - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { SerializedProperty prop = _recordsProp.GetArrayElementAtIndex(index); var targetProp = prop.FindPropertyRelative(nameof(PipelineTemplateUtility.Record.target)); @@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Editors bool isNull = targetProp.managedReferenceValue == null; 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; } @@ -130,14 +130,14 @@ namespace DCFApixels.DragonECS.Unity.Editors { float result; result = EditorGUI.GetPropertyHeight(_recordsProp.GetArrayElementAtIndex(index)); - return EcsGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f; + return DragonGUI.GetTypeMetaBlockHeight(result) + Spacing * 2f; } private void OnReorderableRecordsListAdd(ReorderableList list) { list.serializedProperty.arraySize += 1; list.serializedProperty.GetArrayElementAtIndex(list.serializedProperty.arraySize - 1).ResetValues(); - EcsGUI.Changed = true; + DragonGUI.Changed = true; } #endregion @@ -146,7 +146,7 @@ namespace DCFApixels.DragonECS.Unity.Editors { if (IsSO) { - EcsGUI.Layout.ManuallySerializeButton(targets); + DragonGUI.Layout.ManuallySerializeButton(targets); } if (IsMultipleTargets) @@ -155,13 +155,13 @@ namespace DCFApixels.DragonECS.Unity.Editors return; } - EcsGUI.Changed = GUILayout.Button("Validate"); + DragonGUI.Changed = GUILayout.Button("Validate"); DrawLayoutNameList(_layersProp); EditorGUILayout.PropertyField(_parametersProp, UnityEditorUtility.GetLabel(_parametersProp.displayName)); DrawRecordList(_recordsProp); - if (EcsGUI.Changed) + if (DragonGUI.Changed) { serializedObject.ApplyModifiedProperties(); Validate(); @@ -181,7 +181,7 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawLayoutNameList(SerializedProperty layersProp) { - using (EcsGUI.Layout.BeginVertical()) + using (DragonGUI.Layout.BeginVertical()) { GUILayout.Label(UnityEditorUtility.GetLabel(layersProp.displayName), EditorStyles.boldLabel); _reorderableLayersList.DoLayoutList(); @@ -190,16 +190,16 @@ namespace DCFApixels.DragonECS.Unity.Editors private void DrawRecordList(SerializedProperty recordsProp) { GUILayout.Label(UnityEditorUtility.GetLabel(recordsProp.displayName), EditorStyles.boldLabel); - using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) + using (DragonGUI.Layout.BeginVertical(UnityEditorUtility.GetTransperentBlackBackgrounStyle())) { 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); break; - case EcsGUI.AddClearButton.Clear: + case DragonGUI.AddClearButton.Clear: recordsProp.ClearArray(); recordsProp.serializedObject.ApplyModifiedProperties(); break; diff --git a/src/Templates/PipelineTemplate/Editor/PipelineTemplateUtilityRecordDrawer.cs b/src/Templates/PipelineTemplate/Editor/PipelineTemplateUtilityRecordDrawer.cs index 38a5a0e..ee9ad49 100644 --- a/src/Templates/PipelineTemplate/Editor/PipelineTemplateUtilityRecordDrawer.cs +++ b/src/Templates/PipelineTemplate/Editor/PipelineTemplateUtilityRecordDrawer.cs @@ -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; int depth = -1; diff --git a/src/Tools/DragonDocs/Editors/DragonDocsWindow.cs b/src/Tools/DragonDocs/Editors/DragonDocsWindow.cs index 5835f23..66c5156 100644 --- a/src/Tools/DragonDocs/Editors/DragonDocsWindow.cs +++ b/src/Tools/DragonDocs/Editors/DragonDocsWindow.cs @@ -85,7 +85,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors GUILayout.BeginHorizontal(GUILayout.ExpandHeight(true)); 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(); } @@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors 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); } @@ -119,7 +119,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors private void DrawToolbar() { - using (EcsGUI.SetColor(GUI.color * 0.8f)) + using (DragonGUI.SetColor(GUI.color * 0.8f)) GUILayout.BeginHorizontal(EditorStyles.toolbar); GUILayout.Space(EditorGUIUtility.standardVerticalSpacing * 2f); @@ -129,12 +129,12 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors 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; } - 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; } @@ -147,7 +147,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors _searchingSampleChanged = true; } 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(); } @@ -246,29 +246,29 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors 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; alphaPanelColor.a = EscEditorConsts.COMPONENT_DRAWER_ALPHA; - using (EcsGUI.Layout.BeginVertical(alphaPanelColor)) + using (DragonGUI.Layout.BeginVertical(alphaPanelColor)) { GUILayout.Space(1f); //draw title block - using (EcsGUI.Layout.BeginHorizontal()) + using (DragonGUI.Layout.BeginHorizontal()) { 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)) { - EcsGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f)); + DragonGUI.Layout.ScriptAssetButton(script, GUILayout.Width(18f)); } 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); } @@ -282,7 +282,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors if (string.IsNullOrEmpty(meta.MetaID) == false) { 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); var tagsstring = string.Join(',', meta._tags); - using (EcsGUI.SetAlpha(0.5f)) + using (DragonGUI.SetAlpha(0.5f)) { GUILayout.TextArea(tagsstring, EditorStyles.wordWrappedMiniLabel); } @@ -333,7 +333,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors var infos = Prefs.Infos; var isExpands = Prefs.IsExpands; - using (EcsGUI.SetIndentLevel(0)) + using (DragonGUI.SetIndentLevel(0)) { int clippingDepth = int.MaxValue; @@ -363,7 +363,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors if (_searchingSample.Length == 0) { - EcsGUI.IndentLevel = groupInfo.Depth; + DragonGUI.IndentLevel = groupInfo.Depth; } 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)); } - 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; - if (EcsGUI.HitTest(r)) + if (DragonGUI.HitTest(r)) { EditorGUI.DrawRect(r, new Color(1f, 1f, 1f, 0.12f)); 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)) { - using (EcsGUI.SetBackgroundColor(0, 0, 0, 0)) + using (DragonGUI.SetBackgroundColor(0, 0, 0, 0)) { EditorGUI.Foldout(r, false, label, EditorStyles.foldout); } @@ -451,7 +451,7 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors switch (current.type) { case EventType.MouseDown: - if (EcsGUI.HitTest(rect)) + if (DragonGUI.HitTest(rect)) { _buttonsWidthDragStartPos = current.mousePosition; _buttonsWidthDragStartValue = _buttonsWidth; diff --git a/src/Tools/RefRepairer/Editor/RefRepairerWindow.cs b/src/Tools/RefRepairer/Editor/RefRepairerWindow.cs index 2544dc5..bf5532a 100644 --- a/src/Tools/RefRepairer/Editor/RefRepairerWindow.cs +++ b/src/Tools/RefRepairer/Editor/RefRepairerWindow.cs @@ -61,7 +61,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors if (index < 0 || index >= _cachedMissingsResolvingDatas.Length) { return; } ref var data = ref _cachedMissingsResolvingDatas[index]; - using (EcsGUI.SetAlpha(0)) + using (DragonGUI.SetAlpha(0)) { if (GUI.Button(rect, "")) { @@ -75,7 +75,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors { EditorGUI.DrawRect(rect, _activedColor); } - if (EcsGUI.HitTest(rect)) + if (DragonGUI.HitTest(rect)) { EditorGUI.DrawRect(rect, _dragColor); } @@ -122,7 +122,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors GUI.Label(nameRect, name); EditorGUI.DrawRect(oldRect, new Color(0, 0, 0, 0.16f)); GUI.Label(oldRect, oldStr); - using (EcsGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter)) + using (DragonGUI.SetAlignment(GUI.skin.label, TextAnchor.MiddleCenter)) { GUI.Label(arrowRect, "->"); } @@ -160,16 +160,16 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors _panel = new GUIStyle(); _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 COLLECT_BUTTON = "Collect Missings"; if (_missingRefContainer.IsEmpty) { GUILayout.Label("", GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true)); - using (EcsGUI.SetFontSize(14)) - using (EcsGUI.SetFontSize(GUI.skin.button, 14)) - using (EcsGUI.SetAlignment(value: TextAnchor.MiddleCenter)) + using (DragonGUI.SetFontSize(14)) + using (DragonGUI.SetFontSize(GUI.skin.button, 14)) + using (DragonGUI.SetAlignment(value: TextAnchor.MiddleCenter)) { Vector2 center = GUILayoutUtility.GetLastRect().center; 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.center = center; 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; } @@ -222,8 +222,8 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors InitList(); } - var bc = EcsGUI.SetBackgroundColor(Color.black, 0.5f); - using (EcsGUI.Layout.BeginVertical(EditorStyles.helpBox)) + var bc = DragonGUI.SetBackgroundColor(Color.black, 0.5f); + using (DragonGUI.Layout.BeginVertical(EditorStyles.helpBox)) { bc.Dispose(); _scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.ExpandHeight(true)); @@ -232,7 +232,7 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors } GUILayout.Space(4f); - using (EcsGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false))) + using (DragonGUI.Layout.BeginVertical(GUILayout.ExpandHeight(false))) { //GUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandHeight(false)); @@ -245,14 +245,14 @@ namespace DCFApixels.DragonECS.Unity.RefRepairer.Editors if (data == null) { - using (EcsGUI.SetAlignment(TextAnchor.MiddleCenter)) + using (DragonGUI.SetAlignment(TextAnchor.MiddleCenter)) { GUI.Label(rect, "Select any record"); } } else { - using (EcsGUI.CheckChanged()) + using (DragonGUI.CheckChanged()) { rect.height = EditorGUIUtility.singleLineHeight; 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); rect = rect.Move(0, EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing); 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); } @@ -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))) { diff --git a/src/Utils/ReferenceDropDownAttribute.cs b/src/Utils/ReferenceDropDownAttribute.cs index d55b637..defaca8 100644 --- a/src/Utils/ReferenceDropDownAttribute.cs +++ b/src/Utils/ReferenceDropDownAttribute.cs @@ -31,7 +31,7 @@ namespace DCFApixels.DragonECS 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; [CustomPropertyDrawer(typeof(ReferenceDropDownAttribute), true)] - [CustomPropertyDrawer(typeof(TypeMetaBlockAttribute), true)] - internal class EcsDragonFieldDrawer : ExtendedPropertyDrawer + [CustomPropertyDrawer(typeof(DragonMetaBlockAttribute), true)] + internal class DragonFieldDrawer : ExtendedPropertyDrawer { private const float DamagedComponentHeight = 18f * 2f; private DragonFieldDropDown _dropDown; @@ -50,13 +50,13 @@ namespace DCFApixels.DragonECS.Unity.Editors private ReferenceDropDownAttribute ReferenceDropDownAttribute; private ReferenceDropDownWithoutAttribute ReferenceDropDownWithoutAttribute; - private TypeMetaBlockAttribute TypeMetaBlockAttribute; + private DragonMetaBlockAttribute TypeMetaBlockAttribute; private bool _isInit = false; private bool _hasSerializableData; // 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 private float Padding => Spacing; @@ -68,9 +68,9 @@ namespace DCFApixels.DragonECS.Unity.Editors #region Init protected override void OnStaticInit() { - if(_unrecursiveLable == null) + if(_unrecursiveLabel == null) { - _unrecursiveLable = new GUIContent(); + _unrecursiveLabel = new GUIContent(); } } protected override void OnInit(SerializedProperty property) @@ -78,6 +78,7 @@ namespace DCFApixels.DragonECS.Unity.Editors PredicateTypesKey key; _hasSerializableData = true; + if (fieldInfo != null) { if (property.propertyType == SerializedPropertyType.ManagedReference) @@ -90,14 +91,13 @@ namespace DCFApixels.DragonECS.Unity.Editors { case ReferenceDropDownAttribute atr: ReferenceDropDownAttribute = 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 = fieldInfo.FieldType; + var targetType = PropertyType; if (ReferenceDropDownAttribute != null) { Type[] withOutTypes = ReferenceDropDownWithoutAttribute != null ? ReferenceDropDownWithoutAttribute.PredicateTypes : Type.EmptyTypes; @@ -149,16 +149,16 @@ namespace DCFApixels.DragonECS.Unity.Editors currentProperty.isExpanded = false; } currentProperty.serializedObject.ApplyModifiedProperties(); - EcsGUI.DelayedChanged = true; + DragonGUI.DelayedChanged = true; } #endregion protected override float GetCustomHeight(SerializedProperty property, GUIContent label) { - if (ReferenceEquals(_unrecursiveLable, label)) { return EditorGUI.GetPropertyHeight(property, label); } - _unrecursiveLable.text = label.text; - _unrecursiveLable.tooltip = label.tooltip; - label = _unrecursiveLable; + if (ReferenceEquals(_unrecursiveLabel, label)) { return EditorGUI.GetPropertyHeight(property, label); } + _unrecursiveLabel.text = label.text; + _unrecursiveLabel.tooltip = label.tooltip; + label = _unrecursiveLabel; //if (CheckSkip()) { return EditorGUI.GetPropertyHeight(property, label); } 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) { - if (ReferenceEquals(_unrecursiveLable, label)) { EditorGUI.PropertyField(rect, property, label, true); return; } - _unrecursiveLable.text = label.text; - _unrecursiveLable.tooltip = label.tooltip; - label = _unrecursiveLable; + if (ReferenceEquals(_unrecursiveLabel, label)) { EditorGUI.PropertyField(rect, property, label, true); return; } + _unrecursiveLabel.text = label.text; + _unrecursiveLabel.tooltip = label.tooltip; + label = _unrecursiveLabel; //if (CheckSkip()) { EditorGUI.PropertyField(rect, property, label, true); return; } bool isSerializeReference = property.propertyType == SerializedPropertyType.ManagedReference; @@ -236,6 +236,7 @@ namespace DCFApixels.DragonECS.Unity.Editors bool isDrawProperty = true; bool isDrawDropDown = IsDrawDropDown && isSerializeReference; + Rect srcRect = rect; if (isSerializeReference) { var template = property.managedReferenceValue; @@ -295,7 +296,7 @@ namespace DCFApixels.DragonECS.Unity.Editors if (IsDrawMetaBlock) { 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; if (skip) { @@ -339,7 +340,7 @@ namespace DCFApixels.DragonECS.Unity.Editors var labelRect = rect; labelRect.width = EditorGUIUtility.labelWidth; 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; } @@ -350,15 +351,11 @@ namespace DCFApixels.DragonECS.Unity.Editors EditorGUI.LabelField(rect, label); } - - - if (isDrawDropDown) { - rect.xMax -= selectionButtonRightOffset; - DrawSelectionDropDown(rect, property, label); + srcRect.xMax -= selectionButtonRightOffset; + DrawSelectionDropDown(srcRect, property, label); } - } @@ -369,8 +366,19 @@ namespace DCFApixels.DragonECS.Unity.Editors { 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.y += Spacing * 2; bool isHideButtonIfNotNull = ReferenceDropDownAttribute.IsHideButtonIfNotNull; object obj = property.hasMultipleDifferentValues ? null : property.managedReferenceValue;