第三个教程 -实现一个多反应系统
教程地址
https://github.com/sschmid/Entitas-CSharp/wiki/MultiReactiveSystem-Tutorial
配置
打开之前的Entitas编辑器,就是之前用来generate的那个。
在那个Jenny->Context 配置Game, Input, Ui,然后generate
加入教程所说的DestroyedComponent组件,Generate.
我之前用的是1.4.0,一直在报错,说array out of range,怕是因为不能识别多个属性,然后换成1.4.2版本的Entitas就没事了。
MultiDestroySystem
官方代码有问题,是这样的
using System.Collections.Generic;
using Entitas;
using Entitas.Unity;
using UnityEngine;
// IDestroyed: "I'm an Entity, I can have a DestroyedComponent"
public interface IDestroyEntity : IEntity, IDestroyedEntity{ }
// tell the compiler that our context-specific entities implement IDestroyed
public partial class GameEntity : IDestroyEntity { }
public partial class InputEntity : IDestroyEntity { }
public partial class UiEntity : IDestroyEntity { }
// inherit from MultiReactiveSystem using the IDestroy