Hi all, I’m trying to use ParticleSystem GetCustomParticleData/SetCustomParticleData, I’ve had this working in 5.6 but don’t have the code in front of me.
I’ve tried this simple example from the Unity docs but when I step through the code GetCustomParticleData always returns vectors of 0,0,0,0
Has anyone tested this lately? I’m on 2017.1.0f3
Code:
using UnityEngine;
using System.Collections.Generic;
public class ExampleClass : MonoBehaviour
{
private ParticleSystem ps;
private List<Vector4> customData = new List<Vector4>();
private int uniqueID;
void Start()
{
ps = GetComponent<ParticleSystem>();
UnityEngine.ParticleSystem.CustomDataModule customData = ps.customData;
customData.enabled = true;
customData.SetMode(ParticleSystemCustomData.Custom1, UnityEngine.ParticleSystemCustomDataMode.Vector);
customData.SetVectorComponentCount(ParticleSystemCustomData.Custom1, 4);
//customData.SetVector(ParticleSystemCustomData.Custom1, 0, 0);
//customData.SetVector(ParticleSystemCustomData.Custom1, 1, 0);
//customData.SetVector(ParticleSystemCustomData.Custom1, 2, 0);
//customData.SetVector(ParticleSystemCustomData.Custom1, 3, 0);
}
void Update()
{
ps.GetCustomParticleData(customData, ParticleSystemCustomData.Custom1);
for (int i = 0; i < customData.Count; i++)
{
// set custom data to the next ID, if it is in the default 0 state
if (customData[i].x == 0.0f)
{
customData[i] = new Vector4(++uniqueID, 0, 0, 0);
}
}
ps.SetCustomParticleData(customData, ParticleSystemCustomData.Custom1);
}
}
TNKS!
G