From 8055bb84f1939e0501a85a1a00fb5fce0cf646ef Mon Sep 17 00:00:00 2001 From: mob-sakai Date: Fri, 13 Jul 2018 12:56:50 +0900 Subject: [PATCH] close #5; Supports sprites --- .../UIExtensions/UIParticle/UIParticle.cs | 31 +++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Assets/Coffee/UIExtensions/UIParticle/UIParticle.cs b/Assets/Coffee/UIExtensions/UIParticle/UIParticle.cs index dc2fa72..33b7d0c 100644 --- a/Assets/Coffee/UIExtensions/UIParticle/UIParticle.cs +++ b/Assets/Coffee/UIExtensions/UIParticle/UIParticle.cs @@ -37,8 +37,32 @@ namespace Coffee.UIExtensions { get { - var mat = _renderer ? _renderer.sharedMaterial : defaultGraphicMaterial; - return mat && mat.HasProperty(s_IdMainTex) ? mat.mainTexture : s_WhiteTexture; ; + Texture tex = null; + if (!m_IsTrail) + { + Profiler.BeginSample("Check TextureSheetAnimation module"); + var textureSheet = m_ParticleSystem.textureSheetAnimation; + if (textureSheet.enabled && textureSheet.mode == ParticleSystemAnimationMode.Sprites && 0 < textureSheet.spriteCount) + { + tex = textureSheet.GetSprite(0).texture; + } + Profiler.EndSample(); + } + if (!tex && _renderer) + { + Profiler.BeginSample("Check material"); + var mat = m_IsTrail + ? _renderer.trailMaterial + : Application.isPlaying + ? _renderer.material + : _renderer.sharedMaterial; + if (mat && mat.HasProperty(s_IdMainTex)) + { + tex = mat.mainTexture; + } + Profiler.EndSample(); + } + return tex ?? s_WhiteTexture; } } @@ -143,8 +167,9 @@ namespace Coffee.UIExtensions // Set mesh to CanvasRenderer. - Profiler.BeginSample("Set mesh to CanvasRenderer"); + Profiler.BeginSample("Set mesh and texture to CanvasRenderer"); canvasRenderer.SetMesh(_mesh); + canvasRenderer.SetTexture(mainTexture); Profiler.EndSample(); } }