close #5; Supports sprites

pull/33/head
mob-sakai 2018-07-13 12:56:50 +09:00
parent 2a298eea7d
commit 8055bb84f1
1 changed files with 28 additions and 3 deletions

View File

@ -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();
}
}