I know that to change the value of the UI text is
textName.text = “A number of value”
But in this situation I want to change the value of the float inside the shader file instead of the UI text.
But I don’t know what code can do this function.
For example, I want to change this float value. What should I write in the c# script?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ChangeShaderSpeedScript : MonoBehaviour
{
public Material myMaterial;
public float someValue=1;
// Start is called before the first frame update
void Start()
{
myMaterial.SetFloat(“speed”, someValue);
}
// Update is called once per frame
void Update()
{
}
}
If the speed is 1, the animation plays. But it doesn’t play as the speed is still 0. I have put the Unlit_NewUnlitShader Material in myMaterial, but it is not working. What should I do?
Please answer me the CODE instead of concept! As I really know the concept.
Tutorial videos are also welcome.