mirror of
https://github.com/DCFApixels/DragonECS-Unity.git
synced 2025-11-12 14:55:56 +08:00
update/fixs
This commit is contained in:
parent
3cc315c2db
commit
834651887b
@ -2,9 +2,9 @@
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = nameof(EcsDefaultWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsDefaultWorldProvider), order = 1)]
|
||||
[CreateAssetMenu(fileName = nameof(EcsDefaultWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/Providers/" + nameof(EcsDefaultWorldProvider), order = 1)]
|
||||
public class EcsDefaultWorldProvider : EcsWorldProvider<EcsDefaultWorld>
|
||||
{
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, null, WorldID); }
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, WorldName, WorldID); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
namespace DCFApixels.DragonECS
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = NAME, menuName = EcsConsts.FRAMEWORK_NAME + "/Providers/" + NAME, order = 1)]
|
||||
public class EcsDefaultWorldSingletonProvider : EcsWorldProvider<EcsDefaultWorld>
|
||||
{
|
||||
private const string NAME = "SingletonDefaultWorld";
|
||||
private static EcsDefaultWorldSingletonProvider _instance;
|
||||
public static EcsDefaultWorldSingletonProvider Instance
|
||||
{
|
||||
@ -9,11 +13,11 @@
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>("SingletonDefaultWorld");
|
||||
_instance = FindOrCreateSingleton<EcsDefaultWorldSingletonProvider>(NAME);
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, null, WorldID); }
|
||||
protected override EcsDefaultWorld BuildWorld(ConfigContainer configs) { return new EcsDefaultWorld(configs, WorldName, WorldID); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,8 +2,10 @@
|
||||
using DCFApixels.DragonECS.Unity.Internal;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
@ -11,14 +13,19 @@ namespace DCFApixels.DragonECS
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(EcsRootUnity), 30)]
|
||||
public class EcsRootUnity : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private EcsPipelineProvider _pipelineProvider;
|
||||
[SerializeField]
|
||||
private bool _enablePipelineDebug = true;
|
||||
[SerializeField]
|
||||
private bool _enableWorldDebug = true;
|
||||
[SerializeField]
|
||||
private ScriptablePipelineTemplateBase[] _scriptableTemplates;
|
||||
[SerializeField]
|
||||
private MonoPipelineTemplateBase[] _monoTemplates;
|
||||
|
||||
private EcsPipeline _pipeline;
|
||||
private bool _isInit = false;
|
||||
|
||||
public IEnumerable<ScriptablePipelineTemplateBase> ScriptableTemplates
|
||||
{
|
||||
@ -34,12 +41,23 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public bool IsInit
|
||||
{
|
||||
get { return _pipeline != null && _pipeline.IsInit; }
|
||||
get { return _isInit; }
|
||||
}
|
||||
public bool EnablePipelineDebug
|
||||
{
|
||||
get { return _enablePipelineDebug; }
|
||||
}
|
||||
public bool EnableWorldDebug
|
||||
{
|
||||
get { return _enableWorldDebug; }
|
||||
}
|
||||
|
||||
private void Start()
|
||||
public void ManualStart()
|
||||
{
|
||||
var pipelineBuilder = EcsPipeline.New();
|
||||
if (_isInit) { return; }
|
||||
|
||||
var pipelineBuilder = EcsPipeline.New(new ConfigContainer(this));
|
||||
|
||||
foreach (var template in _scriptableTemplates)
|
||||
{
|
||||
if (template == null) { continue; }
|
||||
@ -50,6 +68,7 @@ namespace DCFApixels.DragonECS
|
||||
if (template == null) { continue; }
|
||||
pipelineBuilder.Add(template);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (_enablePipelineDebug)
|
||||
{
|
||||
@ -57,7 +76,26 @@ namespace DCFApixels.DragonECS
|
||||
pipelineBuilder.AddUnique(new PipelineMonitorSystem(), EcsUnityConsts.DEBUG_LAYER);
|
||||
}
|
||||
#endif
|
||||
_pipeline = pipelineBuilder.BuildAndInit();
|
||||
_pipeline = pipelineBuilder.Build();
|
||||
if (_pipelineProvider != null)
|
||||
{
|
||||
_pipelineProvider.Set(_pipeline);
|
||||
}
|
||||
_pipeline.Init();
|
||||
|
||||
_isInit = true;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
ManualStart();
|
||||
}
|
||||
|
||||
private void OnValidate()
|
||||
{
|
||||
if (_pipelineProvider == null)
|
||||
{
|
||||
_pipelineProvider = EcsPipelineProvider.SingletonInstance;
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@ -77,7 +115,6 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.DrawIcon(transform.position, "", false);
|
||||
_pipeline?.DrawGizmos();
|
||||
}
|
||||
|
||||
@ -133,4 +170,11 @@ namespace DCFApixels.DragonECS
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
public static class EcsRootUnityExt
|
||||
{
|
||||
public static bool IsEnableWorldDebug(this EcsPipeline.Builder self)
|
||||
{
|
||||
return self.Configs.Instance.Get<EcsRootUnity>().EnableWorldDebug;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
39
src/Buildin/EcsRootUnitySingleton.cs
Normal file
39
src/Buildin/EcsRootUnitySingleton.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(EcsRootUnity))]
|
||||
[AddComponentMenu(EcsConsts.FRAMEWORK_NAME + "/" + nameof(EcsRootUnitySingleton), 30)]
|
||||
public class EcsRootUnitySingleton : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private EcsRootUnity _root;
|
||||
[SerializeField]
|
||||
private bool _dontDestroyOnLoad = true;
|
||||
|
||||
private static EcsRootUnitySingleton _singletonInstance;
|
||||
public static EcsRootUnity Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_singletonInstance == null)
|
||||
{
|
||||
_singletonInstance = FindObjectOfType<EcsRootUnitySingleton>();//FindFirstObjectByType<EcsRootUnitySingleton>();
|
||||
}
|
||||
return _singletonInstance?._root;
|
||||
}
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
if (_dontDestroyOnLoad)
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
}
|
||||
private void OnValidate()
|
||||
{
|
||||
_root = GetComponent<EcsRootUnity>();
|
||||
}
|
||||
}
|
||||
}
|
||||
11
src/Buildin/EcsRootUnitySingleton.cs.meta
Normal file
11
src/Buildin/EcsRootUnitySingleton.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2baa1c20021ec540b0c5399aba0db86
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -2,9 +2,9 @@
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = nameof(EcsWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/WorldProviders/" + nameof(EcsWorldProvider), order = 1)]
|
||||
[CreateAssetMenu(fileName = nameof(EcsWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/Providers/" + nameof(EcsWorldProvider), order = 1)]
|
||||
public class EcsWorldProvider : EcsWorldProvider<EcsWorld>
|
||||
{
|
||||
protected override EcsWorld BuildWorld(ConfigContainer configs) { return new EcsWorld(configs, null, WorldID); }
|
||||
protected override EcsWorld BuildWorld(ConfigContainer configs) { return new EcsWorld(configs, WorldName, WorldID); }
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,18 +32,16 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
this.obj = obj;
|
||||
}
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() //IntelliSense hack
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
IEnumerator IEnumerable.GetEnumerator() //IntelliSense hack
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
IEnumerator<T> IEnumerable<T>.GetEnumerator() { throw new NotSupportedException(); }//IntelliSense hack
|
||||
IEnumerator IEnumerable.GetEnumerator() { throw new NotSupportedException(); }//IntelliSense hack
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator T(UnityComponent<T> a) { return a.obj; }
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static implicit operator UnityComponent<T>(T a) { return new UnityComponent<T>(a); }
|
||||
public override string ToString()
|
||||
{
|
||||
return $"UnityComponent<{typeof(T).ToMeta().TypeName}>";
|
||||
}
|
||||
}
|
||||
|
||||
#region Unity Component Templates
|
||||
|
||||
@ -18,7 +18,7 @@ namespace DCFApixels.DragonECS
|
||||
[SerializeField]
|
||||
private EcsWorldProviderBase _world;
|
||||
|
||||
private bool _created;
|
||||
private bool _started;
|
||||
|
||||
#region Properties
|
||||
public EcsEntityConnect Connect
|
||||
@ -39,10 +39,7 @@ namespace DCFApixels.DragonECS
|
||||
AutoResolveWorldProviderDependensy();
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
CreateEntity();
|
||||
}
|
||||
private void Start() { ManualStart(); }
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
@ -56,19 +53,17 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
public void ManualStart()
|
||||
{
|
||||
CreateEntity();
|
||||
if (_started) { return; }
|
||||
ManualCreate();
|
||||
_started = true;
|
||||
}
|
||||
private void CreateEntity()
|
||||
public void ManualCreate()
|
||||
{
|
||||
if (_created) { return; }
|
||||
|
||||
if (_world == null)
|
||||
{
|
||||
AutoResolveWorldProviderDependensy();
|
||||
}
|
||||
|
||||
InitConnect(_connect, _world.GetRaw());
|
||||
_created = true;
|
||||
}
|
||||
|
||||
private void InitConnect(EcsEntityConnect connect, EcsWorld world)
|
||||
|
||||
65
src/Connectors/EcsPipelineProvider.cs
Normal file
65
src/Connectors/EcsPipelineProvider.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace DCFApixels.DragonECS
|
||||
{
|
||||
[CreateAssetMenu(fileName = nameof(EcsWorldProvider), menuName = EcsConsts.FRAMEWORK_NAME + "/Providers/" + nameof(EcsWorldProvider), order = 1)]
|
||||
public class EcsPipelineProvider : ScriptableObject
|
||||
{
|
||||
private EcsPipeline _pipeline;
|
||||
private static EcsPipelineProvider _singletonInstance;
|
||||
|
||||
#region Properties
|
||||
public bool IsEmpty
|
||||
{
|
||||
get { return _pipeline == null; }
|
||||
}
|
||||
public static EcsPipelineProvider SingletonInstance
|
||||
{
|
||||
get
|
||||
{
|
||||
if(_singletonInstance == null)
|
||||
{
|
||||
_singletonInstance = FindOrCreateSingleton();
|
||||
}
|
||||
return _singletonInstance;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void Set(EcsPipeline pipeline)
|
||||
{
|
||||
_pipeline = pipeline;
|
||||
}
|
||||
public EcsPipeline GetCurrentPipeline()
|
||||
{
|
||||
return _pipeline;
|
||||
}
|
||||
protected static EcsPipelineProvider FindOrCreateSingleton()
|
||||
{
|
||||
return FindOrCreateSingleton(typeof(EcsPipelineProvider).Name + "Singleton");
|
||||
}
|
||||
protected static EcsPipelineProvider FindOrCreateSingleton(string name)
|
||||
{
|
||||
EcsPipelineProvider instance = Resources.Load<EcsPipelineProvider>(name);
|
||||
if (instance == null)
|
||||
{
|
||||
instance = CreateInstance<EcsPipelineProvider>();
|
||||
#if UNITY_EDITOR
|
||||
if (AssetDatabase.IsValidFolder("Assets/Resources/") == false)
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(Application.dataPath + "/Resources/");
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
AssetDatabase.CreateAsset(instance, "Assets/Resources/" + name + ".asset");
|
||||
AssetDatabase.Refresh();
|
||||
#endif
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
11
src/Connectors/EcsPipelineProvider.cs.meta
Normal file
11
src/Connectors/EcsPipelineProvider.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 63bcd818806115742a86a7bbae1b8e95
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
@ -17,14 +15,17 @@ namespace DCFApixels.DragonECS
|
||||
public abstract EcsWorld GetCurrentWorldRaw();
|
||||
}
|
||||
[Serializable]
|
||||
public abstract class EcsWorldProvider<TWorld> : EcsWorldProviderBase where TWorld : EcsWorld
|
||||
public abstract class EcsWorldProvider<TWorld> : EcsWorldProviderBase, IEcsModule
|
||||
where TWorld : EcsWorld
|
||||
{
|
||||
private TWorld _world;
|
||||
|
||||
[SerializeField]
|
||||
public short _worldID = -1;
|
||||
|
||||
[Header("Default Configs")]
|
||||
[Header("Base")]
|
||||
[SerializeField]
|
||||
private short _worldID = -1;
|
||||
private string _worldName = "";
|
||||
|
||||
[Header("Entites")]
|
||||
[SerializeField]
|
||||
private int _entitiesCapacity = EcsWorldConfig.Default.EntitiesCapacity;
|
||||
@ -50,6 +51,10 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
get { return _worldID; }
|
||||
}
|
||||
public string WorldName
|
||||
{
|
||||
get { return _worldName; }
|
||||
}
|
||||
public int EntitiesCapacity
|
||||
{
|
||||
get { return _entitiesCapacity; }
|
||||
@ -122,9 +127,19 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
void IEcsModule.Import(EcsPipeline.Builder b)
|
||||
{
|
||||
var wolrd = Get();
|
||||
b.Inject(wolrd);
|
||||
if (b.IsEnableWorldDebug())
|
||||
{
|
||||
b.AddUnityDebug(wolrd);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
//TODO переименовать в CreateWorld
|
||||
protected abstract TWorld BuildWorld(ConfigContainer configs);
|
||||
protected virtual void OnWorldCreated(TWorld world) { }
|
||||
#endregion
|
||||
|
||||
@ -51,6 +51,17 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
target.Autoset_Editor();
|
||||
}
|
||||
}
|
||||
using (EcsGUI.SetEnable(Application.isPlaying))
|
||||
{
|
||||
buttonRect = buttonRect.Move(-height, 0);
|
||||
if (EcsGUI.NewEntityButton(buttonRect))
|
||||
{
|
||||
foreach (AutoEntityCreator target in targets)
|
||||
{
|
||||
target.ManualCreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,10 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
component = default;
|
||||
}
|
||||
public override string ToString()
|
||||
{
|
||||
return $"GO({(Connect == null ? "NULL" : Connect.name)})";
|
||||
}
|
||||
}
|
||||
|
||||
public enum GameObjectIcon : byte
|
||||
|
||||
@ -20,7 +20,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
private DefineSymbolsInfo[] _defineSymbols = null;
|
||||
private void InitDefines()
|
||||
{
|
||||
string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.Standalone);
|
||||
string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.Standalone);//TODO
|
||||
_defineSymbols =
|
||||
typeof(EcsDefines).GetFields(BindingFlags.Static | BindingFlags.Public).Select(o => new DefineSymbolsInfo(o.Name, false))
|
||||
.Concat(typeof(EcsUnityDefines).GetFields(BindingFlags.Static | BindingFlags.Public).Select(o => new DefineSymbolsInfo(o.Name, false)))
|
||||
@ -98,7 +98,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
GUILayout.BeginHorizontal();
|
||||
var symbol = _defineSymbols[i];
|
||||
|
||||
string text = symbol.name == "DEBUG" ? symbol.name + " (Build Olny)" : symbol.name;
|
||||
string text = symbol.name == "DEBUG" ? symbol.name + " (Build Only)" : symbol.name;
|
||||
symbol.isOn = EditorGUILayout.ToggleLeft(text, symbol.isOn);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
@ -106,14 +106,24 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
if (EditorGUI.EndChangeCheck()) { }
|
||||
if (GUILayout.Button("Apply"))
|
||||
{
|
||||
BuildTargetGroup group = EditorUserBuildSettings.selectedBuildTargetGroup;
|
||||
#if UNITY_6000_0_OR_NEWER
|
||||
string symbolsString = PlayerSettings.GetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group));
|
||||
for (int i = 0; i < _defineSymbols.Length; i++)
|
||||
{
|
||||
symbolsString = symbolsString.Replace(_defineSymbols[i].name, "");
|
||||
}
|
||||
symbolsString += ";" + string.Join(';', _defineSymbols.Where(o => o.isOn).Select(o => o.name));
|
||||
PlayerSettings.SetScriptingDefineSymbols(NamedBuildTarget.FromBuildTargetGroup(group), symbolsString);
|
||||
#else
|
||||
string symbolsString = PlayerSettings.GetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone);
|
||||
for (int i = 0; i < _defineSymbols.Length; i++)
|
||||
{
|
||||
var symbol = _defineSymbols[i];
|
||||
symbolsString = symbolsString.Replace(symbol.name, "");
|
||||
symbolsString = symbolsString.Replace(_defineSymbols[i].name, "");
|
||||
}
|
||||
symbolsString += ";" + string.Join(';', _defineSymbols.Where(o => o.isOn).Select(o => o.name));
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(BuildTargetGroup.Standalone, symbolsString);
|
||||
#endif
|
||||
InitDefines();
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
@ -69,6 +69,20 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
}
|
||||
[SerializeField]
|
||||
private bool _isShowEntityOther = false;
|
||||
public bool IsShowEntityOtherData
|
||||
{
|
||||
get => _isShowEntityOther;
|
||||
set
|
||||
{
|
||||
if (_isShowEntityOther != value)
|
||||
{
|
||||
_isShowEntityOther = value;
|
||||
AutoSave();
|
||||
}
|
||||
}
|
||||
}
|
||||
//[SerializeField]
|
||||
//private bool _isFastModeRuntimeComponents = false;
|
||||
//public bool IsFastModeRuntimeComponents
|
||||
|
||||
@ -0,0 +1,7 @@
|
||||
namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public abstract class EntityEditorBlockDrawer
|
||||
{
|
||||
public abstract void Draw(entlong entity);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 932947836ddab7640b33fc15b7ffb33c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -10,7 +10,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
protected override void DrawCustom()
|
||||
{
|
||||
bool isAlive = Target.Entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
|
||||
var entity = Target.Entity;
|
||||
bool isAlive = entity.TryUnpackForUnityEditor(out int id, out short gen, out short worldID, out EcsWorld world);
|
||||
using (EcsGUI.SetEnable(isAlive))
|
||||
{
|
||||
if (GUILayout.Button("Delete Entity", GUILayout.Height(36f)))
|
||||
@ -19,7 +20,34 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
EcsGUI.Layout.EntityBarForAlive(isAlive ? EcsGUI.EntityStatus.Alive : EcsGUI.EntityStatus.NotAlive, id, gen, worldID);
|
||||
EcsGUI.Layout.DrawRuntimeComponents(Target.Entity, false);
|
||||
|
||||
var drawers = UnityEditorUtility._entityEditorBlockDrawers;
|
||||
if (drawers.Length > 0)
|
||||
{
|
||||
using (EcsGUI.Layout.BeginVertical(UnityEditorUtility.GetStyle(Color.black, 0.2f)))
|
||||
{
|
||||
bool isExpand = false;
|
||||
using (EcsGUI.CheckChanged())
|
||||
{
|
||||
isExpand = EditorGUILayout.Foldout(UserSettingsPrefs.instance.IsShowEntityOtherData, "Other data");
|
||||
if (EcsGUI.Changed)
|
||||
{
|
||||
UserSettingsPrefs.instance.IsShowEntityOtherData = isExpand;
|
||||
}
|
||||
}
|
||||
|
||||
if (isExpand)
|
||||
{
|
||||
foreach (var drawer in drawers)
|
||||
{
|
||||
drawer.Draw(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
EcsGUI.Layout.DrawRuntimeComponents(entity, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
systemsListStyle = new GUIStyle(EditorStyles.miniLabel);
|
||||
systemsListStyle.wordWrap = true;
|
||||
|
||||
if (Target.Pipeline == null || Target.Pipeline.IsDestoryed)
|
||||
if (Target.Pipeline == null || Target.Pipeline.IsDestroyed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ namespace DCFApixels.DragonECS
|
||||
}
|
||||
return;
|
||||
}
|
||||
Debug.Log(v);
|
||||
Debug.Log(msg);
|
||||
}
|
||||
public override void Break()
|
||||
{
|
||||
|
||||
@ -435,6 +435,10 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
}
|
||||
|
||||
public static bool NewEntityButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance.PassIcon, 2f, "Create entity");
|
||||
}
|
||||
public static bool ValidateButton(Rect position)
|
||||
{
|
||||
return IconButton(position, Icons.Instance.RepaireIcon, 2f, "Validate");
|
||||
@ -523,15 +527,21 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
using (new EditorGUI.DisabledScope(true))
|
||||
{
|
||||
GUI.Label(idRect, "Entity ID", style);
|
||||
GUI.Label(genRect, "Generation", style);
|
||||
GUI.Label(worldRect, "World ID", style);
|
||||
using (SetAlpha(0.85f))
|
||||
{
|
||||
GUI.Label(genRect, "Generation", style);
|
||||
GUI.Label(worldRect, "World ID", style);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.IntField(idRect, id, style);
|
||||
EditorGUI.IntField(genRect, gen, style);
|
||||
EditorGUI.IntField(worldRect, world, style);
|
||||
using (SetAlpha(0.85f))
|
||||
{
|
||||
EditorGUI.IntField(genRect, gen, style);
|
||||
EditorGUI.IntField(worldRect, world, style);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,9 +88,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
internal class ComponentDropDown : MetaObjectsDropDown<IComponentTemplate>
|
||||
{
|
||||
//private class StringComparer : IComparer<string>
|
||||
//{
|
||||
// public int Compare(string x, string y)
|
||||
// {
|
||||
// return x.CompareTo(y);
|
||||
// }
|
||||
//}
|
||||
public ComponentDropDown()
|
||||
{
|
||||
IEnumerable<(IComponentTemplate, ITypeMeta)> itemMetaPairs = ComponentTemplateTypeCache.Dummies.ToArray().Select(dummy =>
|
||||
IEnumerable<(IComponentTemplate template, ITypeMeta meta)> itemMetaPairs = ComponentTemplateTypeCache.Dummies.ToArray().Select(dummy =>
|
||||
{
|
||||
ITypeMeta meta;
|
||||
if (dummy is IComponentTemplateWithMetaOverride withMetaOverride)
|
||||
@ -103,6 +110,8 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
}
|
||||
return (dummy, meta);
|
||||
});
|
||||
//TODO оптимизировать или вырезать
|
||||
itemMetaPairs = itemMetaPairs.OrderBy(o => o.meta.Group.Name);
|
||||
Setup(itemMetaPairs);
|
||||
}
|
||||
|
||||
@ -170,7 +179,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
{
|
||||
public RuntimeComponentDropDown(IEnumerable<IEcsPool> pools)
|
||||
{
|
||||
IEnumerable<(IEcsPool, ITypeMeta)> itemMetaPairs = pools.Select(pool =>
|
||||
IEnumerable<(IEcsPool pool, ITypeMeta meta)> itemMetaPairs = pools.Select(pool =>
|
||||
{
|
||||
return (pool, (ITypeMeta)pool.ComponentType.ToMeta());
|
||||
});
|
||||
@ -230,6 +239,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
Dictionary<Key, Item> dict = new Dictionary<Key, Item>();
|
||||
|
||||
|
||||
foreach (var pair in _itemMetaPairs)
|
||||
{
|
||||
ITypeMeta meta = pair.Item2;
|
||||
|
||||
@ -115,6 +115,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
colorBoxeStyles = new SparseArray<GUIStyle>();
|
||||
|
||||
List<Type> serializableTypes = new List<Type>();
|
||||
List<EntityEditorBlockDrawer> entityEditorBlockDrawers = new List<EntityEditorBlockDrawer>();
|
||||
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||
{
|
||||
//var targetTypes = assembly.GetTypes().Where(type =>
|
||||
@ -122,6 +123,16 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
// type.IsSubclassOf(typeof(UnityObject)) == false &&
|
||||
// type.GetCustomAttribute<SerializableAttribute>() != null);
|
||||
|
||||
foreach (var type in assembly.GetTypes())
|
||||
{
|
||||
if ((type.IsGenericType || type.IsAbstract || type.IsInterface) == false &&
|
||||
typeof(EntityEditorBlockDrawer).IsAssignableFrom(type))
|
||||
{
|
||||
var drawer = (EntityEditorBlockDrawer)Activator.CreateInstance(type);
|
||||
entityEditorBlockDrawers.Add(drawer);
|
||||
}
|
||||
}
|
||||
|
||||
var targetTypes = assembly.GetTypes().Where(type =>
|
||||
(type.IsGenericType || type.IsAbstract || type.IsInterface) == false &&
|
||||
type.IsSubclassOf(typeof(UnityObject)) == false &&
|
||||
@ -130,6 +141,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
serializableTypes.AddRange(targetTypes);
|
||||
}
|
||||
_serializableTypes = serializableTypes.ToArray();
|
||||
_entityEditorBlockDrawers = entityEditorBlockDrawers.ToArray();
|
||||
_serializableTypeWithMetaIDMetas = serializableTypes
|
||||
.Where(TypeMeta.IsHasMetaID)
|
||||
.Select(type => type.ToMeta())
|
||||
@ -149,6 +161,7 @@ namespace DCFApixels.DragonECS.Unity.Editors
|
||||
|
||||
internal static readonly Assembly _integrationAssembly;
|
||||
internal static readonly Type[] _serializableTypes;
|
||||
internal static readonly EntityEditorBlockDrawer[] _entityEditorBlockDrawers;
|
||||
internal static readonly TypeMeta[] _serializableTypeWithMetaIDMetas;
|
||||
private static readonly Dictionary<string, Type> _metaIDTypePairs = new Dictionary<string, Type>();
|
||||
|
||||
|
||||
@ -72,7 +72,15 @@ namespace DCFApixels.DragonECS.Unity.Docs.Editors
|
||||
|
||||
private void AddInfo(List<MetaGroupInfo> infos, string path, int startIndex, int length)
|
||||
{
|
||||
MetaGroupInfo lastInfo = infos[infos.Count - 1];
|
||||
MetaGroupInfo lastInfo;
|
||||
if (infos.Count == 0)
|
||||
{
|
||||
lastInfo = new MetaGroupInfo(string.Empty, string.Empty, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
lastInfo = infos[infos.Count - 1];
|
||||
}
|
||||
//if (lastInfo.Depth == 0) { lastInfo = new MetaGroupInfo("", "", 0, 0, 0); }
|
||||
int depth = 0;
|
||||
int lastSeparatorIndex = 0;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user