diff --git a/Svelto.Common b/Svelto.Common index cb8cd13..cac26cb 160000 --- a/Svelto.Common +++ b/Svelto.Common @@ -1 +1 @@ -Subproject commit cb8cd139b914f10a0fc5520934d1cb234eea4d76 +Subproject commit cac26cb5f3fd62f6026ea32bc204dbe4da170c0c diff --git a/Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs b/Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs index 730fd10..828e598 100644 --- a/Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs +++ b/Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs @@ -4,7 +4,7 @@ using System.Reflection; namespace Svelto.ECS.Internal { - internal static class SetEGIDWithoutBoxing where T : struct, IEntityStruct + static class SetEGIDWithoutBoxing where T : struct, IEntityStruct { internal delegate void ActionCast(ref T target, EGID egid); @@ -14,6 +14,7 @@ namespace Svelto.ECS.Internal { if (EntityBuilder.HAS_EGID) { +#if !ENABLE_IL2CPP Type myTypeA = typeof(T); PropertyInfo myFieldInfo = myTypeA.GetProperty("ID"); @@ -25,6 +26,14 @@ namespace Svelto.ECS.Internal var setter = Expression.Lambda(assignExp, targetExp, valueExp).Compile(); return setter; +#else + return (ref T target, EGID value) => + { + var needEgid = (target as INeedEGID); + needEgid.ID = value; + target = (T) needEgid; + }; +#endif } return null; diff --git a/Svelto.ECS/EnginesRoot.Entities.cs b/Svelto.ECS/EnginesRoot.Entities.cs index 518ac13..08e3ffc 100644 --- a/Svelto.ECS/EnginesRoot.Entities.cs +++ b/Svelto.ECS/EnginesRoot.Entities.cs @@ -41,6 +41,7 @@ namespace Svelto.ECS _entitiesOperations.Clear(); _transientEntitiesOperations.Clear(); + _scheduler.Dispose(); #if DEBUG && !PROFILER _idCheckers.Clear(); #endif diff --git a/Svelto.ECS/EntityBuilder.CheckFields.cs b/Svelto.ECS/EntityBuilder.CheckFields.cs index 99b7d0e..f1f2d25 100644 --- a/Svelto.ECS/EntityBuilder.CheckFields.cs +++ b/Svelto.ECS/EntityBuilder.CheckFields.cs @@ -15,7 +15,7 @@ namespace Svelto.ECS #if DISABLE_CHECKS [Conditional("_CHECKS_DISABLED")] #endif - public static void CheckFields(Type entityStructType, bool needsReflection) + public static void CheckFields(Type entityStructType, bool needsReflection, bool isStringAllowed = false) { if (entityStructType == ENTITY_STRUCT_INFO_VIEW || entityStructType == EGIDType || @@ -39,7 +39,7 @@ namespace Svelto.ECS FieldInfo fieldInfo = fields[i]; Type fieldType = fieldInfo.FieldType; - SubCheckFields(fieldType, entityStructType); + SubCheckFields(fieldType, entityStructType, isStringAllowed); } } else @@ -62,9 +62,7 @@ namespace Svelto.ECS } PropertyInfo[] properties = fieldInfo.FieldType.GetProperties( - BindingFlags.Public | - BindingFlags.Instance | - BindingFlags.DeclaredOnly); + BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); for (int j = properties.Length - 1; j >= 0; --j) { @@ -81,25 +79,27 @@ namespace Svelto.ECS Type propertyType = properties[j].PropertyType; if (propertyType != STRINGTYPE) { - SubCheckFields(propertyType, entityStructType); + //for EntityViewStructs, component fields that are structs that hold strings + //are allowed + SubCheckFields(propertyType, entityStructType, isStringAllowed: true); } } } } } - static void SubCheckFields(Type fieldType, Type entityStructType) + static void SubCheckFields(Type fieldType, Type entityStructType, bool isStringAllowed = false) { - if (fieldType.IsPrimitive || fieldType.IsValueType) + if (fieldType.IsPrimitive || fieldType.IsValueType || (isStringAllowed == true && fieldType == STRINGTYPE)) { if (fieldType.IsValueType && !fieldType.IsEnum && fieldType.IsPrimitive == false) { - CheckFields(fieldType, false); + CheckFields(fieldType, false, isStringAllowed); } return; } - + ProcessError(MSG, entityStructType, fieldType); } diff --git a/Svelto.ECS/EntitySubmissionScheduler.cs b/Svelto.ECS/EntitySubmissionScheduler.cs index 5ddc91a..e6d0ffc 100644 --- a/Svelto.ECS/EntitySubmissionScheduler.cs +++ b/Svelto.ECS/EntitySubmissionScheduler.cs @@ -1,6 +1,8 @@ +using System; + namespace Svelto.ECS.Schedulers { - public interface IEntitySubmissionScheduler + public interface IEntitySubmissionScheduler: IDisposable { EnginesRoot.EntitiesSubmitter onTick { set; } } diff --git a/Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs b/Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs index be60f78..4f4e120 100644 --- a/Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs +++ b/Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs @@ -8,7 +8,7 @@ namespace Svelto.ECS.Schedulers.Unity { //The EntitySubmissionScheduler has been introduced to make the entity views submission logic platform independent //You can customize the scheduler if you wish - public class UnityEntitySubmissionScheduler : IEntitySubmissionScheduler, IDisposable + public class UnityEntitySubmissionScheduler : IEntitySubmissionScheduler { class Scheduler : MonoBehaviour { @@ -27,7 +27,7 @@ namespace Svelto.ECS.Schedulers.Unity while (true) { yield return _wait; - + onTick.Invoke(); } } @@ -49,8 +49,12 @@ namespace Svelto.ECS.Schedulers.Unity { set { - if (_scheduler == null) _scheduler = new GameObject(_name).AddComponent(); - + if (_scheduler == null) + { + _scheduler = new GameObject(_name).AddComponent(); + GameObject.DontDestroyOnLoad(_scheduler.gameObject); + } + _scheduler.onTick = value; } } diff --git a/Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs b/Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs index 7735e1c..e2fe657 100644 --- a/Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs +++ b/Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs @@ -17,5 +17,9 @@ namespace Svelto.ECS } EnginesRoot.EntitiesSubmitter _onTick; + + public void Dispose() + { + } } } \ No newline at end of file