You've already forked ParticleEffectForUGUI
mirror of
https://github.com/mob-sakai/ParticleEffectForUGUI.git
synced 2026-05-14 20:20:06 +00:00
# [3.0.0-preview.36](https://github.com/mob-sakai/ParticleEffectForUGUI/compare/v3.0.0-preview.35...v3.0.0-preview.36) (2020-09-28) ### Bug Fixes * do not bake particle system to mesh when the alpha is zero ([1775713](1775713c2d)), closes [#102](https://github.com/mob-sakai/ParticleEffectForUGUI/issues/102) * in Unity 2018.x, sample import failed on Windows ([f5861b0](f5861b0add))
66 lines
1.9 KiB
C#
66 lines
1.9 KiB
C#
using UnityEngine;
|
|
|
|
namespace Coffee.UIExtensions
|
|
{
|
|
[System.Serializable]
|
|
public class AnimatableProperty : ISerializationCallbackReceiver
|
|
{
|
|
public enum ShaderPropertyType
|
|
{
|
|
Color,
|
|
Vector,
|
|
Float,
|
|
Range,
|
|
Texture,
|
|
}
|
|
|
|
[SerializeField] string m_Name = "";
|
|
[SerializeField] ShaderPropertyType m_Type = ShaderPropertyType.Vector;
|
|
public int id { get; private set; }
|
|
|
|
public ShaderPropertyType type
|
|
{
|
|
get { return m_Type; }
|
|
}
|
|
|
|
public void UpdateMaterialProperties(Material material, MaterialPropertyBlock mpb)
|
|
{
|
|
if (!material.HasProperty(id)) return;
|
|
|
|
switch (type)
|
|
{
|
|
case ShaderPropertyType.Color:
|
|
var color = mpb.GetColor(id);
|
|
if (color != default(Color))
|
|
material.SetColor(id, color);
|
|
break;
|
|
case ShaderPropertyType.Vector:
|
|
var vector = mpb.GetVector(id);
|
|
if (vector != default(Vector4))
|
|
material.SetVector(id, vector);
|
|
break;
|
|
case ShaderPropertyType.Float:
|
|
case ShaderPropertyType.Range:
|
|
var value = mpb.GetFloat(id);
|
|
if (value != default(float))
|
|
material.SetFloat(id, value);
|
|
break;
|
|
case ShaderPropertyType.Texture:
|
|
var tex = mpb.GetTexture(id);
|
|
if (tex != default(Texture))
|
|
material.SetTexture(id, tex);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void OnBeforeSerialize()
|
|
{
|
|
}
|
|
|
|
public void OnAfterDeserialize()
|
|
{
|
|
id = Shader.PropertyToID(m_Name);
|
|
}
|
|
}
|
|
}
|