- Home /
The question is answered, right answer was accepted
Setting unitys new shader graphs properties via C#
Hi,
My problem and what I tried
I'm currently trying to set a property in Unitys new shader graph via my c# script. I tried the below, but it didn't work. material.SetVector("Offset", new Vector2(xCoord, zCoord));
What I am doing
I'm trying to make a water effect. I'm currently using perlin, and than editing an offset to make waves. I than made a water shader (in unitys new shader graph tool), and would like to try and match it against the offset so that it looks more realistic. Any suggestions? It would be greatly appreciated.
~Jared
Answer by CHNGames · May 04, 2018 at 08:16 PM
Hello, You can access shader graph properties via c# script. Your code is true but the your property name is not offset, Unity's Shader graph names properties randomly. You need to use these names that are in red circle in image.
Hi exploit4,
Thanks for the reply. I have moved on since than but I'll test out what you said the next time I mess with shaders again.
Thanks again.
~Jared
Thank you for this answer, really helped me out. It may be worth noting that you can also add your own reference for the value ins$$anonymous$$d of getting the randomly generated characters at the end of the name.
This can be defined in the shader graph window inside the respective property inside the dashboard.
Thanks again for the answer.
Answer by Flindt · Nov 21, 2018 at 02:00 PM
Hi there
Is it true that it is not possible to set a property from within shader graph? = is it only possible to set from script?
Let say i need to store a temporary value - to offset something - then is it not possible inside shader graph?
Probably, they fixed the blackboard of Shader Graph. I haven't tested yet, but I think, you can set property values by using blackboard ins$$anonymous$$d of using script.
Follow this Question
Related Questions
Can this explosion effect be created in Unity 3.5? 1 Answer
How to detect collision with shaders? 0 Answers
Changing Queue in shader has no effect 1 Answer
Unity Water4 simple shader not working from above 0 Answers
Different wave speeds 1 Answer