mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-18 01:54:35 +08:00
upddate
This commit is contained in:
parent
4afce1c448
commit
1176853cd5
@ -9,7 +9,7 @@
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>("DefaultSingletonProvider");
|
||||
_instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>("SingletonDefaultWorld");
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ namespace DCFApixels.DragonECS
|
||||
internal void Autoset_Editor()
|
||||
{
|
||||
_connect = GetComponentInChildren<EcsEntityConnect>();
|
||||
AutoResolveWorldProviderDependensy();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
if (Target.Entity.TryUnpack(out int entityID, out EcsWorld world))
|
||||
{
|
||||
EcsGUI.Layout.DrawComponents(entityID, world);
|
||||
EcsGUI.Layout.DrawRuntimeComponents(entityID, world);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
@ -6,29 +7,46 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
[FilePath(EcsConsts.FRAMEWORK_NAME + "/" + nameof(DebugMonitorPrefs) + ".prefs", FilePathAttribute.Location.ProjectFolder)]
|
||||
public class DebugMonitorPrefs : ScriptableSingleton<DebugMonitorPrefs>
|
||||
{
|
||||
[SerializeField]
|
||||
private bool _isShowInterfaces = false;
|
||||
public bool IsShowInterfaces
|
||||
{
|
||||
get => _isShowInterfaces; set
|
||||
get => _isShowInterfaces;
|
||||
set
|
||||
{
|
||||
_isShowInterfaces = value;
|
||||
Save(false);
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private bool _isShowHidden = false;
|
||||
public bool IsShowHidden
|
||||
{
|
||||
get => _isShowHidden; set
|
||||
get => _isShowHidden;
|
||||
set
|
||||
{
|
||||
_isShowHidden = value;
|
||||
Save(false);
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private bool _isShowRuntimeComponents = true;
|
||||
public bool IsShowRuntimeComponents
|
||||
{
|
||||
get => _isShowRuntimeComponents;
|
||||
set
|
||||
{
|
||||
_isShowRuntimeComponents = value;
|
||||
Save(false);
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
private bool _poolsToggle = false;
|
||||
public bool PoolsToggle
|
||||
{
|
||||
get => _poolsToggle; set
|
||||
get => _poolsToggle;
|
||||
set
|
||||
{
|
||||
_poolsToggle = value;
|
||||
Save(false);
|
||||
|
@ -84,32 +84,41 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
get { return DebugMonitorPrefs.instance.IsShowHidden; }
|
||||
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))
|
||||
{
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
var pool = world.GetPool(componentTypeID);
|
||||
{
|
||||
DrawComponent(entityID, pool);
|
||||
DrawRuntimeComponent(entityID, pool);
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
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();
|
||||
if (meta.IsHidden == false || IsShowHidden)
|
||||
@ -121,7 +130,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
Type componentType = pool.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)
|
||||
{
|
||||
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();
|
||||
UnityEngine.Object uobj = data as UnityEngine.Object;
|
||||
@ -150,7 +159,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
foreach (var field in type.GetFields(fieldFlags))
|
||||
{
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user