private void DrawSprite() { var matBlock = new MaterialPropertyBlock(); matBlock.SetTexture(_shaderPropertyTexture, _sprite.texture); matBlock.SetColor(_shaderPropertyColor, Color.white); matBlock.SetVector(_shaderPropertyUv, SpriteRenderingSystem.GetUv(_sprite)); Graphics.DrawMesh(_mesh, GetMatrix(), _mat, 0, null, 0, matBlock, ShadowCastingMode.On); }
private void DrawWithCamera(Camera cam) { if (!cam) { return; } if (_animation == null || _sprite == null) { return; } if (_mesh == null) { _mesh = ProceduralMeshUtility.GenerateQuad(new Vector2(20.48f, 10.24f), new Vector2(0.5f, 0)); } if (_sprite != null) { DrawSprite(); return; } if (!_drawTimer.IsActive) { _frame++; if (_frame >= _animation.Frames.Length) { _frame = 0; } _drawTimer.StartNewTime(_animation.FrameTime * _animation.GetFrame(_frame).Length); } var sprite = _animation.GetSprite(_frame); var matBlock = new MaterialPropertyBlock(); matBlock.SetTexture(_shaderPropertyTexture, sprite.texture); matBlock.SetTexture(_shaderPropertyNormal, _animation.NormalMap); matBlock.SetFloat(_shaderPropertyEmissivePower, _animation.EmissiveMap != null ? 1 : 0); if (_animation.EmissiveMap != null) { matBlock.SetTexture(_shaderPropertyEmissive, _animation.EmissiveMap); } matBlock.SetColor(_shaderPropertyColor, Color.white); matBlock.SetVector(_shaderPropertyUv, SpriteRenderingSystem.GetUv(sprite)); Graphics.DrawMesh(_mesh, GetMatrix(), _mat, 0, null, 0, matBlock, ShadowCastingMode.On); }