-
Notifications
You must be signed in to change notification settings - Fork 42
Entity
jiepengtan edited this page Nov 20, 2019
·
4 revisions
-
应该使用Public 定义属性
-
同时需要最终继承自IEntity
-
成员可以使用你定义的Componet
-
成员也可以使用内置的Components
- Animator //TODO
- CollisionAgent //TODO
- NavMeshAgent //TODO
- Prefab //含有一个ID 用于标志相应的资源索引
- Transform2D
- Transform3D
[EntityCount(2)]
public partial class BoidObstacle :IEntity,IBindViewEntity,IUpdateViewEntity{
public Transform3D Transform;
public Prefab Prefab;
public PlayerData Player;
public SkillData Skill;
public MoveData Move;
public BoidObstacleTag Tag;
}
- 如果需要将UnsafeECS 中的Entity 的位置于旋转属性同步到Unity 中的Entity ,需要继承自IUpdateViewEntity接口
- 参考代码 __DllSourceFiles/Game.Model/Src/__UnsafeECS/Generated/CodeGen_UpdateViewStateSystem.cs
- 如果希望能够以GameObject 的形式 绑定相关的Entity,这样方便挂接特效等一些View 层的脚本,可以继承自IBindViewEntity 接口,
- 参考代码 __DllSourceFiles/Game.**View**/Src/__UnsafeECS/Generated/CodeGen_EntityView.cs
[EntityCount(20)]
public partial class TestEntity1 : IEntity{
public CellData Cell;
}
[EntityCount(100)]
public partial class TestEntity2 : TestEntity1{
public SpawnData Spawn;
}
- Generated Codes
[StructLayoutAttribute(LayoutKind.Sequential)]
[System.Serializable]
public unsafe partial struct TestEntity1 :IEntity {
// Fields
public CellData Cell;
//... other codes
}
[StructLayoutAttribute(LayoutKind.Sequential)]
[System.Serializable]
public unsafe partial struct TestEntity2 :IEntity {
// Fields
public SpawnData Spawn;
public CellData Cell;
//... other codes
}