Merge branch 'development' of https://github.com/Unity-UI-Extensions/com.unity.uiextensions into feature/V2.3.0
commit
968fdab8cc
|
@ -43,6 +43,22 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ParticleSystem.Particle[] Particles
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (particles == null)
|
||||||
|
{
|
||||||
|
#if UNITY_5_5_OR_NEWER
|
||||||
|
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
||||||
|
#else
|
||||||
|
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return particles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected bool Initialize()
|
protected bool Initialize()
|
||||||
{
|
{
|
||||||
// initialize members
|
// initialize members
|
||||||
|
@ -66,8 +82,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
mainModule.maxParticles = 14000;
|
mainModule.maxParticles = 14000;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (pSystem.maxParticles > 14000)
|
if (pSystem.maxParticles > 14000)
|
||||||
pSystem.maxParticles = 14000;
|
{
|
||||||
|
pSystem.maxParticles = 14000;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
pRenderer = pSystem.GetComponent<ParticleSystemRenderer>();
|
||||||
|
@ -95,18 +113,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
mainModule.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
#else
|
#else
|
||||||
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
pSystem.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
particles = null;
|
|
||||||
}
|
}
|
||||||
#if UNITY_5_5_OR_NEWER
|
|
||||||
if (particles == null)
|
|
||||||
particles = new ParticleSystem.Particle[pSystem.main.maxParticles];
|
|
||||||
#else
|
|
||||||
if (particles == null)
|
|
||||||
particles = new ParticleSystem.Particle[pSystem.maxParticles];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
imageUV = new Vector4(0, 0, 1, 1);
|
imageUV = new Vector4(0, 0, 1, 1);
|
||||||
|
|
||||||
|
@ -127,7 +136,9 @@ namespace UnityEngine.UI.Extensions
|
||||||
{
|
{
|
||||||
base.Awake();
|
base.Awake();
|
||||||
if (!Initialize())
|
if (!Initialize())
|
||||||
|
{
|
||||||
enabled = false;
|
enabled = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,17 +171,17 @@ namespace UnityEngine.UI.Extensions
|
||||||
Vector2 corner1 = Vector2.zero;
|
Vector2 corner1 = Vector2.zero;
|
||||||
Vector2 corner2 = Vector2.zero;
|
Vector2 corner2 = Vector2.zero;
|
||||||
// iterate through current particles
|
// iterate through current particles
|
||||||
int count = pSystem.GetParticles(particles);
|
int count = pSystem.GetParticles(Particles);
|
||||||
|
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
ParticleSystem.Particle particle = particles[i];
|
ParticleSystem.Particle particle = Particles[i];
|
||||||
|
|
||||||
// get particle properties
|
// get particle properties
|
||||||
#if UNITY_5_5_OR_NEWER
|
#if UNITY_5_5_OR_NEWER
|
||||||
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector2 position = (mainModule.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||||
#else
|
#else
|
||||||
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
Vector2 position = (pSystem.simulationSpace == ParticleSystemSimulationSpace.Local ? particle.position : _transform.InverseTransformPoint(particle.position));
|
||||||
#endif
|
#endif
|
||||||
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
float rotation = -particle.rotation * Mathf.Deg2Rad;
|
||||||
float rotation90 = rotation + Mathf.PI / 2;
|
float rotation90 = rotation + Mathf.PI / 2;
|
||||||
|
@ -182,8 +193,8 @@ namespace UnityEngine.UI.Extensions
|
||||||
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
if (mainModule.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
#else
|
#else
|
||||||
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
if (pSystem.scalingMode == ParticleSystemScalingMode.Shape)
|
||||||
position /= canvas.scaleFactor;
|
position /= canvas.scaleFactor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// apply texture sheet animation
|
// apply texture sheet animation
|
||||||
|
@ -378,8 +389,7 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (material == currentMaterial)
|
if (material == currentMaterial) { return; }
|
||||||
return;
|
|
||||||
pSystem = null;
|
pSystem = null;
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
@ -408,4 +418,4 @@ namespace UnityEngine.UI.Extensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -29,5 +29,27 @@ namespace UnityEngine.UI.Extensions
|
||||||
!gameObject.hideFlags.HasFlag(HideFlags.HideInHierarchy);
|
!gameObject.hideFlags.HasFlag(HideFlags.HideInHierarchy);
|
||||||
// I don't care about GameObjects *inside* prefabs, just the overall prefab.
|
// I don't care about GameObjects *inside* prefabs, just the overall prefab.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generic clamp method to limt a value between a range of values
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"><see cref="IComparable"/> data type</typeparam>
|
||||||
|
/// <param name="value">Value to clamp</param>
|
||||||
|
/// <param name="min">Minimum value</param>
|
||||||
|
/// <param name="max">Maximum value</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T Clamp<T>(this T value, T min, T max) where T : IComparable<T>
|
||||||
|
{
|
||||||
|
if (value.CompareTo(min) < 0)
|
||||||
|
{
|
||||||
|
value = min;
|
||||||
|
}
|
||||||
|
if (value.CompareTo(max) > 0)
|
||||||
|
{
|
||||||
|
value = max;
|
||||||
|
}
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,10 @@ namespace UnityEngine.UI.Extensions
|
||||||
parentCanvas = rt.GetComponentInParent<Canvas>();
|
parentCanvas = rt.GetComponentInParent<Canvas>();
|
||||||
if (parentCanvas == null)
|
if (parentCanvas == null)
|
||||||
{
|
{
|
||||||
|
if (parent.parent == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
parent = parent.parent.GetComponent<RectTransform>();
|
parent = parent.parent.GetComponent<RectTransform>();
|
||||||
SearchIndex++;
|
SearchIndex++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,11 @@ namespace UnityEngine.UI.Extensions
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
canvas = GetComponentInParent<RectTransform>().GetParentCanvas().GetComponent<RectTransform>();
|
var canvasParent = GetComponentInParent<RectTransform>().GetParentCanvas();
|
||||||
|
if (canvasParent != null)
|
||||||
|
{
|
||||||
|
canvas = canvasParent.GetComponent<RectTransform>();
|
||||||
|
}
|
||||||
rt = GetComponent<RectTransform>();
|
rt = GetComponent<RectTransform>();
|
||||||
lr = GetComponent<UILineRenderer>();
|
lr = GetComponent<UILineRenderer>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue