close #10; Add a scale property independent of transform
parent
b6f23013f8
commit
61212545c7
|
@ -58,6 +58,11 @@ namespace Coffee.UIExtensions
|
||||||
EditorGUILayout.PropertyField(_spTrailParticle);
|
EditorGUILayout.PropertyField(_spTrailParticle);
|
||||||
EditorGUI.EndDisabledGroup();
|
EditorGUI.EndDisabledGroup();
|
||||||
|
|
||||||
|
if ((target as UIParticle).GetComponentsInParent<UIParticle> (false).Length == 1)
|
||||||
|
{
|
||||||
|
EditorGUILayout.PropertyField (serializedObject.FindProperty ("m_Scale"));
|
||||||
|
}
|
||||||
|
|
||||||
serializedObject.ApplyModifiedProperties();
|
serializedObject.ApplyModifiedProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace Coffee.UIExtensions
|
||||||
[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.")]
|
||||||
|
[SerializeField] float m_Scale = 1;
|
||||||
|
|
||||||
|
|
||||||
//################################
|
//################################
|
||||||
|
@ -66,6 +68,11 @@ namespace Coffee.UIExtensions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Particle effect scale.
|
||||||
|
/// </summary>
|
||||||
|
public float scale { get { return _parent ? _parent.scale : m_Scale; } set { m_Scale = value; } }
|
||||||
|
|
||||||
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);
|
||||||
|
@ -82,6 +89,11 @@ namespace Coffee.UIExtensions
|
||||||
base.OnEnable();
|
base.OnEnable();
|
||||||
|
|
||||||
Canvas.willRenderCanvases += UpdateMesh;
|
Canvas.willRenderCanvases += UpdateMesh;
|
||||||
|
|
||||||
|
foreach(var c in Resources.FindObjectsOfTypeAll<Camera>())
|
||||||
|
{
|
||||||
|
Debug.LogFormat ("{0}, {1}, {2}, {3}, {4}",c,c.orthographic,c.orthographicSize,c.transform.localScale,c.transform.position);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisable()
|
protected override void OnDisable()
|
||||||
|
@ -102,6 +114,7 @@ namespace Coffee.UIExtensions
|
||||||
//################################
|
//################################
|
||||||
Mesh _mesh;
|
Mesh _mesh;
|
||||||
ParticleSystemRenderer _renderer;
|
ParticleSystemRenderer _renderer;
|
||||||
|
Matrix4x4 scaleaMatrix = default(Matrix4x4);
|
||||||
|
|
||||||
void UpdateMesh()
|
void UpdateMesh()
|
||||||
{
|
{
|
||||||
|
@ -121,19 +134,21 @@ namespace Coffee.UIExtensions
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
Profiler.BeginSample("Make Matrix");
|
Profiler.BeginSample("Make Matrix");
|
||||||
var cam = canvas.worldCamera ?? Camera.main;
|
var s = scale;
|
||||||
bool useTransform = false;
|
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 =
|
||||||
Matrix4x4.Rotate(m_ParticleSystem.transform.rotation).inverse
|
scaleaMatrix
|
||||||
* Matrix4x4.Scale(m_ParticleSystem.transform.lossyScale).inverse;
|
* Matrix4x4.Rotate(m_ParticleSystem.transform.rotation).inverse
|
||||||
useTransform = true;
|
* Matrix4x4.Scale(m_ParticleSystem.transform.lossyScale).inverse;
|
||||||
break;
|
break;
|
||||||
case ParticleSystemSimulationSpace.World:
|
case ParticleSystemSimulationSpace.World:
|
||||||
matrix = m_ParticleSystem.transform.worldToLocalMatrix;
|
matrix =
|
||||||
|
scaleaMatrix
|
||||||
|
* m_ParticleSystem.transform.worldToLocalMatrix;
|
||||||
break;
|
break;
|
||||||
case ParticleSystemSimulationSpace.Custom:
|
case ParticleSystemSimulationSpace.Custom:
|
||||||
break;
|
break;
|
||||||
|
@ -146,11 +161,11 @@ namespace Coffee.UIExtensions
|
||||||
Profiler.BeginSample("Bake Mesh");
|
Profiler.BeginSample("Bake Mesh");
|
||||||
if (m_IsTrail)
|
if (m_IsTrail)
|
||||||
{
|
{
|
||||||
_renderer.BakeTrailsMesh(_mesh, cam, useTransform);
|
_renderer.BakeTrailsMesh(_mesh, cam, m_UseTransform);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_renderer.BakeMesh(_mesh, cam, useTransform);
|
_renderer.BakeMesh(_mesh, cam, m_UseTransform);
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue