Refactor
parent
5e6cd8c8f6
commit
279a470202
|
@ -4,15 +4,15 @@ using UnityEngine;
|
||||||
|
|
||||||
namespace Coffee.UIExtensions
|
namespace Coffee.UIExtensions
|
||||||
{
|
{
|
||||||
[CustomEditor(typeof(UIParticle))]
|
[CustomEditor (typeof (UIParticle))]
|
||||||
[CanEditMultipleObjects]
|
[CanEditMultipleObjects]
|
||||||
public class UIParticleEditor : GraphicEditor
|
public class UIParticleEditor : GraphicEditor
|
||||||
{
|
{
|
||||||
//################################
|
//################################
|
||||||
// Constant or Static Members.
|
// Constant or Static Members.
|
||||||
//################################
|
//################################
|
||||||
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");
|
||||||
|
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
|
@ -21,42 +21,42 @@ namespace Coffee.UIExtensions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is called when the object becomes enabled and active.
|
/// This function is called when the object becomes enabled and active.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void OnEnable()
|
protected override void OnEnable ()
|
||||||
{
|
{
|
||||||
base.OnEnable();
|
base.OnEnable ();
|
||||||
_spParticleSystem = serializedObject.FindProperty("m_ParticleSystem");
|
_spParticleSystem = serializedObject.FindProperty ("m_ParticleSystem");
|
||||||
_spTrailParticle = serializedObject.FindProperty("m_TrailParticle");
|
_spTrailParticle = serializedObject.FindProperty ("m_TrailParticle");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Implement this function to make a custom inspector.
|
/// Implement this function to make a custom inspector.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void OnInspectorGUI()
|
public override void OnInspectorGUI ()
|
||||||
{
|
{
|
||||||
serializedObject.Update();
|
serializedObject.Update ();
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(_spParticleSystem);
|
EditorGUILayout.PropertyField (_spParticleSystem);
|
||||||
EditorGUI.indentLevel++;
|
EditorGUI.indentLevel++;
|
||||||
var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;
|
var ps = _spParticleSystem.objectReferenceValue as ParticleSystem;
|
||||||
if (ps)
|
if (ps)
|
||||||
{
|
{
|
||||||
var pr = ps.GetComponent<ParticleSystemRenderer>();
|
var pr = ps.GetComponent<ParticleSystemRenderer> ();
|
||||||
var sp = new SerializedObject(pr).FindProperty("m_Materials");
|
var sp = new SerializedObject (pr).FindProperty ("m_Materials");
|
||||||
|
|
||||||
EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(0), contentParticleMaterial);
|
EditorGUILayout.PropertyField (sp.GetArrayElementAtIndex (0), contentParticleMaterial);
|
||||||
EditorGUILayout.PropertyField(sp.GetArrayElementAtIndex(1), contentTrailMaterial);
|
EditorGUILayout.PropertyField (sp.GetArrayElementAtIndex (1), contentTrailMaterial);
|
||||||
sp.serializedObject.ApplyModifiedProperties();
|
sp.serializedObject.ApplyModifiedProperties ();
|
||||||
|
|
||||||
if(!Application.isPlaying && pr.enabled)
|
if (!Application.isPlaying && pr.enabled)
|
||||||
{
|
{
|
||||||
EditorGUILayout.HelpBox("ParticleSystemRenderer will be disable on playing.", MessageType.Info);
|
EditorGUILayout.HelpBox ("ParticleSystemRenderer will be disable on playing.", MessageType.Info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EditorGUI.indentLevel--;
|
EditorGUI.indentLevel--;
|
||||||
|
|
||||||
EditorGUI.BeginDisabledGroup(true);
|
EditorGUI.BeginDisabledGroup (true);
|
||||||
EditorGUILayout.PropertyField(_spTrailParticle);
|
EditorGUILayout.PropertyField (_spTrailParticle);
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup ();
|
||||||
|
|
||||||
if ((target as UIParticle).GetComponentsInParent<UIParticle> (false).Length == 1)
|
if ((target as UIParticle).GetComponentsInParent<UIParticle> (false).Length == 1)
|
||||||
{
|
{
|
||||||
|
@ -64,7 +64,7 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
EditorGUILayout.PropertyField (serializedObject.FindProperty ("m_IgnoreParent"));
|
EditorGUILayout.PropertyField (serializedObject.FindProperty ("m_IgnoreParent"));
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties ();
|
||||||
}
|
}
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
|
|
|
@ -16,23 +16,23 @@ namespace Coffee.UIExtensions
|
||||||
//################################
|
//################################
|
||||||
// Constant or Readonly Static Members.
|
// Constant or Readonly Static Members.
|
||||||
//################################
|
//################################
|
||||||
static readonly int s_IdMainTex = Shader.PropertyToID("_MainTex");
|
static readonly int s_IdMainTex = Shader.PropertyToID ("_MainTex");
|
||||||
static readonly List<Vector3> s_Vertices = new List<Vector3>();
|
static readonly List<Vector3> s_Vertices = new List<Vector3> ();
|
||||||
static readonly List<UIParticle> s_TempRelatables = new List<UIParticle>();
|
static readonly List<UIParticle> s_TempRelatables = new List<UIParticle> ();
|
||||||
static readonly List<UIParticle> s_ActiveSoftMasks = new List<UIParticle>();
|
static readonly List<UIParticle> s_ActiveSoftMasks = new List<UIParticle> ();
|
||||||
|
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
// Serialize Members.
|
// Serialize Members.
|
||||||
//################################
|
//################################
|
||||||
[Tooltip("The ParticleSystem rendered by CanvasRenderer")]
|
[Tooltip ("The ParticleSystem rendered by CanvasRenderer")]
|
||||||
[SerializeField] ParticleSystem m_ParticleSystem;
|
[SerializeField] ParticleSystem m_ParticleSystem;
|
||||||
[Tooltip("The UIParticle to render trail effect")]
|
[Tooltip ("The UIParticle to render trail effect")]
|
||||||
[SerializeField] UIParticle m_TrailParticle;
|
[SerializeField] UIParticle m_TrailParticle;
|
||||||
[HideInInspector] [SerializeField] bool m_IsTrail = false;
|
[HideInInspector] [SerializeField] bool m_IsTrail = false;
|
||||||
[Tooltip("Particle effect scale")]
|
[Tooltip ("Particle effect scale")]
|
||||||
[SerializeField] float m_Scale = 1;
|
[SerializeField] float m_Scale = 1;
|
||||||
[Tooltip("Ignore parent scale")]
|
[Tooltip ("Ignore parent scale")]
|
||||||
[SerializeField] bool m_IgnoreParent = false;
|
[SerializeField] bool m_IgnoreParent = false;
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,27 +46,27 @@ namespace Coffee.UIExtensions
|
||||||
Texture tex = null;
|
Texture tex = null;
|
||||||
if (!m_IsTrail)
|
if (!m_IsTrail)
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("Check TextureSheetAnimation module");
|
Profiler.BeginSample ("Check TextureSheetAnimation module");
|
||||||
var textureSheet = m_ParticleSystem.textureSheetAnimation;
|
var textureSheet = m_ParticleSystem.textureSheetAnimation;
|
||||||
if (textureSheet.enabled && textureSheet.mode == ParticleSystemAnimationMode.Sprites && 0 < textureSheet.spriteCount)
|
if (textureSheet.enabled && textureSheet.mode == ParticleSystemAnimationMode.Sprites && 0 < textureSheet.spriteCount)
|
||||||
{
|
{
|
||||||
tex = textureSheet.GetSprite(0).texture;
|
tex = textureSheet.GetSprite (0).texture;
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
}
|
}
|
||||||
if (!tex && _renderer)
|
if (!tex && _renderer)
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("Check material");
|
Profiler.BeginSample ("Check material");
|
||||||
var mat = m_IsTrail
|
var mat = m_IsTrail
|
||||||
? _renderer.trailMaterial
|
? _renderer.trailMaterial
|
||||||
: Application.isPlaying
|
: Application.isPlaying
|
||||||
? _renderer.material
|
? _renderer.material
|
||||||
: _renderer.sharedMaterial;
|
: _renderer.sharedMaterial;
|
||||||
if (mat && mat.HasProperty(s_IdMainTex))
|
if (mat && mat.HasProperty (s_IdMainTex))
|
||||||
{
|
{
|
||||||
tex = mat.mainTexture;
|
tex = mat.mainTexture;
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
}
|
}
|
||||||
return tex ?? s_WhiteTexture;
|
return tex ?? s_WhiteTexture;
|
||||||
}
|
}
|
||||||
|
@ -86,95 +86,95 @@ namespace Coffee.UIExtensions
|
||||||
get { return m_IgnoreParent; }
|
get { return m_IgnoreParent; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if(m_IgnoreParent != value)
|
if (m_IgnoreParent != value)
|
||||||
{
|
{
|
||||||
m_IgnoreParent = value;
|
m_IgnoreParent = value;
|
||||||
OnTransformParentChanged();
|
OnTransformParentChanged ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnEnable()
|
protected override void OnEnable ()
|
||||||
{
|
{
|
||||||
// Register.
|
// Register.
|
||||||
if(s_ActiveSoftMasks.Count == 0)
|
if (s_ActiveSoftMasks.Count == 0)
|
||||||
{
|
{
|
||||||
Canvas.willRenderCanvases += UpdateMeshes;
|
Canvas.willRenderCanvases += UpdateMeshes;
|
||||||
}
|
}
|
||||||
s_ActiveSoftMasks.Add(this);
|
s_ActiveSoftMasks.Add (this);
|
||||||
|
|
||||||
// Reset the parent-child relation.
|
// Reset the parent-child relation.
|
||||||
GetComponentsInChildren<UIParticle>(false, s_TempRelatables);
|
GetComponentsInChildren<UIParticle> (false, s_TempRelatables);
|
||||||
for(int i = s_TempRelatables.Count - 1; 0 <= i; i--)
|
for (int i = s_TempRelatables.Count - 1; 0 <= i; i--)
|
||||||
{
|
{
|
||||||
s_TempRelatables [i].OnTransformParentChanged();
|
s_TempRelatables [i].OnTransformParentChanged ();
|
||||||
}
|
}
|
||||||
s_TempRelatables.Clear();
|
s_TempRelatables.Clear ();
|
||||||
|
|
||||||
m_ParticleSystem = m_ParticleSystem ? m_ParticleSystem : GetComponent<ParticleSystem>();
|
m_ParticleSystem = m_ParticleSystem ? m_ParticleSystem : GetComponent<ParticleSystem> ();
|
||||||
_renderer = m_ParticleSystem ? m_ParticleSystem.GetComponent<ParticleSystemRenderer>() : null;
|
_renderer = m_ParticleSystem ? m_ParticleSystem.GetComponent<ParticleSystemRenderer> () : null;
|
||||||
|
|
||||||
// Create objects.
|
// Create objects.
|
||||||
_mesh = new Mesh();
|
_mesh = new Mesh ();
|
||||||
_mesh.MarkDynamic();
|
_mesh.MarkDynamic ();
|
||||||
CheckTrail();
|
CheckTrail ();
|
||||||
|
|
||||||
base.OnEnable();
|
base.OnEnable ();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisable()
|
protected override void OnDisable ()
|
||||||
{
|
{
|
||||||
// Unregister.
|
// Unregister.
|
||||||
s_ActiveSoftMasks.Remove(this);
|
s_ActiveSoftMasks.Remove (this);
|
||||||
if(s_ActiveSoftMasks.Count == 0)
|
if (s_ActiveSoftMasks.Count == 0)
|
||||||
{
|
{
|
||||||
Canvas.willRenderCanvases -= UpdateMeshes;
|
Canvas.willRenderCanvases -= UpdateMeshes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the parent-child relation.
|
// Reset the parent-child relation.
|
||||||
for(int i = _children.Count - 1; 0 <= i; i--)
|
for (int i = _children.Count - 1; 0 <= i; i--)
|
||||||
{
|
{
|
||||||
_children [i].SetParent(_parent);
|
_children [i].SetParent (_parent);
|
||||||
}
|
}
|
||||||
_children.Clear();
|
_children.Clear ();
|
||||||
SetParent(null);
|
SetParent (null);
|
||||||
|
|
||||||
// Destroy objects.
|
// Destroy objects.
|
||||||
DestroyImmediate(_mesh);
|
DestroyImmediate (_mesh);
|
||||||
_mesh = null;
|
_mesh = null;
|
||||||
CheckTrail();
|
CheckTrail ();
|
||||||
|
|
||||||
base.OnDisable();
|
base.OnDisable ();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void UpdateGeometry()
|
protected override void UpdateGeometry ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is called when the parent property of the transform of the GameObject has changed.
|
/// This function is called when the parent property of the transform of the GameObject has changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void OnTransformParentChanged()
|
protected override void OnTransformParentChanged ()
|
||||||
{
|
{
|
||||||
UIParticle newParent = null;
|
UIParticle newParent = null;
|
||||||
if(isActiveAndEnabled && !m_IgnoreParent)
|
if (isActiveAndEnabled && !m_IgnoreParent)
|
||||||
{
|
{
|
||||||
var parentTransform = transform.parent;
|
var parentTransform = transform.parent;
|
||||||
while(parentTransform &&(!newParent || !newParent.enabled))
|
while (parentTransform && (!newParent || !newParent.enabled))
|
||||||
{
|
{
|
||||||
newParent = parentTransform.GetComponent<UIParticle>();
|
newParent = parentTransform.GetComponent<UIParticle> ();
|
||||||
parentTransform = parentTransform.parent;
|
parentTransform = parentTransform.parent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetParent(newParent);
|
SetParent (newParent);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDidApplyAnimationProperties()
|
protected override void OnDidApplyAnimationProperties ()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,10 +182,10 @@ namespace Coffee.UIExtensions
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is called when the script is loaded or a value is changed in the inspector(Called in the editor only).
|
/// This function is called when the script is loaded or a value is changed in the inspector(Called in the editor only).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void OnValidate()
|
protected override void OnValidate ()
|
||||||
{
|
{
|
||||||
OnTransformParentChanged();
|
OnTransformParentChanged ();
|
||||||
base.OnValidate();
|
base.OnValidate ();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -196,45 +196,45 @@ namespace Coffee.UIExtensions
|
||||||
Mesh _mesh;
|
Mesh _mesh;
|
||||||
ParticleSystemRenderer _renderer;
|
ParticleSystemRenderer _renderer;
|
||||||
UIParticle _parent;
|
UIParticle _parent;
|
||||||
List<UIParticle> _children = new List<UIParticle>();
|
List<UIParticle> _children = new List<UIParticle> ();
|
||||||
Matrix4x4 scaleaMatrix = default(Matrix4x4);
|
Matrix4x4 scaleaMatrix = default (Matrix4x4);
|
||||||
|
|
||||||
static void UpdateMeshes()
|
static void UpdateMeshes ()
|
||||||
{
|
{
|
||||||
foreach(var uip in s_ActiveSoftMasks)
|
foreach (var uip in s_ActiveSoftMasks)
|
||||||
{
|
{
|
||||||
uip.UpdateMesh();
|
uip.UpdateMesh ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateMesh()
|
void UpdateMesh ()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("CheckTrail");
|
Profiler.BeginSample ("CheckTrail");
|
||||||
CheckTrail();
|
CheckTrail ();
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
|
|
||||||
if (m_ParticleSystem)
|
if (m_ParticleSystem)
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("Disable ParticleSystemRenderer");
|
Profiler.BeginSample ("Disable ParticleSystemRenderer");
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
{
|
{
|
||||||
_renderer.enabled = false;
|
_renderer.enabled = false;
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
|
|
||||||
Profiler.BeginSample("Make Matrix");
|
Profiler.BeginSample ("Make Matrix");
|
||||||
var s = scale;
|
var s = scale;
|
||||||
scaleaMatrix = Matrix4x4.Scale(new Vector3(s, s, s));
|
scaleaMatrix = Matrix4x4.Scale (new Vector3 (s, s, s));
|
||||||
Matrix4x4 matrix = default(Matrix4x4);
|
Matrix4x4 matrix = default (Matrix4x4);
|
||||||
switch (m_ParticleSystem.main.simulationSpace)
|
switch (m_ParticleSystem.main.simulationSpace)
|
||||||
{
|
{
|
||||||
case ParticleSystemSimulationSpace.Local:
|
case ParticleSystemSimulationSpace.Local:
|
||||||
matrix =
|
matrix =
|
||||||
scaleaMatrix
|
scaleaMatrix
|
||||||
* Matrix4x4.Rotate(m_ParticleSystem.transform.rotation).inverse
|
* Matrix4x4.Rotate (m_ParticleSystem.transform.rotation).inverse
|
||||||
* Matrix4x4.Scale(m_ParticleSystem.transform.lossyScale).inverse;
|
* Matrix4x4.Scale (m_ParticleSystem.transform.lossyScale).inverse;
|
||||||
break;
|
break;
|
||||||
case ParticleSystemSimulationSpace.World:
|
case ParticleSystemSimulationSpace.World:
|
||||||
matrix =
|
matrix =
|
||||||
|
@ -244,64 +244,64 @@ namespace Coffee.UIExtensions
|
||||||
case ParticleSystemSimulationSpace.Custom:
|
case ParticleSystemSimulationSpace.Custom:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
|
|
||||||
_mesh.Clear();
|
_mesh.Clear ();
|
||||||
if (0 < m_ParticleSystem.particleCount)
|
if (0 < m_ParticleSystem.particleCount)
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("Bake Mesh");
|
Profiler.BeginSample ("Bake Mesh");
|
||||||
if (m_IsTrail)
|
if (m_IsTrail)
|
||||||
{
|
{
|
||||||
_renderer.BakeTrailsMesh(_mesh, true);
|
_renderer.BakeTrailsMesh (_mesh, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_renderer.BakeMesh(_mesh, true);
|
_renderer.BakeMesh (_mesh, true);
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
|
|
||||||
// Apply matrix.
|
// Apply matrix.
|
||||||
Profiler.BeginSample("Apply matrix to position");
|
Profiler.BeginSample ("Apply matrix to position");
|
||||||
_mesh.GetVertices(s_Vertices);
|
_mesh.GetVertices (s_Vertices);
|
||||||
var count = s_Vertices.Count;
|
var count = s_Vertices.Count;
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
s_Vertices[i] = matrix.MultiplyPoint3x4(s_Vertices[i]);
|
s_Vertices [i] = matrix.MultiplyPoint3x4 (s_Vertices [i]);
|
||||||
}
|
}
|
||||||
_mesh.SetVertices(s_Vertices);
|
_mesh.SetVertices (s_Vertices);
|
||||||
s_Vertices.Clear();
|
s_Vertices.Clear ();
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set mesh to CanvasRenderer.
|
// Set mesh to CanvasRenderer.
|
||||||
Profiler.BeginSample("Set mesh and texture to CanvasRenderer");
|
Profiler.BeginSample ("Set mesh and texture to CanvasRenderer");
|
||||||
canvasRenderer.SetMesh(_mesh);
|
canvasRenderer.SetMesh (_mesh);
|
||||||
canvasRenderer.SetTexture(mainTexture);
|
canvasRenderer.SetTexture (mainTexture);
|
||||||
Profiler.EndSample();
|
Profiler.EndSample ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(System.Exception e)
|
catch (System.Exception e)
|
||||||
{
|
{
|
||||||
Debug.LogException(e);
|
Debug.LogException (e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckTrail()
|
void CheckTrail ()
|
||||||
{
|
{
|
||||||
if (isActiveAndEnabled && !m_IsTrail && m_ParticleSystem && m_ParticleSystem.trails.enabled)
|
if (isActiveAndEnabled && !m_IsTrail && m_ParticleSystem && m_ParticleSystem.trails.enabled)
|
||||||
{
|
{
|
||||||
if (!m_TrailParticle)
|
if (!m_TrailParticle)
|
||||||
{
|
{
|
||||||
m_TrailParticle = new GameObject("[UIParticle] Trail").AddComponent<UIParticle>();
|
m_TrailParticle = new GameObject ("[UIParticle] Trail").AddComponent<UIParticle> ();
|
||||||
var trans = m_TrailParticle.transform;
|
var trans = m_TrailParticle.transform;
|
||||||
trans.SetParent(transform);
|
trans.SetParent (transform);
|
||||||
trans.localPosition = Vector3.zero;
|
trans.localPosition = Vector3.zero;
|
||||||
trans.localRotation = Quaternion.identity;
|
trans.localRotation = Quaternion.identity;
|
||||||
trans.localScale = Vector3.one;
|
trans.localScale = Vector3.one;
|
||||||
|
|
||||||
m_TrailParticle._renderer = GetComponent<ParticleSystemRenderer>();
|
m_TrailParticle._renderer = GetComponent<ParticleSystemRenderer> ();
|
||||||
m_TrailParticle.m_ParticleSystem = GetComponent<ParticleSystem>();
|
m_TrailParticle.m_ParticleSystem = GetComponent<ParticleSystem> ();
|
||||||
m_TrailParticle.m_IsTrail = true;
|
m_TrailParticle.m_IsTrail = true;
|
||||||
}
|
}
|
||||||
m_TrailParticle.enabled = true;
|
m_TrailParticle.enabled = true;
|
||||||
|
@ -316,21 +316,21 @@ namespace Coffee.UIExtensions
|
||||||
/// Set the parent of the soft mask.
|
/// Set the parent of the soft mask.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newParent">The parent soft mask to use.</param>
|
/// <param name="newParent">The parent soft mask to use.</param>
|
||||||
void SetParent(UIParticle newParent)
|
void SetParent (UIParticle newParent)
|
||||||
{
|
{
|
||||||
if(_parent != newParent && this != newParent)
|
if (_parent != newParent && this != newParent)
|
||||||
{
|
{
|
||||||
if(_parent && _parent._children.Contains(this))
|
if (_parent && _parent._children.Contains (this))
|
||||||
{
|
{
|
||||||
_parent._children.Remove(this);
|
_parent._children.Remove (this);
|
||||||
_parent._children.RemoveAll(x => x == null);
|
_parent._children.RemoveAll (x => x == null);
|
||||||
}
|
}
|
||||||
_parent = newParent;
|
_parent = newParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_parent && !_parent._children.Contains(this))
|
if (_parent && !_parent._children.Contains (this))
|
||||||
{
|
{
|
||||||
_parent._children.Add(this);
|
_parent._children.Add (this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue