mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-09-17 17:34:34 +08:00
updtae
This commit is contained in:
parent
f67b8e236c
commit
dd41a6f2b8
22
src/Debug/Systems/DebugModule.cs
Normal file
22
src/Debug/Systems/DebugModule.cs
Normal file
@ -0,0 +1,22 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public sealed class DebugModule : IEcsModule
|
||||
{
|
||||
public const string DEBUG_SYSTEMS_BLOCK = nameof(DEBUG_SYSTEMS_BLOCK);
|
||||
public EcsWorld[] _worlds;
|
||||
public DebugModule(params EcsWorld[] worlds)
|
||||
{
|
||||
_worlds = worlds;
|
||||
}
|
||||
|
||||
void IEcsModule.ImportSystems(EcsPipeline.Builder b)
|
||||
{
|
||||
b.InsertSystemsBlock(DEBUG_SYSTEMS_BLOCK, EcsConsts.POST_END_SYSTEMS_BLOCK);
|
||||
b.Add(new PipelineDebugSystem(), DEBUG_SYSTEMS_BLOCK);
|
||||
foreach (var world in _worlds)
|
||||
{
|
||||
b.Add(new WorldDebugSystem(world), DEBUG_SYSTEMS_BLOCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
11
src/Debug/Systems/DebugModule.cs.meta
Normal file
11
src/Debug/Systems/DebugModule.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2e2725559ae99464d9df9336b4fc84e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -54,8 +54,15 @@ namespace DCFApixels.DragonECS
|
||||
private GUIStyle _interfacesStyle;
|
||||
private Color _interfaceColor = new Color(0.96f, 1f, 0.16f);
|
||||
private PipelineDebugMonitor Target => (PipelineDebugMonitor)target;
|
||||
|
||||
|
||||
private GUIStyle systemsListStyle;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
systemsListStyle = new GUIStyle(EditorStyles.miniLabel);
|
||||
systemsListStyle.wordWrap = true;
|
||||
|
||||
if (Target.source == null)
|
||||
return;
|
||||
if (_headerStyle == null)
|
||||
@ -66,6 +73,7 @@ namespace DCFApixels.DragonECS
|
||||
_interfacesStyle.focused.textColor = _interfaceColor;
|
||||
_interfacesStyle.active.textColor = _interfaceColor;
|
||||
_interfacesStyle.normal.textColor = _interfaceColor;
|
||||
_interfacesStyle.wordWrap = true;
|
||||
_headerStyle.fontSize = 28;
|
||||
}
|
||||
|
||||
@ -133,7 +141,7 @@ namespace DCFApixels.DragonECS
|
||||
Color color = (GetAttribute<DebugColorAttribute>(type) ?? _fakeDebugColorAttribute).GetUnityColor();
|
||||
GUILayout.BeginVertical(EcsEditor.GetStyle(color, 0.2f));
|
||||
GUILayout.Label(type.Name, EditorStyles.boldLabel);
|
||||
GUILayout.Label(string.Join(", ", runner.Targets.Cast<object>().Select(o => o.GetType().Name)), EditorStyles.miniLabel);
|
||||
GUILayout.Label(string.Join(", ", runner.Targets.Cast<object>().Select(o => o.GetType().Name)), systemsListStyle);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public class WorldDebugSystem : IEcsRunSystem
|
||||
{
|
||||
private string _monitorName;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using DCFApixels.DragonECS;
|
||||
using System;
|
||||
using System;
|
||||
|
||||
namespace DCFApixels.Assets.DragonECS_Unity.src.Fetures
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
public static class UnityWorldProvider<TWorld>
|
||||
where TWorld : EcsWorld<TWorld>
|
||||
@ -18,5 +17,13 @@ namespace DCFApixels.Assets.DragonECS_Unity.src.Fetures
|
||||
|
||||
return _world;
|
||||
}
|
||||
|
||||
public static TWorld Get()
|
||||
{
|
||||
if (_world == null)
|
||||
_world = (TWorld)Activator.CreateInstance(typeof(TWorld));
|
||||
return _world;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using UnityEditor.ShortcutManagement;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
@ -64,8 +66,8 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
EcsEntity result = self.NewEntity();
|
||||
GameObject newGameObject = new GameObject(name);
|
||||
newGameObject.AddComponent<EcsEntityConnect>()._entity = result;
|
||||
self.GetPool<UnityGameObject>().Add(result.id) = new UnityGameObject(newGameObject);
|
||||
newGameObject.AddComponent<EcsEntityConnect>().ConectWith(result);
|
||||
// self.GetPool<UnityGameObject>().Add(result.id) =
|
||||
#if UNITY_EDITOR
|
||||
if (icon != GameObjectIcon.NONE)
|
||||
{
|
||||
@ -89,19 +91,58 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class EcsEntityConnect : MonoBehaviour
|
||||
{
|
||||
internal EcsEntity _entity;
|
||||
public EcsEntity entity
|
||||
private sealed class Query : EcsQuery
|
||||
{
|
||||
public readonly EcsPool<UnityGameObject> unityGameObjects;
|
||||
public Query(Builder b)
|
||||
{
|
||||
unityGameObjects = b.Include<UnityGameObject>();
|
||||
}
|
||||
}
|
||||
|
||||
private EcsEntity _entity;
|
||||
private EcsWorld _world;
|
||||
|
||||
#region Properties
|
||||
public EcsEntity Entity
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _entity;
|
||||
}
|
||||
public EcsWorld World
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _world;
|
||||
}
|
||||
public bool IsAlive
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _entity.IsAlive;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void ConectWith(EcsEntity entity)
|
||||
{
|
||||
int e = _entity.id;
|
||||
if (_world != null && _entity.IsNotNull)
|
||||
{
|
||||
var q = _world.Select<Query>();
|
||||
q.unityGameObjects.Del(e);
|
||||
}
|
||||
_world = null;
|
||||
|
||||
_entity = entity;
|
||||
|
||||
if (_entity.IsNotNull)
|
||||
{
|
||||
_world = _entity.GetWorld();
|
||||
var q = _world.Select<Query>();
|
||||
if (!q.unityGameObjects.Has(e)) q.unityGameObjects.Add(e) = new UnityGameObject(gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
@ -115,8 +156,8 @@ namespace DCFApixels.DragonECS
|
||||
private EcsEntityConnect Target => (EcsEntityConnect)target;
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUILayout.IntField(Target._entity.id);
|
||||
GUILayout.Label(Target._entity.ToString());
|
||||
EditorGUILayout.IntField(Target.Entity.id);
|
||||
GUILayout.Label(Target.Entity.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user