Add try-catch
parent
1f85fc6d98
commit
b6f23013f8
115
UIParticle.cs
115
UIParticle.cs
|
@ -105,72 +105,79 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
void UpdateMesh()
|
void UpdateMesh()
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("CheckTrail");
|
try
|
||||||
CheckTrail();
|
|
||||||
Profiler.EndSample();
|
|
||||||
|
|
||||||
if (m_ParticleSystem)
|
|
||||||
{
|
{
|
||||||
Profiler.BeginSample("Disable ParticleSystemRenderer");
|
Profiler.BeginSample("CheckTrail");
|
||||||
if (Application.isPlaying)
|
CheckTrail();
|
||||||
{
|
|
||||||
_renderer.enabled = false;
|
|
||||||
}
|
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
Profiler.BeginSample("Make Matrix");
|
if (m_ParticleSystem)
|
||||||
var cam = canvas.worldCamera ?? Camera.main;
|
|
||||||
bool useTransform = false;
|
|
||||||
Matrix4x4 matrix = default(Matrix4x4);
|
|
||||||
switch (m_ParticleSystem.main.simulationSpace)
|
|
||||||
{
|
{
|
||||||
case ParticleSystemSimulationSpace.Local:
|
Profiler.BeginSample("Disable ParticleSystemRenderer");
|
||||||
matrix =
|
if (Application.isPlaying)
|
||||||
Matrix4x4.Rotate(m_ParticleSystem.transform.rotation).inverse
|
|
||||||
* Matrix4x4.Scale(m_ParticleSystem.transform.lossyScale).inverse;
|
|
||||||
useTransform = true;
|
|
||||||
break;
|
|
||||||
case ParticleSystemSimulationSpace.World:
|
|
||||||
matrix = m_ParticleSystem.transform.worldToLocalMatrix;
|
|
||||||
break;
|
|
||||||
case ParticleSystemSimulationSpace.Custom:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Profiler.EndSample();
|
|
||||||
|
|
||||||
_mesh.Clear();
|
|
||||||
if (0 < m_ParticleSystem.particleCount)
|
|
||||||
{
|
|
||||||
Profiler.BeginSample("Bake Mesh");
|
|
||||||
if (m_IsTrail)
|
|
||||||
{
|
{
|
||||||
_renderer.BakeTrailsMesh(_mesh, cam, useTransform);
|
_renderer.enabled = false;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_renderer.BakeMesh(_mesh, cam, useTransform);
|
|
||||||
}
|
}
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
|
|
||||||
// Apply matrix.
|
Profiler.BeginSample("Make Matrix");
|
||||||
Profiler.BeginSample("Apply matrix to position");
|
var cam = canvas.worldCamera ?? Camera.main;
|
||||||
_mesh.GetVertices(s_Vertices);
|
bool useTransform = false;
|
||||||
var count = s_Vertices.Count;
|
Matrix4x4 matrix = default(Matrix4x4);
|
||||||
for (int i = 0; i < count; i++)
|
switch (m_ParticleSystem.main.simulationSpace)
|
||||||
{
|
{
|
||||||
s_Vertices[i] = matrix.MultiplyPoint3x4(s_Vertices[i]);
|
case ParticleSystemSimulationSpace.Local:
|
||||||
|
matrix =
|
||||||
|
Matrix4x4.Rotate(m_ParticleSystem.transform.rotation).inverse
|
||||||
|
* Matrix4x4.Scale(m_ParticleSystem.transform.lossyScale).inverse;
|
||||||
|
useTransform = true;
|
||||||
|
break;
|
||||||
|
case ParticleSystemSimulationSpace.World:
|
||||||
|
matrix = m_ParticleSystem.transform.worldToLocalMatrix;
|
||||||
|
break;
|
||||||
|
case ParticleSystemSimulationSpace.Custom:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
_mesh.SetVertices(s_Vertices);
|
Profiler.EndSample();
|
||||||
s_Vertices.Clear();
|
|
||||||
|
_mesh.Clear();
|
||||||
|
if (0 < m_ParticleSystem.particleCount)
|
||||||
|
{
|
||||||
|
Profiler.BeginSample("Bake Mesh");
|
||||||
|
if (m_IsTrail)
|
||||||
|
{
|
||||||
|
_renderer.BakeTrailsMesh(_mesh, cam, useTransform);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_renderer.BakeMesh(_mesh, cam, useTransform);
|
||||||
|
}
|
||||||
|
Profiler.EndSample();
|
||||||
|
|
||||||
|
// Apply matrix.
|
||||||
|
Profiler.BeginSample("Apply matrix to position");
|
||||||
|
_mesh.GetVertices(s_Vertices);
|
||||||
|
var count = s_Vertices.Count;
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
s_Vertices[i] = matrix.MultiplyPoint3x4(s_Vertices[i]);
|
||||||
|
}
|
||||||
|
_mesh.SetVertices(s_Vertices);
|
||||||
|
s_Vertices.Clear();
|
||||||
|
Profiler.EndSample();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set mesh to CanvasRenderer.
|
||||||
|
Profiler.BeginSample("Set mesh and texture to CanvasRenderer");
|
||||||
|
canvasRenderer.SetMesh(_mesh);
|
||||||
|
canvasRenderer.SetTexture(mainTexture);
|
||||||
Profiler.EndSample();
|
Profiler.EndSample();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch(System.Exception e)
|
||||||
// Set mesh to CanvasRenderer.
|
{
|
||||||
Profiler.BeginSample("Set mesh and texture to CanvasRenderer");
|
Debug.LogException(e);
|
||||||
canvasRenderer.SetMesh(_mesh);
|
|
||||||
canvasRenderer.SetTexture(mainTexture);
|
|
||||||
Profiler.EndSample();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue