- Home /
Change shader values independent from material through script?
Hi guys,
i want to change the actual shader values at runtime like e.g.
_Glossiness ("Smoothness", Range(0,1)) = 0.5
independent from the material, so that I can export and re-attach the shader to another material without having to set all the values again.
Until now i only found material dependent shader value changes like e.g. this: material.SetFloat ("_Glossiness", smoothnessValue);
Is it even possible to change the values of a shader from a script at runtime without just changing the values material dependent?
Thanks for reading!
The only Idea i had until now was to use a streamwriter to write a completely new file...
But how? I cant just write into a file while the program is running right?
If you want to do it that way, you can. Using the .NET framework, you can access System.IO, which allows you to write to files through code.
https://msdn.microsoft.com/en-us/library/system.io%28v=vs.110%29.aspx
https://msdn.microsoft.com/en-us/library/system.io.file%28v=vs.110%29.aspx
Your answer
![](https://koobas.hobune.stream/wayback/20220612073134im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Weird shader thing 1 Answer
Problem with custom shader (ShaderLab + Cg) 1 Answer
Unity 5 shaders and alpha on sprites broken? 2 Answers
Shaders in Unity2018 0 Answers
Get shadowmap in HDRP with commandBuffer 0 Answers