Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question writing to customData1 in ParticleSystemJobData

Discussion in 'C# Job System' started by tillholzapfel, Feb 22, 2023.

  1. tillholzapfel

    tillholzapfel

    Joined:
    Oct 29, 2020
    Posts:
    4
    SOLVED: Tick off the custom data module in the inspector and everything works as intended.

    Hey there, can anyone help me out how to set the values of customData1 within an IJobParticleSystem? I can read from it, but when I try to assign a new value to it (the same way I do for positions, velocity and color) it seems to get reset after the job finished executing. customData.png customData_console.png
     
    Last edited: Feb 22, 2023
  2. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Haven't personally looked at the ParticleSystem in Jobs yet.. But if it's anything like the normal (MonoBehaviour-based) ParticleSystems, then you might need to set it back to particles.

    Code (CSharp):
    1. var customData1 = particles.customData1;
    2. // Do Changes
    3. customData1.val1 = i;
    4. // Set back
    5. particles.customData1 = customData1;
     
  3. tillholzapfel

    tillholzapfel

    Joined:
    Oct 29, 2020
    Posts:
    4
    unfortunately anything particles. within a job is not assignable. It might simply be that it works for position etc. because they have a direct influence on the scene, which customData1 does not. I`ll probably have to do my customData related computation outside the job.
     
  4. tillholzapfel

    tillholzapfel

    Joined:
    Oct 29, 2020
    Posts:
    4
    Ok my mistake, everything seems to work just as I originally intended as long as I have the custom data module tickt off in the inspector, which otherwise would of cause override my changes in script