Hi.
I’m trying to access my shader material to my script to control dissolve timer.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class uuyyy : MonoBehaviour
{
public Shader myMeshShader;
public float shadertime = 0; // dessolve value
void Start()
{
myMeshShader = gameObject.GetComponent<Shader>();
shadertime = myMeshShader.set ............. // setGlobalFloat !!
}
}
You want the Material.SetFloat() command.
If you click the little cog icon in the inspector for the shader and go edit, you will get a list of editable values and somewhere you will find the dissolve value. May look something like _DesolveValue
Thank you your respond. actually, you right about the SetFloat. I should use it. Any way Here is the full script.
public Material _shader;
public float timer = 0;
// Start is called before the first frame update
void Start()
{
// _shader = gameObject.GetComponent<Renderer>().material; // this line will duplicate the mate !! I don't know why ? So, no need to use it
_shader.SetFloat("Vector1_F92326F1", timer); // How I get the name from shader file..look at image down.
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
timer += 0.01f;
_shader.SetFloat("Vector1_F92326F1", timer);
}
}