增加Demo示例

增加Demo示例
This commit is contained in:
ALEXTANG
2022-09-23 10:38:22 +08:00
parent 752cf4bad6
commit a23f74c2f9
38 changed files with 2892 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
using System;
using TEngine.Runtime;
using TEngine.Runtime.Entity;
using UnityEngine;
public class EntityTestMain : MonoBehaviour
{
void Start()
{
//Demo示例监听TEngine流程加载器OnStartGame事件
//抛出这个事件说明框架流程加载完成(热更新,初始化等)
GameEventMgr.Instance.AddEventListener(TEngineEvent.OnStartGame,OnStartGame);
}
private void OnStartGame()
{
Log.Debug("TEngineEvent.OnStartGame");
for (int i = 1; i < 10; i++)
{
//实体数据创建
EntityData entityData= EntityData.Create();
entityData.Position = new Vector3(i, i, 0);
entityData.Rotation = Quaternion.identity;
//实体系统创建实体,自动创建实体组
EntitySystem.Instance.CreateEntity<EntityCube>("Cube",entityData);
}
}
/// <summary>
/// 实体Cube
/// </summary>
public class EntityCube:EntityLogicEx
{
protected override void OnAttached(EntityLogic childEntity, Transform parentTransform, object userData)
{
base.OnAttached(childEntity, parentTransform, userData);
Log.Info("OnAttached");
}
/// <summary>
/// 实体显示事件
/// </summary>
/// <param name="userData">EntityData</param>
protected override void OnShow(object userData)
{
base.OnShow(userData);
Log.Info("OnShow");
}
protected override void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
base.OnUpdate(elapseSeconds, realElapseSeconds);
}
}
}