- Home /
Shader.PropertyToID() - How does it work?
I've just started working with shaders more and discovered Shader.PropertyToID(). It works just fine for me but I don't understand how it works.
So you pass in the name of name of the property you want and it gives you a number ID for that property. That's simple enough, but how does it know which shader I want the property from? How can it know when you don't give it a reference to the shader you want? What if there are multiple shaders with properties that share the same name? How would it know which property I want then?
I've been looking everywhere for how and why this works but to no avail. Some insight into this would be greatly appreciated.
Answer by Remy_Unity · Jan 30, 2018 at 09:24 AM
I think it's just some kind of hash. So the same property name will always return the same hash for any shader. That also why if you change the shader of a material, if the old and new one have the same properties, it will retain their values.
Your answer
Follow this Question
Related Questions
how to apply universal shaders? 0 Answers
Shaders and Trail Renderer don't work on Mobile using Qualcomm Vuforia Plug-in. 0 Answers
Problem after upgrading from Unity 4.6 to Unity 5 0 Answers
How to merge two images at runtime? 1 Answer
Change saturation dynamically around the Player object? 0 Answers