Last active
July 23, 2019 15:00
-
-
Save Densyakun/d9899952ecbe5ad4509e50b600bdb352 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Unity.Entities; | |
using Unity.Rendering; | |
using Unity.Transforms; | |
public class Main : MonoBehaviour | |
{ | |
private World _world; | |
void OnEnable() | |
{ | |
_world = World.Active = new World("MyWorld"); | |
_world.CreateManager<EntityManager>(); | |
_world.CreateManager<EndFrameTransformSystem>(); | |
_world.CreateManager<RenderingSystemBootstrap>(); | |
ScriptBehaviourUpdateOrder.UpdatePlayerLoop(_world); | |
} | |
void OnDisable() | |
{ | |
ScriptBehaviourUpdateOrder.UpdatePlayerLoop(null); | |
_world.Dispose(); | |
} | |
} |
現在のバージョンではEndFrameTransformSystemがRenderingSystemBootstrapがない
Unity Physicsパッケージを利用したConvert To Entityなどで、
Awake内でWorldやSystemが使用される場合は対応できない
Meshを描画するために、EndFrameTransformSystemとRenderingSystemBootstrapを追加しています。
以前はWorld.CreateManager<EndFrameBarrier>()
とWorld.CreateManager<RenderMeshSystem>().ActiveCamera = mainCamera
が必要だったと思われますが、現在は不要のようです。
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
OnEnableでWorldを作成し、Worldに各種Systemを追加しています。
SystemはWorldが自動的に動作させます。
一例として、OnDisableでWorldを破棄しています。
最終的に使わなくなったWorldは、このようにして破棄してください。
また、現時点ではスクリプト再読込時に自動的にWorldが使えなくなってしまうため、
StartではなくOnEnableとOnDisableにしています。