From 4ea1c97bc821a2ae33a612e86c86976578a330bd Mon Sep 17 00:00:00 2001 From: Tristan Bellman-Greenwood Date: Fri, 1 May 2020 18:07:04 -0400 Subject: [PATCH] adding an init method to EntityMonoBehaviour which is called after the prefab is instantiated and the bootstrapper/entity references are set --- .../Hybrid Simulation Test Project/Packages/manifest.json | 4 ++-- .../ProjectSettings/ProjectVersion.txt | 4 ++-- Runtime/Scripts/MonoBehaviours/EntityMonoBehaviour.cs | 5 +++++ Runtime/Scripts/Systems/PrefabSpawnSystem.cs | 2 ++ package.json | 2 +- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Examples~/Hybrid Simulation Test Project/Packages/manifest.json b/Examples~/Hybrid Simulation Test Project/Packages/manifest.json index 848333a..003392d 100644 --- a/Examples~/Hybrid Simulation Test Project/Packages/manifest.json +++ b/Examples~/Hybrid Simulation Test Project/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.10101software.dots.hybridsimulation": "file:../../..", "com.unity.entities": "0.9.1-preview.15", "com.unity.ide.rider": "1.2.1", "com.unity.render-pipelines.universal": "8.0.1", @@ -11,7 +12,6 @@ "com.unity.modules.physics": "1.0.0", "com.unity.modules.physics2d": "1.0.0", "com.unity.modules.ui": "1.0.0", - "com.unity.modules.uielements": "1.0.0", - "com.10101software.dots.hybridsimulation": "file:../../.." + "com.unity.modules.uielements": "1.0.0" } } diff --git a/Examples~/Hybrid Simulation Test Project/ProjectSettings/ProjectVersion.txt b/Examples~/Hybrid Simulation Test Project/ProjectSettings/ProjectVersion.txt index 6976c8e..6489044 100644 --- a/Examples~/Hybrid Simulation Test Project/ProjectSettings/ProjectVersion.txt +++ b/Examples~/Hybrid Simulation Test Project/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2020.1.0b6 -m_EditorVersionWithRevision: 2020.1.0b6 (255abb3234f8) +m_EditorVersion: 2020.1.0b7 +m_EditorVersionWithRevision: 2020.1.0b7 (6cfebb967dcd) diff --git a/Runtime/Scripts/MonoBehaviours/EntityMonoBehaviour.cs b/Runtime/Scripts/MonoBehaviours/EntityMonoBehaviour.cs index 6654bb5..ddeb638 100644 --- a/Runtime/Scripts/MonoBehaviours/EntityMonoBehaviour.cs +++ b/Runtime/Scripts/MonoBehaviours/EntityMonoBehaviour.cs @@ -72,5 +72,10 @@ internal override void Destroy() { base.Destroy(); } + + /// + /// Called after the PrefabSpawnSystem instantiates the prefab. + /// + internal virtual void PostInstantiate() { } } } diff --git a/Runtime/Scripts/Systems/PrefabSpawnSystem.cs b/Runtime/Scripts/Systems/PrefabSpawnSystem.cs index 83b8fa2..9ffbb74 100644 --- a/Runtime/Scripts/Systems/PrefabSpawnSystem.cs +++ b/Runtime/Scripts/Systems/PrefabSpawnSystem.cs @@ -29,6 +29,8 @@ protected override void OnUpdate() { EntityManager.SetName(entity, instance.name); #endif + instance.PostInstantiate(); + ecb.RemoveComponent(entity); ecb.AddComponent(entity, new GameObjectFlagComponentData()); }) diff --git a/package.json b/package.json index 82f5dce..38c5ac9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.10101software.dots.hybridsimulation", "description": "A framework for using FixedUpdate in a simulation world which is linked to a GameObject-based presentation layer.", - "version": "0.3.2", + "version": "0.3.3", "unity": "2020.1", "displayName": "DOTS Hybrid Simulation Worlds", "dependencies": {