Hello, I have a script that randomize the trail renderer colors each time I instantiate a new one.
The problem is that the only way I can change the colors is via SerializedObject.
public void RandomizeColor(TrailRenderer trailr) {
SerializedObject so = new SerializedObject(trailr);
so.FindProperty("m_Colors.m_Color[0]").colorValue = new Color(Random.value, Random.value, Random.value, 1);
so.FindProperty("m_Colors.m_Color[1]").colorValue = new Color(Random.value, Random.value, Random.value, 1);
so.FindProperty("m_Colors.m_Color[2]").colorValue = new Color(Random.value, Random.value, Random.value, 1);
so.FindProperty("m_Colors.m_Color[3]").colorValue = new Color(Random.value, Random.value, Random.value, 1);
so.FindProperty("m_Colors.m_Color[4]").colorValue = new Color(Random.value, Random.value, Random.value, 1);
so.ApplyModifiedProperties();
}
Then I use this method later on in the script. So it wprks but I can’t build it as I’m using UnityEditor.
So my question is how do I work around that to be able to build the project.