mirror of
https://github.com/BlackMATov/unity-flash-tools.git
synced 2025-12-16 14:11:19 +07:00
tint color for clips
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
Shader "FlashTools/SwfMasked" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
|
||||
[PerRendererData] _MainTex("Main Texture", 2D ) = "white" {}
|
||||
[PerRendererData] _Color ("Tint" , Color) = (1,1,1,1)
|
||||
_StencilID ("Stencil ID", Int) = 0
|
||||
}
|
||||
|
||||
@@ -42,11 +43,13 @@ Shader "FlashTools/SwfMasked" {
|
||||
fixed4 addcolor : TEXCOORD1;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
|
||||
v2f vert(appdata_t IN) {
|
||||
v2f OUT;
|
||||
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
|
||||
OUT.uv = IN.uv;
|
||||
OUT.mulcolor = IN.mulcolor;
|
||||
OUT.mulcolor = IN.mulcolor * _Color;
|
||||
OUT.addcolor = IN.addcolor;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Shader "FlashTools/SwfSimple" {
|
||||
Properties {
|
||||
[PerRendererData] _MainTex("Main Texture", 2D) = "white" {}
|
||||
[PerRendererData] _MainTex("Main Texture", 2D ) = "white" {}
|
||||
[PerRendererData] _Color ("Tint" , Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader {
|
||||
@@ -37,11 +38,13 @@ Shader "FlashTools/SwfSimple" {
|
||||
fixed4 addcolor : TEXCOORD1;
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
|
||||
v2f vert(appdata_t IN) {
|
||||
v2f OUT;
|
||||
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
|
||||
OUT.uv = IN.uv;
|
||||
OUT.mulcolor = IN.mulcolor;
|
||||
OUT.mulcolor = IN.mulcolor * _Color;
|
||||
OUT.addcolor = IN.addcolor;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,16 @@ namespace FlashTools {
|
||||
}
|
||||
|
||||
[Header("Animation")]
|
||||
[SerializeField]
|
||||
Color _tint = Color.white;
|
||||
public Color tint {
|
||||
get { return _tint; }
|
||||
set {
|
||||
_tint = value;
|
||||
ChangeTint();
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
SwfClipAsset _clip = null;
|
||||
public SwfClipAsset clip {
|
||||
@@ -147,6 +157,7 @@ namespace FlashTools {
|
||||
|
||||
public void UpdateAllProperties() {
|
||||
ClearCache();
|
||||
ChangeTint();
|
||||
ChangeClip();
|
||||
ChangeSequence();
|
||||
ChangeCurrentFrame();
|
||||
@@ -161,6 +172,10 @@ namespace FlashTools {
|
||||
_curPropBlock = null;
|
||||
}
|
||||
|
||||
void ChangeTint() {
|
||||
UpdatePropBlock();
|
||||
}
|
||||
|
||||
void ChangeClip() {
|
||||
if ( _meshRenderer ) {
|
||||
_meshRenderer.enabled = !!clip;
|
||||
@@ -220,6 +235,9 @@ namespace FlashTools {
|
||||
_curPropBlock = new MaterialPropertyBlock();
|
||||
}
|
||||
_meshRenderer.GetPropertyBlock(_curPropBlock);
|
||||
_curPropBlock.SetColor(
|
||||
"_Color",
|
||||
tint);
|
||||
_curPropBlock.SetTexture(
|
||||
"_MainTex",
|
||||
clip && clip.Atlas ? clip.Atlas : Texture2D.whiteTexture);
|
||||
|
||||
Reference in New Issue
Block a user