close #11; Easy setup in editor
parent
dfc173ad91
commit
820432b0db
|
@ -1,6 +1,8 @@
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
using UnityEditor.UI;
|
using UnityEditor.UI;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Coffee.UIExtensions
|
namespace Coffee.UIExtensions
|
||||||
{
|
{
|
||||||
|
@ -13,7 +15,8 @@ namespace Coffee.UIExtensions
|
||||||
//################################
|
//################################
|
||||||
static readonly GUIContent contentParticleMaterial = new GUIContent ("Particle Material", "The material for rendering particles");
|
static readonly GUIContent contentParticleMaterial = new GUIContent ("Particle Material", "The material for rendering particles");
|
||||||
static readonly GUIContent contentTrailMaterial = new GUIContent ("Trail Material", "The material for rendering particle trails");
|
static readonly GUIContent contentTrailMaterial = new GUIContent ("Trail Material", "The material for rendering particle trails");
|
||||||
|
static readonly List<UIParticle> s_UIParticles = new List<UIParticle> ();
|
||||||
|
static readonly List<ParticleSystem> s_ParticleSystems = new List<ParticleSystem> ();
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
// Public/Protected Members.
|
// Public/Protected Members.
|
||||||
|
@ -26,6 +29,8 @@ namespace Coffee.UIExtensions
|
||||||
base.OnEnable ();
|
base.OnEnable ();
|
||||||
_spParticleSystem = serializedObject.FindProperty ("m_ParticleSystem");
|
_spParticleSystem = serializedObject.FindProperty ("m_ParticleSystem");
|
||||||
_spTrailParticle = serializedObject.FindProperty ("m_TrailParticle");
|
_spTrailParticle = serializedObject.FindProperty ("m_TrailParticle");
|
||||||
|
_spScale = serializedObject.FindProperty ("m_Scale");
|
||||||
|
_spIgnoreParent = serializedObject.FindProperty ("m_IgnoreParent");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -58,11 +63,31 @@ namespace Coffee.UIExtensions
|
||||||
EditorGUILayout.PropertyField (_spTrailParticle);
|
EditorGUILayout.PropertyField (_spTrailParticle);
|
||||||
EditorGUI.EndDisabledGroup ();
|
EditorGUI.EndDisabledGroup ();
|
||||||
|
|
||||||
if ((target as UIParticle).GetComponentsInParent<UIParticle> (false).Length == 1)
|
var current = target as UIParticle;
|
||||||
|
|
||||||
|
EditorGUILayout.PropertyField (_spIgnoreParent);
|
||||||
|
|
||||||
|
EditorGUI.BeginDisabledGroup (!current.isRoot);
|
||||||
|
EditorGUILayout.PropertyField (_spScale);
|
||||||
|
EditorGUI.EndDisabledGroup ();
|
||||||
|
|
||||||
|
current.GetComponentsInChildren<ParticleSystem> (true, s_ParticleSystems);
|
||||||
|
if (s_ParticleSystems.Any (x => x.GetComponent<UIParticle> () == null))
|
||||||
{
|
{
|
||||||
EditorGUILayout.PropertyField (serializedObject.FindProperty ("m_Scale"));
|
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 p in s_ParticleSystems.Where (x => !x.GetComponent<UIParticle> ()))
|
||||||
|
{
|
||||||
|
p.gameObject.AddComponent<UIParticle> ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUILayout.EndVertical ();
|
||||||
|
GUILayout.EndHorizontal ();
|
||||||
}
|
}
|
||||||
EditorGUILayout.PropertyField (serializedObject.FindProperty ("m_IgnoreParent"));
|
s_ParticleSystems.Clear ();
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties ();
|
serializedObject.ApplyModifiedProperties ();
|
||||||
}
|
}
|
||||||
|
@ -72,5 +97,7 @@ namespace Coffee.UIExtensions
|
||||||
//################################
|
//################################
|
||||||
SerializedProperty _spParticleSystem;
|
SerializedProperty _spParticleSystem;
|
||||||
SerializedProperty _spTrailParticle;
|
SerializedProperty _spTrailParticle;
|
||||||
|
SerializedProperty _spScale;
|
||||||
|
SerializedProperty _spIgnoreParent;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -94,6 +94,11 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool isRoot
|
||||||
|
{
|
||||||
|
get { return !_parent; }
|
||||||
|
}
|
||||||
|
|
||||||
public override Material GetModifiedMaterial (Material baseMaterial)
|
public override Material GetModifiedMaterial (Material baseMaterial)
|
||||||
{
|
{
|
||||||
return base.GetModifiedMaterial (_renderer ? _renderer.sharedMaterial : baseMaterial);
|
return base.GetModifiedMaterial (_renderer ? _renderer.sharedMaterial : baseMaterial);
|
||||||
|
|
Loading…
Reference in New Issue