Browse Source

Fix WebGL/IL2CPP mistakes

tags/2.9.1
sebas77 5 years ago
parent
commit
27185629db
7 changed files with 37 additions and 17 deletions
  1. +1
    -1
      Svelto.Common
  2. +10
    -1
      Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs
  3. +1
    -0
      Svelto.ECS/EnginesRoot.Entities.cs
  4. +10
    -10
      Svelto.ECS/EntityBuilder.CheckFields.cs
  5. +3
    -1
      Svelto.ECS/EntitySubmissionScheduler.cs
  6. +8
    -4
      Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs
  7. +4
    -0
      Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs

+ 1
- 1
Svelto.Common

@@ -1 +1 @@
Subproject commit cb8cd139b914f10a0fc5520934d1cb234eea4d76
Subproject commit cac26cb5f3fd62f6026ea32bc204dbe4da170c0c

+ 10
- 1
Svelto.ECS/DataStructures/SetEGIDWithoutBoxing.cs View File

@@ -4,7 +4,7 @@ using System.Reflection;

namespace Svelto.ECS.Internal
{
internal static class SetEGIDWithoutBoxing<T> where T : struct, IEntityStruct
static class SetEGIDWithoutBoxing<T> where T : struct, IEntityStruct
{
internal delegate void ActionCast(ref T target, EGID egid);

@@ -14,6 +14,7 @@ namespace Svelto.ECS.Internal
{
if (EntityBuilder<T>.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<ActionCast>(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;


+ 1
- 0
Svelto.ECS/EnginesRoot.Entities.cs View File

@@ -41,6 +41,7 @@ namespace Svelto.ECS

_entitiesOperations.Clear();
_transientEntitiesOperations.Clear();
_scheduler.Dispose();
#if DEBUG && !PROFILER
_idCheckers.Clear();
#endif


+ 10
- 10
Svelto.ECS/EntityBuilder.CheckFields.cs View File

@@ -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);
}



+ 3
- 1
Svelto.ECS/EntitySubmissionScheduler.cs View File

@@ -1,6 +1,8 @@
using System;

namespace Svelto.ECS.Schedulers
{
public interface IEntitySubmissionScheduler
public interface IEntitySubmissionScheduler: IDisposable
{
EnginesRoot.EntitiesSubmitter onTick { set; }
}

+ 8
- 4
Svelto.ECS/Extensions/Unity/UnityEntitySubmissionScheduler.cs View File

@@ -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<Scheduler>();
if (_scheduler == null)
{
_scheduler = new GameObject(_name).AddComponent<Scheduler>();
GameObject.DontDestroyOnLoad(_scheduler.gameObject);
}

_scheduler.onTick = value;
}
}


+ 4
- 0
Svelto.ECS/SimpleSubmissionEntityViewScheduler.cs View File

@@ -17,5 +17,9 @@ namespace Svelto.ECS
}
EnginesRoot.EntitiesSubmitter _onTick;

public void Dispose()
{
}
}
}

Loading…
Cancel
Save