1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ISystem と SystemBase

Posted at

ISystem と SystemBase の違いと、用いるポイントについて

ECSでプログラムを作成しているとき、色々なサンプルプログラムを参照しつつ制作していくと思いますが、作業する中で思い至った ISystemとSystemBase の使い分けについて備忘録を残します。

1,[BurstCompile] を使うかどうか

ECSを使ってゲームを作る場合、負荷軽減が目的になることも多いと思いますが、少しでも高速処理するために、BurstCompileを使いたい場面は多いと思います。

SystemBase上でもJobを起こして、.Scheduleや.ScheduleParallelを使えば、Job内ではBurstCompileを使えますが、多少の差は出てくると思います。

.Scheduleと.ScheduleParallelの違いはこちら
https://qiita.com/khbowling/items/c5daa1488312373f162f

2, GameObjectとの連携

ISystem はGameObjectと繋げて設計するのが難しいことが多いです。
なので実際には、MonoBehaviour ⇔ SystemBase ⇔ ISystem のように、間に挟んで設計することになります。
例えば、
・マウスクリックでカメラに対してのポジション(Vestar3)を取得する場合
・キャラクター(Entity)が戦闘でダメージを受けた時、ダメージアイコンを出現させる場合(Entityのダメージアイコンは出せるが、カメラの向きを取得して向きを変えられない)
のようなケースでは、SystemBaseを挟む必要が出てきます。

他にも思いついたら追記していこうと思いますが、
基本的にはできる限りISystemを使い、どうしても難しい場合はSystemBaseを使うように設計していくことが最適解と思います。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?