Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by pense_cre · Mar 25, 2020 at 11:35 PM · programmingbug-perhapscompiler errordotserror-building-player

DOTS / ECS: Burst error BC1022: Accessing a managed array is not supported

I am getting the following stack trace on my application, and I am stuck on this. Could someone help me out?

 C:\wkspaces_nvme\PEP 2019.3\Assets\PenseCre\Scripts\GraphSystem_ForEach.cs(57,17): Burst error BC1022: Accessing a managed array is not supported
 
  at GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0.OriginalLambdaBody(GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0* this, ref Unity.Transforms.Translation translation, ref Unity.Transforms.NonUniformScale scale, ref Graph_ForEach graphComponent) (at C:\wkspaces_nvme\PEP 2019.3\Assets\PenseCre\Scripts\GraphSystem_ForEach.cs:57)
  at GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0.IterateEntities(GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0* this, ref Unity.Entities.ArchetypeChunk chunk, ref GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0.LambdaParameterValueProviders.Runtimes runtimes)
  at GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0.Execute(GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0* this, Unity.Entities.ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
  at Unity.Entities.JobChunkExtensions.JobChunkProducer`1<GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0>.ExecuteInternal(ref Unity.Entities.JobChunkExtensions.JobChunkWrapper`1<GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0> jobWrapper, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at C:\wkspaces_nvme\PEP 2019.3\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\IJobChunk.cs:271)
  at Unity.Entities.JobChunkExtensions.JobChunkProducer`1<GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0>.Execute(ref Unity.Entities.JobChunkExtensions.JobChunkWrapper`1<GraphSystem_ForEach.<>c__DisplayClass_OnUpdate_LambdaJob0> jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) (at C:\wkspaces_nvme\PEP 2019.3\Library\PackageCache\com.unity.entities@0.8.0-preview.8\Unity.Entities\IJobChunk.cs:245)
 
 
 While compiling job: System.Void Unity.Entities.JobChunkExtensions/JobChunkProducer`1<GraphSystem_ForEach/<>c__DisplayClass_OnUpdate_LambdaJob0>::Execute(Unity.Entities.JobChunkExtensions/JobChunkWrapper`1<T>&,System.IntPtr,System.IntPtr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,System.Int32)
 at C:\wkspaces_nvme\PEP 2019.3\Assets\PenseCre\Scripts\GraphSystem_ForEach.cs:line 57




I am trying to set a simple and optimised pipeline for using dots to move a bunch of particles around following some simple maths formulas. It works in the editor (image below), but this error will not let it compile.

Application running in the editor

This code used to work a few months ago when I wrote it in Entities 0.0.12-preview.33 / Burst 1.1.2. But of course since then there has been many changes in the way to use the pipeline, and now when refactoring, I am stuck with this error.

That's what I have so far:

 using Unity.Burst;
 using Unity.Collections;
 using Unity.Entities;
 using Unity.Jobs;
 using Unity.Mathematics;
 using Unity.Rendering;
 using Unity.Transforms;
 using static Unity.Mathematics.math;
 
 public delegate void Function(float u, float v, float t, ref float3 val);
 
 public class GraphSystem_ForEach : SystemBase
 {
     #region Declarations
     static readonly Function[] functions = {
         SineFunction, Sine2DFunction, MultiSineFunction, MultiSine2DFunction,
         Ripple, Cylinder, Sphere, Torus
     };
 
     const float PI = math.PI;
     const float E = math.E;
     const double PI_DBL = math.PI_DBL;
     const double E_DBL = math.E_DBL;
     #endregion
 
     protected override void OnUpdate()
     {
         float deltaTime = UnityEngine.Time.deltaTime;
         float time = UnityEngine.Time.time;
         float t = ((UnityEngine.Time.timeSinceLevelLoad % float.MaxValue) - Graph_ForEach.startTime) * Graph_ForEach.speed + Graph_ForEach.offset;
 
         int function = Graph_ForEach.function;
         //Function f = functions[Graph_ForEach.function]; //apparently I can't hold such variable here
         int resolution = Graph_ForEach.resolution;
         float step = 2f / Graph_ForEach.resolution;
         float2 inputPos = Graph_ForEach.inputPos;
 
         quaternion rot = new quaternion();
 
         Entities.ForEach((
             ref Translation translation,
             ref NonUniformScale scale,
             in Graph_ForEach graphComponent)
             =>
         {
             if (graphComponent.colliding == 0)
             {
                 float v = (graphComponent.id.x + 0.5f) * step - 1f;
                 float u = (graphComponent.id.y + 0.5f) * step - 1f;
 
                 functions[function](u, v, t, ref translation.Value);
 
                 ScaleFunction(ref translation.Value, ref scale.Value);
                 //scale.Value = ScaleFunction(translation.Value);
             }
         }).ScheduleParallel();
     }
 
     private static float ScaleFunction(float3 value)
     {
         return length(value) * Graph_ForEach.scaleMult + Graph_ForEach.scaleOffset;
     }
     static void ScaleFunction(float3 translation, ref float3 scale)
     {
         scale = length(translation) * Graph_ForEach.scaleMult + Graph_ForEach.scaleOffset;
     }
     static void ScaleFunction(ref float3 translation, ref float3 scale)
     {
         scale = length(translation) * Graph_ForEach.scaleMult + Graph_ForEach.scaleOffset;
     }
     #region Functions implementation (default from catlikecoding tutorial)
     static void FunctionTemplate(float x, float z, float t, ref float3 val)
     {
         float3 p;
         p.x = x;
         p.y = math.sin(PI * (x + t));
         p.z = z;
         val = p;
     }
 
     static void SineFunction(float x, float z, float t, ref float3 val)
     {
         float3 p;
         p.x = x;
         p.y = math.sin(PI * (x + t));
         p.z = z;
         val = p;
     }
 
     static void MultiSineFunction(float x, float z, float t, ref float3 val)
     {
         float3 p;
         p.x = x;
         p.y = math.sin(PI * (x + t));
         p.y += math.sin(2f * PI * (x + 2f * t)) / 2f;
         p.y *= 2f / 3f;
         p.z = z;
         val = p;
     }
 
     static void Sine2DFunction(float x, float z, float t, ref float3 val)
     {
         float3 p;
         p.x = x;
         p.y = math.sin(PI * (x + t));
         p.y += math.sin(PI * (z + t));
         p.y *= 0.5f;
         p.z = z;
         val = p;
     }
 
     static void MultiSine2DFunction(float x, float z, float t, ref float3 val)
     {
         float3 p;
         p.x = x;
         p.y = 4f * math.sin(PI * (x + z + t / 2f));
         p.y += math.sin(PI * (x + t));
         p.y += math.sin(2f * PI * (z + 2f * t)) * 0.5f;
         p.y *= 1f / 5.5f;
         p.z = z;
         val = p;
     }
 
     static void Ripple(float x, float z, float t, ref float3 val)
     {
         float3 p;
         float d = math.sqrt(x * x + z * z);
         p.x = x;
         p.y = math.sin(PI * (4f * d - t));
         p.y /= 1f + 10f * d;
         p.z = z;
         val = p;
     }
 
     static void Cylinder(float u, float v, float t, ref float3 val)
     {
         float3 p;
         float r = 0.8f + math.sin(PI * (6f * u + 2f * v + t)) * 0.2f;
         p.x = r * math.sin(PI * u);
         p.y = v;
         p.z = r * math.cos(PI * u);
         val = p;
     }
 
     static void Sphere(float u, float v, float t, ref float3 val)
     {
         float3 p;
         float r = 0.8f + math.sin(PI * (6f * u + t)) * 0.1f;
         r += math.sin(PI * (4f * v + t)) * 0.1f;
         float s = r * math.cos(PI * 0.5f * v);
         p.x = s * math.sin(PI * u);
         p.y = r * math.sin(PI * 0.5f * v);
         p.z = s * math.cos(PI * u);
         val = p;
     }
 
     static void Torus(float u, float v, float t, ref float3 val)
     {
         float3 p;
         float r1 = 0.65f + math.sin(PI * (6f * u + t)) * 0.1f;
         float r2 = 0.2f + math.sin(PI * (4f * v + t)) * 0.05f;
         float s = r2 * math.cos(PI * v) + r1;
         p.x = s * math.sin(PI * u);
         p.y = r2 * math.sin(PI * v);
         p.z = s * math.cos(PI * u);
         val = p;
     }
     #endregion
 }



Any help much appreciated

Thanks in advance,

Stay safe

PS.: Sorry, copy/pasting with different line numbers in the forum post. Error points to line 57 in the editor, which is the line 51 here, where it says
functions[function](u, v, t, ref translation.Value);

pensecre-2020325-1052-6147.png (181.1 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

214 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Bizarre compile errors in Unity while Visual Studio will build project successfully 0 Answers

Multiple errors after updating asset package from store 0 Answers

Best loop for counting down a variable after an action 0 Answers

How to make the player can use flutter Jump like Yoshi in Super Mario World? 0 Answers

SpriteRender not loading sprites?,SpriteRender isn't changing the sprite 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges