Search Unity

Building ECS with Burst on Android.

Discussion in 'Burst' started by YuriyPopov, Dec 4, 2019.

  1. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    Hi all, I'm trying to build a rather simple ECS example on a android device( The oculus quest) but I'm getting build errors from the compiler. The error is as follows :

    Code (CSharp):
    1. Cannot find the field `TypeInfos` required for supporting TypeManager intrinsics in burst
    2. at Unity.Entities.TypeManager.GetTypeInfo(int typeIndex) (at C:\Users\Uri\SpellPunk\Library\PackageCache\com.unity.entities@0.3.0-preview.4\Unity.Entities\Types\TypeManager.cs:431)
    3.  
    This is the code I'm trying to build :
    Code (CSharp):
    1. using System;
    2. using Unity.Entities;
    3. [Serializable]
    4. public struct MoveComponent : IComponentData
    5. {
    6.     public float MoveSpeed;
    7. }
    8.  
    Code (CSharp):
    1. using Unity.Burst;
    2. using Unity.Collections;
    3. using Unity.Entities;
    4. using Unity.Jobs;
    5. using Unity.Mathematics;
    6. using Unity.Transforms;
    7.  
    8. public class MoveSystem : JobComponentSystem
    9. {
    10.  
    11.     [BurstCompile]
    12.     struct RotationJob : IJobForEach<Rotation, MoveComponent>
    13.     {
    14.         public float DeltaTime;
    15.  
    16.         public void Execute(ref Rotation rotation, [ReadOnly] ref MoveComponent rotationSpeed)
    17.         {
    18.             rotation.Value = math.mul(math.normalize(rotation.Value), quaternion.AxisAngle(math.up(), rotationSpeed.MoveSpeed * DeltaTime));
    19.         }
    20.     }
    21.  
    22.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    23.     {
    24.         RotationJob rotationJob = new RotationJob
    25.         {
    26.             DeltaTime = Time.DeltaTime,
    27.         };
    28.  
    29.         return rotationJob.Schedule(this, inputDeps);
    30.     }
    31. }
    32.  
    Code (CSharp):
    1. using Unity.Collections;
    2. using Unity.Entities;
    3. using Unity.Mathematics;
    4. using Unity.Transforms;
    5. using UnityEngine;
    6. //using Unity.Rendering;
    7. using UnityEngine.UI;
    8.  
    9. public class SystemManager : MonoBehaviour
    10. {
    11.     public GameObject Prefab;
    12.     public int Count;
    13.     public int circleRadius;
    14.     public float RotSpeed;
    15.     private Vector3 origin;
    16.     private EntityManager Manager;
    17.     private int x, y;
    18.     // Start is called before the first frame update
    19.     void Start()
    20.     {
    21.         Manager = World.DefaultGameObjectInjectionWorld.EntityManager;
    22.         origin = new Vector3(4.0f, 3.8f, 0.0f);
    23.         AddCubes();
    24.     }
    25.  
    26.     // Update is called once per frame
    27.   private void AddCubes()
    28.     {
    29.         NativeArray<Entity> cubeEntities = new NativeArray<Entity>(Count, Allocator.Temp);
    30.         var settings = GameObjectConversionSettings.FromWorld(World.DefaultGameObjectInjectionWorld, null);
    31.         Entity prefab = GameObjectConversionUtility.ConvertGameObjectHierarchy(Prefab, settings);
    32.         //Manager.Instantiate(prefab, cubeEntities);
    33.  
    34.         for (int i = 0; i < Count; i++)
    35.         {
    36.          
    37.             for (int j = 0; j < Count; j++)
    38.             {
    39.                 Entity instance = Manager.Instantiate(prefab);
    40.                 Vector3 pos = transform.TransformPoint(new float3(i * 1.3F, noise.cnoise(new float2(i, j) * 0.21F) * 2, j*1.3F));
    41.                 Manager.AddComponentData(instance, new MoveComponent { MoveSpeed = RotSpeed });
    42.                 Manager.SetComponentData(instance, new Translation { Value = pos });
    43.              
    44.  
    45.             }
    46.         }
    47. #if UNITY_EDITOR
    48.         // Name each entity
    49.         for (int i = 0; i < cubeEntities.Length; i++)
    50.         {
    51.             Manager.SetName(cubeEntities[i], "Cube Entity " + i);
    52.         }
    53. #endif
    54.         cubeEntities.Dispose();
    55.     }
    56.  
    I'm a missing something simple or what ?
    Edit: NeverMined I fixed it by updating the burst package to the latest preview
     
    Last edited: Dec 4, 2019