You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
3.0.0-preview.19
# [3.0.0-preview.19](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.18...v3.0.0-preview.19) (2020-08-28) ### Bug Fixes * baking camera settings for camera space ([436c5e4](436c5e47f7)) * fix local simulation ([7add9de](7add9defb7)) ### Features * add menu to create UIParticle ([2fa1843](2fa18431f0)) * add play/pause/stop api ([f09a386](f09a386bc5)) * support for changing rendering orders ([745d4a5](745d4a5988)) * Support for child ParticleSystem rendering ([4ee90be](4ee90be17c)) * UIParticle for trail is no longer needed ([466e43c](466e43cf93)) ### BREAKING CHANGES * The child UIParticle is no longer needed.
This commit is contained in:
@@ -2,7 +2,8 @@ using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Coffee.UIExtensions
|
||||
{
|
||||
@@ -13,17 +14,13 @@ namespace Coffee.UIExtensions
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
private static readonly GUIContent s_ContentParticleMaterial = new GUIContent("Particle Material", "The material for rendering particles");
|
||||
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail Material", "The material for rendering particle trails");
|
||||
private static readonly GUIContent s_ContentAdvancedOptions = new GUIContent("Advanced Options");
|
||||
private static readonly GUIContent s_Content3D = new GUIContent("3D");
|
||||
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
|
||||
private static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem>();
|
||||
|
||||
private SerializedProperty _spParticleSystem;
|
||||
private SerializedProperty _spScale3D;
|
||||
private SerializedProperty _spScale;
|
||||
private SerializedProperty _spIgnoreCanvasScaler;
|
||||
private SerializedProperty _spAnimatableProperties;
|
||||
|
||||
private ReorderableList _ro;
|
||||
private bool _xyzMode;
|
||||
|
||||
private static readonly List<string> s_MaskablePropertyNames = new List<string>
|
||||
@@ -46,10 +43,30 @@ namespace Coffee.UIExtensions
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_spParticleSystem = serializedObject.FindProperty("m_ParticleSystem");
|
||||
_spScale3D = serializedObject.FindProperty("m_Scale3D");
|
||||
_spScale = serializedObject.FindProperty("m_Scale");
|
||||
_spIgnoreCanvasScaler = serializedObject.FindProperty("m_IgnoreCanvasScaler");
|
||||
_spAnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
||||
|
||||
var sp = serializedObject.FindProperty("m_Particles");
|
||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, false, false);
|
||||
_ro.elementHeight = EditorGUIUtility.singleLineHeight + 4;
|
||||
_ro.drawElementCallback = (rect, index, active, focused) =>
|
||||
{
|
||||
rect.y += 1;
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
EditorGUI.PropertyField(rect, sp.GetArrayElementAtIndex(index), GUIContent.none);
|
||||
};
|
||||
_ro.drawHeaderCallback += rect =>
|
||||
{
|
||||
EditorGUI.LabelField(new Rect(rect.x, rect.y, 150, rect.height), "Rendering Order");
|
||||
|
||||
if (!GUI.Button(new Rect(rect.width - 80, rect.y - 1, 80, rect.height), "Reset", EditorStyles.miniButton)) return;
|
||||
|
||||
foreach (UIParticle t in targets)
|
||||
{
|
||||
t.RefreshParticles();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,119 +79,40 @@ namespace Coffee.UIExtensions
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spParticleSystem);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
// Draw materials.
|
||||
EditorGUI.indentLevel++;
|
||||
var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;
|
||||
if (ps != null)
|
||||
{
|
||||
var pr = ps.GetComponent<ParticleSystemRenderer>();
|
||||
var sp = new SerializedObject(pr).FindProperty("m_Materials");
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
{
|
||||
EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), s_ContentParticleMaterial);
|
||||
if (2 <= sp.arraySize)
|
||||
{
|
||||
EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), s_ContentTrailMaterial);
|
||||
}
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
sp.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
if (!Application.isPlaying && pr.enabled)
|
||||
{
|
||||
EditorGUILayout.HelpBox("UIParticles disable the RendererModule in ParticleSystem at runtime to prevent double rendering.", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
// Advanced Options
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField(s_ContentAdvancedOptions, EditorStyles.boldLabel);
|
||||
|
||||
_xyzMode = DrawFloatOrVector3Field(_spScale3D, _xyzMode);
|
||||
|
||||
// IgnoreCanvasScaler
|
||||
EditorGUILayout.PropertyField(_spIgnoreCanvasScaler);
|
||||
|
||||
// Scale
|
||||
EditorGUILayout.PropertyField(_spScale);
|
||||
|
||||
// AnimatableProperties
|
||||
AnimatedPropertiesEditor.DrawAnimatableProperties(_spAnimatableProperties, current.material);
|
||||
|
||||
// Fix
|
||||
current.GetComponentsInChildren(true, s_ParticleSystems);
|
||||
if (s_ParticleSystems.Any(x => x.GetComponent<UIParticle>() == null))
|
||||
_ro.DoLayoutList();
|
||||
|
||||
// Does the shader support UI masks?
|
||||
if (current.maskable && current.GetComponentInParent<Mask>())
|
||||
{
|
||||
GUILayout.BeginHorizontal();
|
||||
EditorGUILayout.HelpBox("There are child ParticleSystems that does not have a UIParticle component.\nAdd UIParticle component to them.", MessageType.Warning);
|
||||
GUILayout.BeginVertical();
|
||||
if (GUILayout.Button("Fix"))
|
||||
foreach (var mat in current.materials)
|
||||
{
|
||||
foreach (var p in s_ParticleSystems.Where(x => !x.GetComponent<UIParticle>()))
|
||||
if (!mat || !mat.shader) continue;
|
||||
var shader = mat.shader;
|
||||
foreach (var propName in s_MaskablePropertyNames)
|
||||
{
|
||||
p.gameObject.AddComponent<UIParticle>();
|
||||
if (mat.HasProperty(propName)) continue;
|
||||
|
||||
EditorGUILayout.HelpBox(string.Format("Shader '{0}' doesn't have '{1}' property. This graphic cannot be masked.", shader.name, propName), MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.EndVertical();
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
s_ParticleSystems.Clear();
|
||||
|
||||
// Does the shader support UI masks?
|
||||
if (current.maskable && current.material && current.material.shader)
|
||||
{
|
||||
var mat = current.material;
|
||||
var shader = mat.shader;
|
||||
foreach (var propName in s_MaskablePropertyNames)
|
||||
{
|
||||
if (mat.HasProperty(propName)) continue;
|
||||
|
||||
EditorGUILayout.HelpBox(string.Format("Shader '{0}' doesn't have '{1}' property. This graphic cannot be masked.", shader.name, propName), MessageType.Warning);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private static bool DrawFloatOrVector3Field(SerializedProperty sp, bool showXyz)
|
||||
{
|
||||
var x = sp.FindPropertyRelative("x");
|
||||
var y = sp.FindPropertyRelative("y");
|
||||
var z = sp.FindPropertyRelative("z");
|
||||
|
||||
showXyz |= !Mathf.Approximately(x.floatValue, y.floatValue) ||
|
||||
!Mathf.Approximately(y.floatValue, z.floatValue) ||
|
||||
y.hasMultipleDifferentValues ||
|
||||
z.hasMultipleDifferentValues;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
if (showXyz)
|
||||
{
|
||||
EditorGUILayout.PropertyField(sp);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(x, s_ContentScale);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
z.floatValue = y.floatValue = x.floatValue;
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
showXyz = GUILayout.Toggle(showXyz, s_Content3D, EditorStyles.miniButton, GUILayout.Width(30));
|
||||
if (EditorGUI.EndChangeCheck() && !showXyz)
|
||||
z.floatValue = y.floatValue = x.floatValue;
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
return showXyz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user