2023-03-29 23:59:26 +08:00
|
|
|
using UnityEngine;
|
|
|
|
using DCFApixels.DragonECS;
|
|
|
|
|
|
|
|
namespace #NAMESPACE#
|
|
|
|
{
|
|
|
|
sealed class #SCRIPTNAME# : MonoBehaviour
|
|
|
|
{
|
2023-03-30 05:40:48 +08:00
|
|
|
private EcsDefaultWrold _world;
|
2023-03-30 05:33:35 +08:00
|
|
|
private EcsPipeline _pipeline;
|
2023-03-29 23:59:26 +08:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
// is needed to integrate the internal debugging tool with the unity environment
|
|
|
|
UnityDebugService.Init();
|
|
|
|
|
2023-03-30 05:40:48 +08:00
|
|
|
_world = new EcsDefaultWrold();
|
2023-03-30 05:33:35 +08:00
|
|
|
_pipeline = EcsPipeline.New()
|
2023-03-29 23:59:26 +08:00
|
|
|
// register your systems here, for example:
|
|
|
|
// .Add (new TestSystem1 ())
|
|
|
|
// .Add (new TestSystem2 ())
|
|
|
|
|
|
|
|
// inject worlds here, for example:
|
|
|
|
.Inject(_world)
|
|
|
|
//.Inject(new EcsWorld<EventWorld>())
|
|
|
|
|
|
|
|
// with Inject you can also inject other data, for example:
|
|
|
|
//.Inject(new SharedData())
|
|
|
|
#if UNITY_EDITOR
|
2023-03-30 05:33:35 +08:00
|
|
|
// add debug system for this EcsPipeline here
|
|
|
|
.Add(new PipelineDebugSystem())
|
2023-03-29 23:59:26 +08:00
|
|
|
#endif
|
|
|
|
.BuildAndInit();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2023-03-30 05:33:35 +08:00
|
|
|
_pipeline?.Run();
|
2023-03-29 23:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void LateUpdate()
|
|
|
|
{
|
2023-03-30 05:33:35 +08:00
|
|
|
_pipeline?.LateRun();
|
2023-03-29 23:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void FixedUpdate()
|
|
|
|
{
|
2023-03-30 05:33:35 +08:00
|
|
|
_pipeline?.FixedRun();
|
2023-03-29 23:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
{
|
|
|
|
// don't forget to clear data
|
2023-03-30 05:33:35 +08:00
|
|
|
if (_pipeline != null)
|
2023-03-29 23:59:26 +08:00
|
|
|
{
|
2023-03-30 05:33:35 +08:00
|
|
|
_pipeline.Destroy();
|
|
|
|
_pipeline = null;
|
2023-03-29 23:59:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_world != null)
|
|
|
|
{
|
|
|
|
_world.Destroy();
|
|
|
|
_world = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|