3.0.0-preview.21
# [3.0.0-preview.21](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.20...v3.0.0-preview.21) (2020-08-28) ### Bug Fixes * if in the mask, rendering material will be destroyed ([0db40cf](pull/120/head0db40cf160
)) * support animatable material property (again) ([cf6ca80](cf6ca80d12
))
parent
ab27f0af6f
commit
46ec957a52
|
@ -1,3 +1,11 @@
|
||||||
|
# [3.0.0-preview.21](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.20...v3.0.0-preview.21) (2020-08-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* if in the mask, rendering material will be destroyed ([0db40cf](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/0db40cf160b2a5a27c83ef15d648b2771a47b51a))
|
||||||
|
* support animatable material property (again) ([cf6ca80](https://github.com/mob-sakai/ParticleEffectForUGUI/commit/cf6ca80d1273bcf49e18d805260afa8e36e94617))
|
||||||
|
|
||||||
# [3.0.0-preview.20](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.19...v3.0.0-preview.20) (2020-08-28)
|
# [3.0.0-preview.20](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.19...v3.0.0-preview.20) (2020-08-28)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,20 +26,30 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
public void UpdateMaterialProperties(Material material, MaterialPropertyBlock mpb)
|
public void UpdateMaterialProperties(Material material, MaterialPropertyBlock mpb)
|
||||||
{
|
{
|
||||||
|
if (!material.HasProperty(id)) return;
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ShaderPropertyType.Color:
|
case ShaderPropertyType.Color:
|
||||||
material.SetColor(id, mpb.GetColor(id));
|
var color = mpb.GetColor(id);
|
||||||
|
if (color != default(Color))
|
||||||
|
material.SetColor(id, color);
|
||||||
break;
|
break;
|
||||||
case ShaderPropertyType.Vector:
|
case ShaderPropertyType.Vector:
|
||||||
material.SetVector(id, mpb.GetVector(id));
|
var vector = mpb.GetVector(id);
|
||||||
|
if (vector != default(Vector4))
|
||||||
|
material.SetVector(id, vector);
|
||||||
break;
|
break;
|
||||||
case ShaderPropertyType.Float:
|
case ShaderPropertyType.Float:
|
||||||
case ShaderPropertyType.Range:
|
case ShaderPropertyType.Range:
|
||||||
material.SetFloat(id, mpb.GetFloat(id));
|
var value = mpb.GetFloat(id);
|
||||||
|
if (value != default(float))
|
||||||
|
material.SetFloat(id, value);
|
||||||
break;
|
break;
|
||||||
case ShaderPropertyType.Texture:
|
case ShaderPropertyType.Texture:
|
||||||
material.SetTexture(id, mpb.GetTexture(id));
|
var tex = mpb.GetTexture(id);
|
||||||
|
if (tex != default(Texture))
|
||||||
|
material.SetTexture(id, tex);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,11 @@ namespace Coffee.UIExtensions
|
||||||
private DrivenRectTransformTracker _tracker;
|
private DrivenRectTransformTracker _tracker;
|
||||||
private Mesh _bakedMesh;
|
private Mesh _bakedMesh;
|
||||||
private readonly List<Material> _modifiedMaterials = new List<Material>();
|
private readonly List<Material> _modifiedMaterials = new List<Material>();
|
||||||
|
private readonly List<Material> _maskMaterials = new List<Material>();
|
||||||
private uint _activeMeshIndices;
|
private uint _activeMeshIndices;
|
||||||
private Vector3 _cachedPosition;
|
private Vector3 _cachedPosition;
|
||||||
private static readonly List<Material> s_TempMaterials = new List<Material>(2);
|
private static readonly List<Material> s_TempMaterials = new List<Material>(2);
|
||||||
|
private static MaterialPropertyBlock s_Mpb;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -129,10 +131,18 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
protected override void UpdateMaterial()
|
protected override void UpdateMaterial()
|
||||||
{
|
{
|
||||||
|
// Clear mask materials.
|
||||||
|
for (var i = 0; i < _maskMaterials.Count; i++)
|
||||||
|
{
|
||||||
|
StencilMaterial.Remove(_maskMaterials[i]);
|
||||||
|
_maskMaterials[i] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
_maskMaterials.Clear();
|
||||||
|
|
||||||
// Clear modified materials.
|
// Clear modified materials.
|
||||||
for (var i = 0; i < _modifiedMaterials.Count; i++)
|
for (var i = 0; i < _modifiedMaterials.Count; i++)
|
||||||
{
|
{
|
||||||
StencilMaterial.Remove(_modifiedMaterials[i]);
|
|
||||||
DestroyImmediate(_modifiedMaterials[i]);
|
DestroyImmediate(_modifiedMaterials[i]);
|
||||||
_modifiedMaterials[i] = null;
|
_modifiedMaterials[i] = null;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +183,9 @@ namespace Coffee.UIExtensions
|
||||||
if (0 < (activeMeshIndices & bit) && 0 < s_TempMaterials.Count)
|
if (0 < (activeMeshIndices & bit) && 0 < s_TempMaterials.Count)
|
||||||
{
|
{
|
||||||
var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite());
|
var mat = GetModifiedMaterial(s_TempMaterials[0], ps.GetTextureForSprite());
|
||||||
canvasRenderer.SetMaterial(mat, j++);
|
canvasRenderer.SetMaterial(mat, j);
|
||||||
|
UpdateMaterialProperties(r, j);
|
||||||
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trails
|
// Trails
|
||||||
|
@ -192,7 +204,7 @@ namespace Coffee.UIExtensions
|
||||||
if (0 < m_StencilValue)
|
if (0 < m_StencilValue)
|
||||||
{
|
{
|
||||||
baseMaterial = StencilMaterial.Add(baseMaterial, (1 << m_StencilValue) - 1, StencilOp.Keep, CompareFunction.Equal, ColorWriteMask.All, (1 << m_StencilValue) - 1, 0);
|
baseMaterial = StencilMaterial.Add(baseMaterial, (1 << m_StencilValue) - 1, StencilOp.Keep, CompareFunction.Equal, ColorWriteMask.All, (1 << m_StencilValue) - 1, 0);
|
||||||
_modifiedMaterials.Add(baseMaterial);
|
_maskMaterials.Add(baseMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture == null && m_AnimatableProperties.Length == 0) return baseMaterial;
|
if (texture == null && m_AnimatableProperties.Length == 0) return baseMaterial;
|
||||||
|
@ -205,6 +217,25 @@ namespace Coffee.UIExtensions
|
||||||
return baseMaterial;
|
return baseMaterial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void UpdateMaterialProperties(Renderer r, int index)
|
||||||
|
{
|
||||||
|
if (m_AnimatableProperties.Length == 0 || canvasRenderer.materialCount <= index) return;
|
||||||
|
|
||||||
|
r.GetPropertyBlock(s_Mpb ?? (s_Mpb = new MaterialPropertyBlock()));
|
||||||
|
if (s_Mpb.isEmpty) return;
|
||||||
|
|
||||||
|
// #41: Copy the value from MaterialPropertyBlock to CanvasRenderer
|
||||||
|
var mat = canvasRenderer.GetMaterial(index);
|
||||||
|
if (!mat) return;
|
||||||
|
|
||||||
|
foreach (var ap in m_AnimatableProperties)
|
||||||
|
{
|
||||||
|
ap.UpdateMaterialProperties(mat, s_Mpb);
|
||||||
|
}
|
||||||
|
|
||||||
|
s_Mpb.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function is called when the object becomes enabled and active.
|
/// This function is called when the object becomes enabled and active.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -205,6 +205,11 @@ namespace Coffee.UIExtensions
|
||||||
|
|
||||||
if (m.vertexCount == 0)
|
if (m.vertexCount == 0)
|
||||||
MeshHelper.DiscardTemporaryMesh();
|
MeshHelper.DiscardTemporaryMesh();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var index = MeshHelper.activeMeshIndices.BitCount() - 1;
|
||||||
|
particle.UpdateMaterialProperties(r, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bake trails particles.
|
// Bake trails particles.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "com.coffee.ui-particle",
|
"name": "com.coffee.ui-particle",
|
||||||
"displayName": "UI Particle",
|
"displayName": "UI Particle",
|
||||||
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
|
"description": "This plugin provide a component to render particle effect for uGUI.\nThe particle rendering is maskable and sortable, without Camera, RenderTexture or Canvas.",
|
||||||
"version": "3.0.0-preview.20",
|
"version": "3.0.0-preview.21",
|
||||||
"unity": "2018.2",
|
"unity": "2018.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
Loading…
Reference in New Issue