Search Unity

Question LocalTransform inoperative on Android and iOS but looks well on editor(mac)

Discussion in 'Entity Component System' started by tangs_111, Jan 10, 2023.

  1. tangs_111

    tangs_111

    Joined:
    Jun 22, 2019
    Posts:
    1
    [BurstCompile]
    public void OnUpdate(ref SystemState state)
    {
    var config = SystemAPI.GetSingleton<MonsterSpawningComponent>();
    var ecbSingleton = SystemAPI.GetSingleton<BeginSimulationEntityCommandBufferSystem.Singleton>();
    var ecb = ecbSingleton.CreateCommandBuffer(state.WorldUnmanaged);

    var vehicles = CollectionHelper.CreateNativeArray<Entity>(config.monsterCount, Allocator.Temp);
    ecb.Instantiate(config.monsterPrefab, vehicles);

    var rand = Unity.Mathematics.Random.CreateFromIndex(223);
    foreach (var entity in vehicles)
    {
    var pos = new float3((float)rand.NextDouble() * 14 - 7f, (float)rand.NextDouble() * 7.2f - 3.6f, 0f);
    var transform = LocalTransform.FromPosition(pos);
    transform.Scale = 0.25f;
    ecb.SetComponent(entity, transform);
    // Debug.Log($"x: {pos.x}, y: {pos.y}");
    // var trans = SystemAPI.GetComponent<LocalTransform>(entity);
    // trans.Position = new float3((float)rand.NextDouble() * 14 - 7f, (float)rand.NextDouble() * 7.2f - 7f, 0f);
    }

    // This system should only run once at startup. So it disables itself after one update.
    state.Enabled = false;
    }

    on Editor:
    截屏2023-01-10 14.55.26.png
    on iOS:
    截屏2023-01-10 14.55.56.png

    Entities version: 1.0.0-pre.15
    Unity version: 2022.2.1f1c1