Hi all !
When I access to a BlobArray in a for loop the result seems always wrong.
I wrote a simple test with a blobarray { 0,1,2 } and the first blobarray[0] return 8.
Anyone meets that before ?
I did bug report (1186219) but if you have a workaround because I’m block for now because of this
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using UnityEngine;
namespace MyNamespace
{
public struct blolData
{
public int valueInt;
public RenderMode renderMode;
public BlobArray<int> MyArray;
}
public class Test
{
[Test]
public void MyTest()
{
BlobAssetReference<blolData> blob;
using (var builder = new BlobBuilder(Allocator.Temp))
{
ref var root = ref builder.ConstructRoot<blolData>();
var targetBlobArray = builder.Allocate(ref root.MyArray, 3);
for (var i = 0; i < targetBlobArray.Length; i++)
targetBlobArray[i] = i;
root.renderMode = RenderMode.ScreenSpaceOverlay;
root.valueInt= 789;
blob = builder.CreateBlobAssetReference<blolData>(Allocator.TempJob);
}
new DebugJob {blob = blob}.Schedule().Complete();
}
public struct DebugJob : IJob
{
/// <inheritdoc />
public void Execute()
{
var array = blob.Value.MyArray;
for (int i = 0; i < array.Length; i++)
{
Assert.AreEqual(i , array[i]);
}
}
public BlobAssetReference<blolData> blob;
}
}
}
4991216–487349–BlobArrayBug.zip (20 KB)