- Home /
Noob to Shaders - How to check for PlayerPref
Ok so as you can tell from the title, I don't exactly know much about shaders and how they work, I really only use ones by others and modify the settings.
In my example, I have a setting on a shader called 'Shine' which to my understanding is a Float:
_ShineAmount ("Shine Amount", Float) = 30
In my js code, I have a PlayerPref being a float called 'SparkleAmount' which is tweaked by a slider I have put together.
How would I go about on the shader making it change the 'Shine Amount' value based on PlayerPrefs.GetFloat("SparkleAmount");?
Thanks!
Answer by Landern · Nov 19, 2014 at 08:46 AM
http://docs.unity3d.com/ScriptReference/Material.SetFloat.html
More to the point:
float sAmount = PlayerPrefs.GetFloat("SparkAmount"); // c#
var sAmount : float = PlayerPrefs.GetFloat("SparkAmount"); // Java/UnityScript
someGameObject.renderer.material.SetFloat("_ShineAmount", sAmount);
Your answer
![](https://koobas.hobune.stream/wayback/20220613171910im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Sizeof float in cg shader 1 Answer
Converting from an Int to a Float and back with PlayerPrefs 1 Answer
Why will Playerprefs not save my score on Android / iOS? 2 Answers
How to make a GameObject collide properly with an animated plane? 0 Answers
How do I take a public float from a different script and access it 0 Answers