ECS
ECSã¯ç¾ç¶æ£ç´ãªæãç©éãå¿ è¦ãªé¨åãECSã§è©¦ãã¦å¤§ã¾ããªé¨åã¯æ¢åã®MonoBehaviourãUnityEngineç³»ã®ã³ã³ãã¼ãã³ãã使ãã®ããã¿ã¼ãªåçã§ããä»åã¯ECSã¨GameObjectãé£æºãããææ³ã«ã¤ãã¦ãç´¹ä»ãã¾ãã æ¤è¨¼ãã¼ã¸ã§ã³ï¼Unity 2019.3ãEntities â¦
ECSã§NavMeshã使ããã å æ¥è¡ããã1WeekGameJamã®å®æ³ã«ã¦ã¦ããã£ã¡ãããèµ°ãåãã²ã¼ã ãããããããè¦ã¦ä½ã¨ãªãECSï¼SubSceneï¼ã§ãNavMeshã«ãã移åå¶éã使ç¨ãããã¨æã£ãã®ã§ãããæ¹ãèãã¦ã¿ã¾ããã èãçã«ã¯å¤§æã«æ¸ãããããããè½â¦
ä»åã¯å¾®å¦ã«è©³ç´°ãªèª¬æã®ãªãISystemStateComponentDataã¨ããæ©è½ãç´¹ä»ãã¾ãã EntityãDestroyããã¦ãç ´æ£ãããªãã³ã³ãã¼ãã³ã Entityçæã»ç ´æ£ã®ã¿ã¤ãã³ã°ã§å¦çãä¸åå®è¡ãã åæåæã®å¦çï¼Awakeçãªï¼ åæåå¾ã®æ¯ãã¬ã¼ã å®è¡ããå¦çï¼â¦
ãã®è¨äºã¯Unity 2019.2.8f1ã¨Entities 0.1.1 ãå©ç¨ãã¦ãã¾ããã¾ãè¨è¨ãã¤ã±ã¦ãªãã®ã§ä¿®æ£ããã¦ãã¾ããããªæãã¯ããã¾ãããç¾ç¶SubSceneã試ãä¸ã§ç¥ããªãã§è¦å´ããã®ã§ã¡ã¢ãã¾ãã SubSceneã§ISharedComponentDataã使ããªã ã¨ããããIShareâ¦
åãªãã¸ã§ã¯ãã®åº§æ¨ã使ããã LocalToParentã使ç¨ãã å転ããªããå¼¾ãæã¤ç ²å° ãã¥ã¼ããåã å¼¾ãçæ å¼¾ãä¸æ¹åã«é£ã°ã 注æç¹ é¢é£ ãã®ãµã³ãã«ã¯ Entities.0.1.1ããã³Unity 2019.2f8ã使ç¨ãã¦ãã¾ã åãªãã¸ã§ã¯ãã®åº§æ¨ã使ããã Unityã§â¦
ç©çæ¼ç®ã§ãªãã¸ã§ã¯ãå士ãæ¥è§¦ããæã®ã¤ãã³ããçºè¡ããæ¹æ³ã«ã¤ãã¦ã§ãã ãªããç¾æ®µéã§ã¯æããã«ä½ã¬ãã«APIã®ã¿ããæä¾ããã¦ããããæªå®æã§ãã ãã®è¨äºã¯ãä»ãã触ã£ã¦ã¿ãããã¨ãã人åãã§ãæ£ç´ãã¾ãæçã§ã¯ããã¾ããã æ¥è§¦ã¤ãâ¦
試ãã«Roll a BallãUnity Physicsã§ä½ã£ã¦ã¿ãæããã®ãã¯ããã¯ç¡ãã ã¨å°ãé¢åãªæããã£ãã®ã§ç´¹ä»ã GameObjectã§Unity Physicsã使ã ãã£ã©ã¯ã¿ã¼ãæ¶ããã®ã解決ãã ãã£ã©ã¯ã¿ã¼ãåããªãåé¡ã解決ãã GameObjectã§Unity Physicsã使ã Unitâ¦
Unity Physicsã«ã¤ãã¦ç´¹ä»ãã¾ãã Unity Physicsã¨ã¯ï¼ äºåæºå ã¨ããããã·ã¼ã³ãç¨æ Unity Physicsã«ç§»è¡ ã¹ãã¼ã¸ã®ãããªå¤§éã®å½ããå¤å®ã®ããç©ãä¸æ°ã«ãã¼ã æ°ããå¢ããè¨å®ã使ããã ããã©ã¼ãã³ã¹ ã³ã¼ãå¶å¾¡é¢ä¿ é¢é£ Unity Physicsã¨â¦
è¤æ°ã®ComponentGroupã使ã å ¨ãç°ãªãComponentGroupãè¤æ°å®ç¾©ããå ´åã¯RequireForUpdateã使ã è¨å®éãã¨ããç¹ã§è¤æ°ã®ComponentGroupã使ç¨ãããå ´åã¯ãChunkIterationãèãã ææ³ è¤æ°ã®ComponentGroupã使ã ComponentGroupã¯ãSystemãå¦çãâ¦
SubSceneã§ç¬èªã®ã³ã³ãã¼ãã³ãããã¾ã å¤æå ã®ç¡ãã³ã³ãã¼ãã³ããComponentDataã«å·®ãæ¿ããã¢ããã¼ãã«ã¤ãã¦ã§ãã GameObjectãã¼ã¹ã®ãã¼ã¿ãECSãã¼ã¹ã¸å¤æãã GameObjectãEntityã¸å¤æããAPI MonoBehaviourãComponentDataã«å¤æãã¦ãããâ¦
ECS 0.0.12 preview 26ãããGameObjectã¨ComponentãEntityï¼ComponentDataã«å¤æããæ©è½ã追å ããã¾ãããã¾ãã¯ããã®ä¸ã§æã便å©ã§ãããSubSceneã«ã¤ãã¦ç´¹ä»ãã¾ãã GameObjectãECSåãã«å¤æãã SubScene å®éã«ä½¿ã£ã¦ã¿ã 1. é¸æãããªãã¸ã§â¦
ComponentDataArrayï¼åï¼ãéæ¨å¥¨ã«ãªãã代ããã«ToComponentDataArray(...)ã¨CopyFromComponentDataArray()ã追å ããã¾ããã ããã¯ä»ã¾ã§ã®ComponentDataArrayã¨ç°ãªããNativeArrayãåå¾ãã¾ãã ToComponentDataArrayã¨CopyFromComponentDataArrayâ¦
ECSã§æ°ãã追å ãããAPI GetSingleton㨠SetSingletonã¨ããAPIã«ã¤ãã¦ã§ãã ä¸ã¤ã ãã®ComponentDataãåå¾ããæ©è½ å®è£ ä¾ ã¸ã§ãã®çµäºå¾ ã¡ãè¡ã ææ³ ä¸ã¤ã ãã®ComponentDataãåå¾ããæ©è½ GetSingleton<T>()ã¨SetSingleton<T>(...)ã§ãããComponentDa</t></t>â¦
ECSã§[Inject]å±æ§ãéæ¨å¥¨ã«ãªããæ°ããAPIã追å ããã¾ããã https://github.com/Unity-Technologies/EntityComponentSystemSamples/blob/master/Documentation%7E/ecs_best_practices.md å人çã«ãå¤å°ããã©ã¼ãã³ã¹ãç ç²ã«ãã¦ç°¡åã«ãªããªããããâ¦
ã³ã³ãã¯ããªUnityã²ã¼ã ãåºåããTiny Modeã®ãã¬ãã¥ã¼çãå ¬éããã¾ããã ã¨ãããã¨ã§ãæ©é触ã£ã¦ã¿ã¾ãã ãã®è¨äºã¯Tiny Mode 0.13.2 previewã§ä½æããã¦ãã¾ãã ã¢ãã¤ã«ãã©ã¦ã¶åãUnity ç¾ç¶ä½¿ããæ©è½ç¾¤ ã¹ã¯ãªããã¯ECSãã¼ã¹ ã¬ã³ããªã³â¦
ä»åãECSã®è©±ã§ãã ã²ã¼ã ã§ã¯ç¹å®ã®ãªãã¸ã§ã¯ãã追跡ããã¨ããã®ã¯ãããã話ã§ããä¾ãã°ã«ã¼ã½ã«ãã¦ããããã¢ã¤ãã ããã¹ãªã©ã ECSã§ãåæ§ã«ãããã£ãæ©æ§ãå¿ è¦ã«ãªãäºã¯å¤ã ããã¾ããä»åã¯Entityããç¹å®ã®ãã£ã©ã¯ã¿ã¼ã追跡ãããæ¹æ³â¦
ä»åã¯èªåãECSã§è²ã ããã¨ãã«ããããã£ã¦ããTipsã3ã¤ç´¹ä»ãã¾ãã ããã±ã¼ã¸ãPackagesã«ç§»ã inputDepsã®ãã§ã¼ã³ Debug.Logãåºã NativeArrayãèªåçã«éæ¾ããã¸ã§ã é¢é£ ããã±ã¼ã¸ãPackagesã«ç§»ã PackageManagerã§å°å ¥ããããã±ã¼ã¸ã¯Cï¼â¦
ä»åã¯ECSã§é åã使ç¨ããæ¹æ³ã«ã¤ãã¦ã§ãã ECSã§é åã使ç¨ãã ECSã«æ ¼ç´ããComponentDataã«ã¯é åãæ ¼ç´åºæ¥ã¾ãããã¨ã¯ãããããã¼ã¸ããªã¡ã¢ãªãæ ¼ç´åºæ¥ãSharedComponentDataã¯å¤§éã®ç¨®é¡ãçæããã¨ECSã®å¹çãèããä¸ããã®ã§ä½ãè¯ãããâ¦
ä»åã¯ECSã«ãããEntityã®ã»ã¼ãåã³ãã¼ãã«ã¤ãã¦ã§ãã ã¤ã¾ãGameObjectãSceneãPrefabã«åºããããã«ãEntityï¼Entity & ComponentDataï¼ããã¡ã¤ã«ã¨ãã¦æ¸ãåºãã¾ãã ãªãUnity 2019辺ãã®ã¿ã¤ãã³ã°ã§ã¡ããã¨ããã¨ãã£ã¿ã¼ãµãã¼ããå§ã¾ãã®â¦
ååã«å¼ãç¶ããä»åã¯ãã¤ãºã使ç¨ãã¦ã¿ã¾ãã ãã¤ãºã使ç¨ãã ã³ã¼ã ãã¤ãºã使ç¨ãã ä¸ã®ãããªæãã®åããä½ã£ã¦ã¿ã¾ãã Mathfã¯å¤åã¡ã¤ã³ã¹ã¬ããã§ããåä½ãã¾ããããMathematicsã ã¨å¥ã¹ã¬ããã§ãåé¡ãªãåä½ãã¾ãã ã¾ãRandomã¨ç°ãªâ¦
ãã«ã¤è¨äºãæ¸ããã¨ãã¦ä¸ã æ´æ°ã¾ã§è¾¿ãçããªãã®ã§ãä»åã¯ãµã¯ã£ã¨ECSã®ä¸¦åå¦çã«ãããã¹ã±ã¸ã¥ã¼ãªã³ã°ã®æåã«ã¤ãã¦æ¸ãã¦ããã¾ãã IJobForEach? ECSã¯åç §ããComponentDataã§ã¹ã±ã¸ã¥ã¼ã«ã決ã¾ã ç°ãªãComponentDataã¸ã¢ã¯ã»ã¹ããã¸ã§ãã¯â¦
æè¿ã®ECSçéã§ç¹ã«çç±ããªãChunk Iterationãæ¡ç¨ããã¦ããäºãããè¦ãã®ã§ãä»åãã®Chunk Iterationã¤ãã¦æ¸ãã¦ã¿ã¾ãã ComponentDataã®çµã¿åããã®ççº Chunk Iterationã¨ããåé¿æ¹æ³ ã³ã¼ããæ¸ãã¦ã¿ã å ¨æ ææ³ é¢é£ ComponentDataã®çµã¿åâ¦
ä»åã¯ECSã§ä¸¦åå¦çããçµæãEntityCommandBufferããåé¤ããæ¹æ³ã«ã¤ãã¦ã§ãã以åã¯åºæ¥ãªãã£ãã®ã§ãããæè¿åºæ¥ãããã«ãªãã¾ããã EntityCommandBufferã¨éåæå¦ç EntityCommandBufferã¨ä¸¦åå¦ç ã³ã¼ã EntityCommandBufferã¨éåæå¦ç 使â¦
ECSã®åºæ¬ã¯Systemã§ããã·ã¹ãã ã¨ããWorldæ¯ã«ã¦ãã¼ã¯ãªãªãã¸ã§ã¯ããå¤ãã®Entityãæä½ãããã¨ã§ã²ã¼ã 表ç¾ãå®ç¾ãã¦ãã¾ãã ããã§æ°ã«ãªãã®ã¯Systemãåããæ¹æ³ãåã³æ¢ããæ¹æ³ã«ã¤ãã¦ã§ããä»åã¯ãã®è¾ºãã«ã¤ãã¦æ¸ãã¦ã¿ã¾ãã Default Wâ¦
ããã¢ã¨ãã¦ã®ECSãã欲ãããªã使ãã¾ããããã²ã¼ã ã¨ãã¦ã®ECSããå¿ è¦ãªãç¥ã£ã¦ããã¨è¯ããè¤æ°ã®Worldéç¨ã«ã¤ãã¦ã§ãã ECSãâã²ã¼ã âã«ããããã«ã¯ è¤æ°ã®Worldã管çãã Worldãä½æãã åããWorldãåãæ¿ãã Tips World.Active Default Wâ¦
ä»åã¯ECSã®ComponentSystemãå®è¡é çªãã³ã³ããã¼ã«ããæ¹æ³ã«ã¤ãã¦ã§ãã ComponentSystemã®å®è¡é çªã¯é常ã«éè¦ å®è¡é ã®ç¢ºèªæ¹æ³ ç¹å®ã®ComponentSystemã®åã«å®è¡ãããå¾ã«å®è¡ãã UpdateInGroupã§å¦çã®ã¿ã¤ãã³ã°ã大ã¾ãã«çºãã é¢é£ Componenâ¦
ä»åã¯ECSã®Entityãéåæã«ä½æããæ¹æ³ã«ã¤ãã¦ã§ãã主ã«æè¦æ¨¡ãªã·ã¼ã³ã®ãã¼ãçã«ä½¿ç¨ã§ãããã§ãã Entityã®çæãç ´æ£ãåé¤ã¯ã¡ã¤ã³ã¹ã¬ããä¸ã§è¡ã ExclusiveEntityTransaction ExclusiveEntityTransactionã使ç¨ãã¤ã¤EntityManagerã使ãããâ¦
ECSã使ãåãä¸ã§ç´ æ´ãããè³æãå ¬éããã¾ããã ç¹ã«ã¸ã§ãã·ã¹ãã ä¸ã§è²ã ã¨ããããå ´åã«ã¯åãåèã«ãªãã¨æãã¾ãã ãCEDEC2018ãCPUã使ãåãï¼ Entity Component Systemï¼é称ECSï¼ ãåãéãæ°ããããã°ã©ãã³ã° from UnityTechnologiesJâ¦
GTMF2018ã®è³æã§ãã SRPã®å°å ¥æ¹æ³ã¨ã¡ãªãããSRPãå©ç¨ããããªãã¯ã«ã¤ãã¦ç´¹ä»ããã¦ãã¾ãã ãGTMF2018TOKYOãScriptableRenderPipelineã§ã¢ããªã«æé©ãªæç»ãããã from UnityTechnologiesJapan www.slideshare.net ECSã¨C# Job SystemãBurstã«â¦
ä»åã¯ECSã®ComponentDataã®è¿½å ãåé¤ã»å¤æ´ã¨ãã£ãåä½ãJobSystemä¸ããæ示ããæ¹æ³ã«ã¤ãã¦ã§ãã C# Job SystemããComponentDataã®è¿½å ã»åé¤çãæ示ãã BarrierSystem ãµã³ãã«ã³ã¼ã IjobParallelFotãIJobProcessComponentDataã§ä½¿ç¨ããã«ã¯ï¼â¦