feat: random mesh sharing group
The mesh sharing group id will be selected randomly.pull/225/head
parent
9afeebf672
commit
4fa43eda4b
|
@ -50,6 +50,7 @@ namespace Coffee.UIExtensions
|
||||||
private static readonly GUIContent s_ContentMaterial = new GUIContent("Material");
|
private static readonly GUIContent s_ContentMaterial = new GUIContent("Material");
|
||||||
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail Material");
|
private static readonly GUIContent s_ContentTrailMaterial = new GUIContent("Trail Material");
|
||||||
private static readonly GUIContent s_Content3D = new GUIContent("3D");
|
private static readonly GUIContent s_Content3D = new GUIContent("3D");
|
||||||
|
private static readonly GUIContent s_ContentRandom = new GUIContent("Random");
|
||||||
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
|
private static readonly GUIContent s_ContentScale = new GUIContent("Scale");
|
||||||
private static SerializedObject s_SerializedObject;
|
private static SerializedObject s_SerializedObject;
|
||||||
|
|
||||||
|
@ -60,9 +61,12 @@ namespace Coffee.UIExtensions
|
||||||
private SerializedProperty m_AnimatableProperties;
|
private SerializedProperty m_AnimatableProperties;
|
||||||
private SerializedProperty m_MeshSharing;
|
private SerializedProperty m_MeshSharing;
|
||||||
private SerializedProperty m_GroupId;
|
private SerializedProperty m_GroupId;
|
||||||
|
private SerializedProperty m_GroupMaxId;
|
||||||
|
|
||||||
|
|
||||||
private ReorderableList _ro;
|
private ReorderableList _ro;
|
||||||
static private bool _xyzMode;
|
static private bool _xyzMode;
|
||||||
|
private bool _showMax;
|
||||||
|
|
||||||
private static readonly List<string> s_MaskablePropertyNames = new List<string>
|
private static readonly List<string> s_MaskablePropertyNames = new List<string>
|
||||||
{
|
{
|
||||||
|
@ -137,6 +141,7 @@ namespace Coffee.UIExtensions
|
||||||
m_AnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
m_AnimatableProperties = serializedObject.FindProperty("m_AnimatableProperties");
|
||||||
m_MeshSharing = serializedObject.FindProperty("m_MeshSharing");
|
m_MeshSharing = serializedObject.FindProperty("m_MeshSharing");
|
||||||
m_GroupId = serializedObject.FindProperty("m_GroupId");
|
m_GroupId = serializedObject.FindProperty("m_GroupId");
|
||||||
|
m_GroupMaxId = serializedObject.FindProperty("m_GroupMaxId");
|
||||||
|
|
||||||
var sp = serializedObject.FindProperty("m_Particles");
|
var sp = serializedObject.FindProperty("m_Particles");
|
||||||
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
_ro = new ReorderableList(sp.serializedObject, sp, true, true, true, true);
|
||||||
|
@ -232,7 +237,16 @@ namespace Coffee.UIExtensions
|
||||||
AnimatedPropertiesEditor.DrawAnimatableProperties(m_AnimatableProperties, mats);
|
AnimatedPropertiesEditor.DrawAnimatableProperties(m_AnimatableProperties, mats);
|
||||||
|
|
||||||
// Mesh sharing
|
// Mesh sharing
|
||||||
DrawMeshSharing();
|
EditorGUI.BeginChangeCheck();
|
||||||
|
_showMax = DrawMeshSharing(m_MeshSharing, m_GroupId, m_GroupMaxId, _showMax);
|
||||||
|
if (EditorGUI.EndChangeCheck())
|
||||||
|
{
|
||||||
|
serializedObject.ApplyModifiedProperties();
|
||||||
|
foreach (var uip in targets.OfType<UIParticle>())
|
||||||
|
{
|
||||||
|
uip.ResetGroupId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Target ParticleSystems.
|
// Target ParticleSystems.
|
||||||
_ro.DoLayoutList();
|
_ro.DoLayoutList();
|
||||||
|
@ -281,20 +295,38 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawMeshSharing()
|
private static bool DrawMeshSharing(SerializedProperty spMeshSharing, SerializedProperty spGroupId, SerializedProperty spGroupMaxId, bool showMax)
|
||||||
{
|
{
|
||||||
EditorGUILayout.PropertyField(m_MeshSharing);
|
showMax |= spGroupId.intValue != spGroupMaxId.intValue ||
|
||||||
EditorGUI.BeginDisabledGroup(m_MeshSharing.intValue == 0);
|
spGroupId.hasMultipleDifferentValues ||
|
||||||
|
spGroupMaxId.hasMultipleDifferentValues;
|
||||||
|
|
||||||
|
EditorGUILayout.BeginHorizontal();
|
||||||
|
EditorGUILayout.PropertyField(spMeshSharing);
|
||||||
|
|
||||||
|
EditorGUI.BeginChangeCheck();
|
||||||
|
showMax = GUILayout.Toggle(showMax, s_ContentRandom, EditorStyles.miniButton, GUILayout.Width(60));
|
||||||
|
if (EditorGUI.EndChangeCheck() && !showMax)
|
||||||
|
spGroupMaxId.intValue = spGroupId.intValue;
|
||||||
|
EditorGUILayout.EndHorizontal();
|
||||||
|
|
||||||
|
EditorGUI.BeginDisabledGroup(spMeshSharing.intValue == 0);
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
EditorGUILayout.PropertyField(m_GroupId);
|
EditorGUILayout.PropertyField(spGroupId);
|
||||||
if (m_MeshSharing.intValue == 1 || m_MeshSharing.intValue == 4)
|
if (showMax)
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField(spGroupMaxId);
|
||||||
|
}
|
||||||
|
else if (spMeshSharing.intValue == 1 || spMeshSharing.intValue == 4)
|
||||||
{
|
{
|
||||||
EditorGUI.BeginDisabledGroup(true);
|
EditorGUI.BeginDisabledGroup(true);
|
||||||
EditorGUILayout.ObjectField("Primary", UIParticleUpdater.GetPrimary(m_GroupId.intValue), typeof(UIParticle), false);
|
EditorGUILayout.ObjectField("Primary", UIParticleUpdater.GetPrimary(spGroupId.intValue), typeof(UIParticle), false);
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
}
|
}
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
|
return showMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WindowFunction(UnityEngine.Object target, SceneView sceneView)
|
private static void WindowFunction(UnityEngine.Object target, SceneView sceneView)
|
||||||
|
|
|
@ -51,6 +51,9 @@ namespace Coffee.UIExtensions
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int m_GroupId = 0;
|
private int m_GroupId = 0;
|
||||||
|
|
||||||
|
[SerializeField]
|
||||||
|
private int m_GroupMaxId = 0;
|
||||||
|
|
||||||
private List<UIParticleRenderer> m_Renderers = new List<UIParticleRenderer>();
|
private List<UIParticleRenderer> m_Renderers = new List<UIParticleRenderer>();
|
||||||
|
|
||||||
#if !SERIALIZE_FIELD_MASKABLE
|
#if !SERIALIZE_FIELD_MASKABLE
|
||||||
|
@ -59,6 +62,7 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
private DrivenRectTransformTracker _tracker;
|
private DrivenRectTransformTracker _tracker;
|
||||||
private Camera _orthoCamera;
|
private Camera _orthoCamera;
|
||||||
|
private int _groupId;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Should this graphic be considered a target for raycasting?
|
/// Should this graphic be considered a target for raycasting?
|
||||||
|
@ -87,8 +91,25 @@ namespace Coffee.UIExtensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int groupId
|
public int groupId
|
||||||
{
|
{
|
||||||
get { return m_GroupId; }
|
get { return _groupId; }
|
||||||
set { m_GroupId = value; }
|
set
|
||||||
|
{
|
||||||
|
if (m_GroupId == value) return;
|
||||||
|
m_GroupId = value;
|
||||||
|
if (m_GroupId != m_GroupMaxId)
|
||||||
|
ResetGroupId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int groupMaxId
|
||||||
|
{
|
||||||
|
get { return m_GroupMaxId; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (m_GroupMaxId == value) return;
|
||||||
|
m_GroupMaxId = value;
|
||||||
|
ResetGroupId();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool useMeshSharing
|
internal bool useMeshSharing
|
||||||
|
@ -295,6 +316,7 @@ namespace Coffee.UIExtensions
|
||||||
#if !SERIALIZE_FIELD_MASKABLE
|
#if !SERIALIZE_FIELD_MASKABLE
|
||||||
maskable = m_Maskable;
|
maskable = m_Maskable;
|
||||||
#endif
|
#endif
|
||||||
|
ResetGroupId();
|
||||||
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
|
_tracker.Add(this, rectTransform, DrivenTransformProperties.Scale);
|
||||||
UIParticleUpdater.Register(this);
|
UIParticleUpdater.Register(this);
|
||||||
RegisterDirtyMaterialCallback(UpdateRendererMaterial);
|
RegisterDirtyMaterialCallback(UpdateRendererMaterial);
|
||||||
|
@ -303,6 +325,18 @@ namespace Coffee.UIExtensions
|
||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void ResetGroupId()
|
||||||
|
{
|
||||||
|
if (m_GroupId == m_GroupMaxId)
|
||||||
|
{
|
||||||
|
_groupId = m_GroupId;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_groupId = Random.Range(m_GroupId, m_GroupMaxId + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is called when the behaviour becomes disabled.
|
/// This function is called when the behaviour becomes disabled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue