Files
TEngine/Assets/TEngine.Demo/Demo/TEngine.ActorDemo/ActorTestMain.cs
ALEXTANG 74092e6399 事件系统优化更新
事件系统优化更新
1.使用静态代替单例,静态方法调用时候内存地址无需二次偏移定位
2.UI事件在关闭UI时自动反监听
2022-10-26 15:14:04 +08:00

38 lines
1.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using TEngine.Runtime;
using TEngine.Runtime.Actor;
using UnityEngine;
public class ActorTestMain : MonoBehaviour
{
private uint _actorId = 1000;
void Start()
{
//Demo示例监听TEngine流程加载器OnStartGame事件
//抛出这个事件说明框架流程加载完成(热更新,初始化等)
GameEvent.AddEventListener(TEngineEvent.OnStartGame,OnStartGame);
}
private void OnStartGame()
{
Log.Debug("TEngineEvent.OnStartGame");
//激活ActorManager
ActorManager.Instance.Active();
//注册Actor类型
ActorManager.Instance.RegisterActorType(ActorType.ActorPlayer,typeof(PlayerActor));
//创建Actor
var actor = ActorManager.Instance.CreateGameActor(ActorType.ActorPlayer, _actorId++, true);
//附加组件ActorGameObjet可视化
actor.Attach<ModelComponent>();
actor.Attach<FsmComponent>();
actor.Attach<AnimatorComponent>();
}
}