EDIT:
After posting my problem in another forum:
https://gamedev.stackexchange.com/questions/163653/how-to-play-a-materials-shader-in-an-image-unity-5-2-0f3
We tried something else:
IEnumerator WaitForInteractiveElementTransform(Animator animator)
{
if (animator != null)
{
while (animator.GetCurrentAnimatorStateInfo(0).length >
animator.GetCurrentAnimatorStateInfo(0).normalizedTime)
{
yield return null;
}
}
if (animatorBackground != null)
{
animatorBackground.SetBool("On", true);
}
else
{
P4.gameObject.SetActive(false);
P4Fantasy.gameObject.SetActive(true);
}
state = SceneState.Unreal;
StartCoroutine(SetMaterialFloatOverTime(spriteRendererMaterial, 1.5f, "Slider_Dissolve"));
private IEnumerator SetMaterialFloatOverTime(Material material, float duration, string propertyName)
{
float timer = 0;
while (timer < duration)
{
material.SetFloat(propertyName, timer);
spriteRenderer.material = material;
timer += Time.deltaTime;
yield return null;
}
}
But unfortunately the same problem: We see the slider moving in the Unity inspector, but in-game the transition of the material isn’t updating.
Here a topic we thought it would help: https://forum.unity.com/threads/material-isnt-updating-when-using-setfloat.530548/ Unfortunately nope. Here our shader:
Shader "Shader Forge/SpriteDissolve" {
Properties {
_Slider_Dissolve ("Slider_Dissolve", Range(0, 1.5)) = 1.5
_Slider_Border ("Slider_Border", Color) = (1,0.7655173,0,1)
_Slider_Transition ("Slider_Transition", Range(0, 0.2)) = 0.1083302
_0RED1GREEN2BLUE ("0 = RED // 1 = GREEN // 2= BLUE", Float ) = 0
_Texture2 ("Texture 2", 2D) = "white" {}
_Texture1 ("Texture 1", 2D) = "white" {}
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}
SubShader {
Tags {
"IgnoreProjector"="True"
"Queue"="Transparent"
"RenderType"="Transparent"
"CanUseSpriteAtlas"="True"
"PreviewType"="Plane"
}
Blend SrcAlpha OneMinusSrcAlpha
Pass {
Name "FORWARD"
Tags {
"LightMode"="ForwardBase"
}
Blend One OneMinusSrcAlpha
Cull Off
ZWrite Off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define UNITY_PASS_FORWARDBASE
#pragma multi_compile _ PIXELSNAP_ON
#include "UnityCG.cginc"
#pragma multi_compile_fwdbase
#pragma exclude_renderers gles3 metal d3d11_9x xbox360 xboxone ps3 ps4 psp2
#pragma target 3.0
uniform float _Slider_Dissolve;
uniform float4 _Slider_Border;
uniform float _Slider_Transition;
uniform float _0RED1GREEN2BLUE;
uniform sampler2D _Texture2; uniform float4 _Texture2_ST;
uniform sampler2D _Texture1; uniform float4 _Texture1_ST;
struct VertexInput {
float4 vertex : POSITION;
float2 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float2 uv0 : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
#ifdef PIXELSNAP_ON
o.pos = UnityPixelSnap(o.pos);
#endif
return o;
}
float4 frag(VertexOutput i, float facing : VFACE) : COLOR {
float isFrontFace = ( facing >= 0 ? 1 : 0 );
float faceSign = ( facing >= 0 ? 1 : -1 );
////// Lighting:
////// Emissive:
float4 _Texture1_var = tex2D(_Texture1,TRANSFORM_TEX(i.uv0, _Texture1));
float4 _Texture2_var = tex2D(_Texture2,TRANSFORM_TEX(i.uv0, _Texture2));
float node_9964_if_leA = step(1.0,_0RED1GREEN2BLUE);
float node_9964_if_leB = step(_0RED1GREEN2BLUE,1.0);
float node_6089 = (lerp((node_9964_if_leA*_Texture1_var.b)+(node_9964_if_leB*_Texture1_var.r),_Texture1_var.g,node_9964_if_leA*node_9964_if_leB)*length((1.0 - i.uv0)));
float node_2567 = step(node_6089,_Slider_Dissolve);
float3 emissive = lerp(lerp(_Texture1_var.rgb,_Texture2_var.rgb,node_2567),_Slider_Border.rgb,(node_2567*step(_Slider_Dissolve,(node_6089+_Slider_Transition))*0.1));
float3 finalColor = emissive;
return fixed4(finalColor,1);
}
ENDCG
}
}
FallBack "Diffuse"
CustomEditor "ShaderForgeMaterialInspector"
}
We hope someone can help us solve our problem
Thanks!