This commit is contained in:
Mikhail 2024-03-04 08:21:01 +08:00
parent 4afce1c448
commit 1176853cd5
5 changed files with 45 additions and 17 deletions

View File

@ -9,7 +9,7 @@
{ {
if (_instance == null) if (_instance == null)
{ {
_instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>("DefaultSingletonProvider"); _instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>("SingletonDefaultWorld");
} }
return _instance; return _instance;
} }

View File

@ -65,6 +65,7 @@ namespace DCFApixels.DragonECS
internal void Autoset_Editor() internal void Autoset_Editor()
{ {
_connect = GetComponentInChildren<EcsEntityConnect>(); _connect = GetComponentInChildren<EcsEntityConnect>();
AutoResolveWorldProviderDependensy();
} }
#endif #endif
} }

View File

@ -224,7 +224,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
if (Target.Entity.TryUnpack(out int entityID, out EcsWorld world)) if (Target.Entity.TryUnpack(out int entityID, out EcsWorld world))
{ {
EcsGUI.Layout.DrawComponents(entityID, world); EcsGUI.Layout.DrawRuntimeComponents(entityID, world);
} }
} }
} }

View File

@ -1,4 +1,5 @@
#if UNITY_EDITOR #if UNITY_EDITOR
using UnityEngine;
using UnityEditor; using UnityEditor;
namespace DCFApixels.DragonECS.Unity.Editors namespace DCFApixels.DragonECS.Unity.Editors
@ -6,29 +7,46 @@ namespace DCFApixels.DragonECS.Unity.Editors
[FilePath(EcsConsts.FRAMEWORK_NAME + "/" + nameof(DebugMonitorPrefs) + ".prefs", FilePathAttribute.Location.ProjectFolder)] [FilePath(EcsConsts.FRAMEWORK_NAME + "/" + nameof(DebugMonitorPrefs) + ".prefs", FilePathAttribute.Location.ProjectFolder)]
public class DebugMonitorPrefs : ScriptableSingleton<DebugMonitorPrefs> public class DebugMonitorPrefs : ScriptableSingleton<DebugMonitorPrefs>
{ {
[SerializeField]
private bool _isShowInterfaces = false; private bool _isShowInterfaces = false;
public bool IsShowInterfaces public bool IsShowInterfaces
{ {
get => _isShowInterfaces; set get => _isShowInterfaces;
set
{ {
_isShowInterfaces = value; _isShowInterfaces = value;
Save(false); Save(false);
} }
} }
[SerializeField]
private bool _isShowHidden = false; private bool _isShowHidden = false;
public bool IsShowHidden public bool IsShowHidden
{ {
get => _isShowHidden; set get => _isShowHidden;
set
{ {
_isShowHidden = value; _isShowHidden = value;
Save(false); Save(false);
} }
} }
[SerializeField]
private bool _isShowRuntimeComponents = true;
public bool IsShowRuntimeComponents
{
get => _isShowRuntimeComponents;
set
{
_isShowRuntimeComponents = value;
Save(false);
}
}
[SerializeField]
private bool _poolsToggle = false; private bool _poolsToggle = false;
public bool PoolsToggle public bool PoolsToggle
{ {
get => _poolsToggle; set get => _poolsToggle;
set
{ {
_poolsToggle = value; _poolsToggle = value;
Save(false); Save(false);

View File

@ -84,32 +84,41 @@ namespace DCFApixels.DragonECS.Unity.Editors
get { return DebugMonitorPrefs.instance.IsShowHidden; } get { return DebugMonitorPrefs.instance.IsShowHidden; }
set { DebugMonitorPrefs.instance.IsShowHidden = value; } set { DebugMonitorPrefs.instance.IsShowHidden = value; }
} }
public static void DrawComponents(entlong entity) private static bool IsShowRuntimeComponents
{
get { return DebugMonitorPrefs.instance.IsShowRuntimeComponents; }
set { DebugMonitorPrefs.instance.IsShowRuntimeComponents = value; }
}
public static void DrawRuntimeComponents(entlong entity)
{ {
if (entity.TryUnpack(out int entityID, out EcsWorld world)) if (entity.TryUnpack(out int entityID, out EcsWorld world))
{ {
DrawComponents(entityID, world); DrawRuntimeComponents(entityID, world);
} }
} }
public static void DrawComponents(int entityID, EcsWorld world) public static void DrawRuntimeComponents(int entityID, EcsWorld world)
{ {
var componentTypeIDs = world.GetComponentTypeIDs(entityID); var componentTypeIDs = world.GetComponentTypeIDs(entityID);
GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black, 0.2f)); GUILayout.BeginVertical(EcsEditor.GetStyle(Color.black, 0.2f));
GUILayout.Label("COMPONENTS");
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHidden);
IsShowRuntimeComponents = EditorGUILayout.Foldout(IsShowRuntimeComponents, "RUNTIME COMPONENTS");
if (IsShowRuntimeComponents)
{
//TODO галочкаслишком чернаяя, невидно
IsShowHidden = EditorGUILayout.Toggle("Show Hidden", IsShowHiddens);
foreach (var componentTypeID in componentTypeIDs) foreach (var componentTypeID in componentTypeIDs)
{ {
var pool = world.GetPool(componentTypeID); var pool = world.GetPool(componentTypeID);
{ {
DrawComponent(entityID, pool); DrawRuntimeComponent(entityID, pool);
}
} }
} }
GUILayout.EndVertical(); GUILayout.EndVertical();
} }
private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; private static readonly BindingFlags fieldFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private static void DrawComponent(int entityID, IEcsPool pool) private static void DrawRuntimeComponent(int entityID, IEcsPool pool)
{ {
var meta = pool.ComponentType.ToMeta(); var meta = pool.ComponentType.ToMeta();
if (meta.IsHidden == false || IsShowHidden) if (meta.IsHidden == false || IsShowHidden)
@ -121,7 +130,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
Type componentType = pool.ComponentType; Type componentType = pool.ComponentType;
ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType); ExpandMatrix expandMatrix = ExpandMatrix.Take(componentType);
bool changed = DrawData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData); bool changed = DrawRuntimeData(componentType, new GUIContent(meta.Name), expandMatrix, data, out object resultData);
if (changed) if (changed)
{ {
pool.SetRaw(entityID, resultData); pool.SetRaw(entityID, resultData);
@ -132,7 +141,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
} }
} }
private static bool DrawData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData) private static bool DrawRuntimeData(Type fieldType, GUIContent label, ExpandMatrix expandMatrix, object data, out object outData)
{ {
Type type = data.GetType(); Type type = data.GetType();
UnityEngine.Object uobj = data as UnityEngine.Object; UnityEngine.Object uobj = data as UnityEngine.Object;
@ -150,7 +159,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
foreach (var field in type.GetFields(fieldFlags)) foreach (var field in type.GetFields(fieldFlags))
{ {
GUIContent subLabel = new GUIContent(EcsUnityEditorUtility.TransformFieldName(field.Name)); GUIContent subLabel = new GUIContent(EcsUnityEditorUtility.TransformFieldName(field.Name));
if (DrawData(field.FieldType, subLabel, expandMatrix, field.GetValue(data), out object fieldData)) if (DrawRuntimeData(field.FieldType, subLabel, expandMatrix, field.GetValue(data), out object fieldData))
{ {
field.SetValue(data, fieldData); field.SetValue(data, fieldData);