public override void OnInspectorGUI() { CanvasParticleSystem system = (CanvasParticleSystem)target; system.material = (Material)EditorGUILayout.ObjectField("Material", system.material, typeof(Material), false); Texture inputTexture = (Texture)EditorGUILayout.ObjectField("Texture", system.texture, typeof(Texture), false); if (ReferenceEquals(inputTexture, system.texture) == false) { system.texture = inputTexture; system.UpdateMaterial(); } #if CANVAS_PFX_JOBS EditorGUI.BeginDisabledGroup(false); #else GUIStyle style = GUI.skin.GetStyle("HelpBox"); style.richText = true; EditorGUILayout.TextArea("Unity Jobs is are not enabled: Install the <b>Jobs</b> and <b>Burst</b> packages in the Package Manager, " + "\nthen apply the compilation symbol to the Player Settings.", style); if (GUILayout.Button("Add \"CANVAS_PFX_JOBS\" symbol to Player Settings")) { Debug.Log("AddDefineSymbols CANVAS_PFX_JOBS"); DefineSymbolsUtils.AddDefineSymbols(new[] { "CANVAS_PFX_JOBS" }); } EditorGUI.BeginDisabledGroup(true); #endif system.useJobs = EditorGUILayout.Toggle("Convert to mesh using Jobs", system.useJobs); EditorGUI.EndDisabledGroup(); }
public void Execute() { for (int i = 0; i < activeCount; i++) { ParticleSystem.Particle particle = particles[i]; float timeAlive = particle.startLifetime - particle.remainingLifetime; float normalizedLifetime = Mathf.Clamp01(timeAlive / particle.startLifetime); float size = startSize * sizeCurve.Evaluate(normalizedLifetime); Color32 color32 = colorGradient.Evaluate(normalizedLifetime); CanvasParticleSystem.GetPositions(particle, isWorldSpace, Vector3.one * size, transformMatrix, out Vector3 p0, out Vector3 p1, out Vector3 p2, out Vector3 p3); CanvasParticleSystem.CalculateUvs(out Vector2 c0, out Vector2 c1, out Vector2 c2, out Vector2 c3); int vertexIndex = i * 4; int v0 = vertexIndex; int v1 = vertexIndex + 1; int v2 = vertexIndex + 2; int v3 = vertexIndex + 3; vertices[v0] = p0; vertices[v1] = p1; vertices[v2] = p2; vertices[v3] = p3; colors[v0] = color32; colors[v1] = color32; colors[v2] = color32; colors[v3] = color32; coords[v0] = c0; coords[v1] = c1; coords[v2] = c2; coords[v3] = c3; int triangleIndex = i * 6; triangles[triangleIndex] = v0; triangles[triangleIndex + 1] = v1; triangles[triangleIndex + 2] = v2; triangles[triangleIndex + 3] = v2; triangles[triangleIndex + 4] = v3; triangles[triangleIndex + 5] = v0; } }