From 8c56b23f7ab7cfd054fe2f67b46764089c06f74c Mon Sep 17 00:00:00 2001 From: Kaira Date: Wed, 10 Nov 2021 02:06:35 +0600 Subject: [PATCH] Added fixes --- Runtime/MonoHelpers/ConvertToEntity.cs | 26 ++++++++++++++++++++++-- Runtime/World/Systems/WorldInitSystem.cs | 3 +++ package.json | 12 +++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Runtime/MonoHelpers/ConvertToEntity.cs b/Runtime/MonoHelpers/ConvertToEntity.cs index b16d16f..f4e7700 100644 --- a/Runtime/MonoHelpers/ConvertToEntity.cs +++ b/Runtime/MonoHelpers/ConvertToEntity.cs @@ -9,14 +9,17 @@ namespace Voody.UniLeo.Light public enum ConvertMode { ConvertAndInject, - ConvertAndDestroy + ConvertAndDestroy, + ConvertAndSave } public class ConvertToEntity : MonoBehaviour { [SerializeField] private ConvertMode convertMode; // Conversion Mode of ECS [SerializeField] private String customWorld; // World Type of ECS - + private EcsPackedEntity packedEntity; + private EcsWorld spawnWorld; + private void Start() { var world = WorldHandler.GetMainWorld(); // Getting Main World from ECS @@ -39,5 +42,24 @@ public ConvertMode GetConvertMode() { return convertMode; } + + public int? TryGetEntity() + { + if (spawnWorld != null) + { + int entity; + if (packedEntity.Unpack(spawnWorld, out entity)) + { + return entity; + } + } + return null; + } + + public void Set(int entity, EcsWorld world) + { + spawnWorld = world; + packedEntity = EcsEntityExtensions.PackEntity(world, entity); + } } } \ No newline at end of file diff --git a/Runtime/World/Systems/WorldInitSystem.cs b/Runtime/World/Systems/WorldInitSystem.cs index 0424b49..e70e9f3 100644 --- a/Runtime/World/Systems/WorldInitSystem.cs +++ b/Runtime/World/Systems/WorldInitSystem.cs @@ -83,6 +83,9 @@ private void AddEntity(GameObject gameObject, EcsSystems systems, String worldNa case ConvertMode.ConvertAndInject: GameObject.Destroy(convertComponent); break; + case ConvertMode.ConvertAndSave: + convertComponent.Set(entity, spawnWorld); + break; } } } diff --git a/package.json b/package.json index 4d537e3..932dcca 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,21 @@ { - "name": "com.voody.unileo.light", - "displayName": "UniLeo-Light", - "description": "Unity Conversion Workflow for Leopotam ECS Light. Easy convert GameObjects to Entity.", + "name": "com.voody.unileo.lite", + "displayName": "UniLeo-Lite", + "description": "Unity Conversion Workflow for Leopotam ECS Lite. Easy convert GameObjects to Entity.", "unity": "2019.1", - "version": "1.0.0", + "version": "1.1.0", "keywords": [ "leoecs", "ecs", "performance", "voody2506", "UniLeo", - "UniLeo Light" + "UniLeo Lite" ], "dependencies": {}, "repository": { "type": "git", - "url": "https://github.com/voody2506/UniLeo-Light.git" + "url": "https://github.com/voody2506/UniLeo-Lite.git" }, "author": { "name": "Voody2506",