SlideShare a Scribd company logo
1 of 20
ECS勉強会
(Unity2018.1.5f1)
ECSとは
ECS = エンティティ・コンポーネント・システム
ECSを最初に採用したゲームはThief: The Dark Project (1998年)
https://ja.wikipedia.org/wiki/エンティティ・コンポーネント・システム
ECSについて
ECS = Entity + Component + System
Entity = オブジェクト(エネミー、乗り物、銃など)
Component = ふるまい(移動する、弾を撃つ、など)
System = Componentを実行する
ECSによる動作の実行
SystemがComponentを実行するとEntityに対して作用が発生
例: 移動の実行
SystemがGoComponentを実行する
-> GoComponentに紐づくEntityが「移動する」を実行
ECSによる動作の実行
例: 移動の実行
Entity
Component
ECSの特徴
データ(Entity)がバラバラに管理されている
処理(Component)とデータもバラバラに管理されている
データ指向設計と相性が良いらしい
https://ja.wikipedia.org/wiki/エンティティ・コンポーネント・システム
UnityのECS
UnityのECS
UnityのECS ≒ 広義のECS
UnityのECSは以下の4つで構成される
・Entity = データの入れ物
・ComponentData = Entityに格納するデータ
・ComponentSystem = 処理
・Group = ComponentSystemが要求するComponentData一覧
http://tsubakit1.hateblo.jp/entry/2018/03/25/180203
JobSystemとの比較
JobSystem
• WorkerThreadに処理を分担させる仕組み
• 処理をIJob〇〇系のExecute()内に書く
• Schedule()メソッドを実行するとシステムが処理を始める
• ECS
• データ駆動で処理を実行させる仕組み
• 処理はComponentSystemのOnUpdate()内に書く
• データを登録するとデータを要求するシステムが処理を始める
ECSの使い方
ECSを使う流れ
1. ECSで実行したい処理をComponentSystemへ書く
2. ArcheType(IComponentDataの組み合わせ)の用意
3. ArcheTypeからEntityを作成する
4. Entity含まれるデータを要求するComponentSystemが動く
例: Cubeを動かすシステムCubeMoveSystem
CubeMoveSystemが位置データPositionを要求している時
Positonを登録するとCubeMoveSystemが動く
終了時にエンティティは破棄
従来手法とECSの比較
従来手法
MonoBehaviourに処理を書く
GameObjectにMonoBehaviourを登録(アタッチ)
GameObjectに紐づくMonoBehaviourが処理を実行
ECS
ComponentSystemに処理を書く
EntityにComponentDataを登録
Entityに紐づくComponentSystemが処理を実行
ECSとJobSystemの連携
ECSとJobSystemの連携
JobComponentSystemクラスを使う
基本はECSと同じ
OnUpdate()でJobを発行してワーカースレッドに処理を投げる
ComponentSystem vs JobComponentSystem
ComponentSystem
・メインスレッド内でUpdate系の処理を回す
JobComponentSystem
・Jobを発行し、ワーカースレッドに処理を投げる
終わり
参考URL(UnityのECS)
EntityComponentSystemSamples
https://github.com/Unity-
Technologies/EntityComponentSystemSamples
Entity-Component System in Unity – a tutorial
https://blogs.msdn.microsoft.com/uk_faculty_connection/201
8/05/08/entity-component-system-in-unity-a-tutorial/
参考URL(ECS)
Entity Component Systems
https://gist.github.com/paniq/c32ac8447a7cc5c33a45
【GDC 2002】A Data-Driven Game Object System
http://gamedevs.org/uploads/data-driven-game-object-
system.pdf

More Related Content

Featured

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Unity2018 ECS

Editor's Notes

  1. このデータを使用することをECSに教えるとデータを要求するComponentSystemが処理を開始する