Reflection and Specular Highlights: how to turn on/off? help pls!

hello world

what is the property to enable/disable Reflections and Specular Highlights (Standard Shader)?

_SpecularHighlights and _GlossyReflections are both “Float” but they are toggles (checkboxes) in the GUI

I want to control them via a checkbox but I don’t know how, please help!

Finally! I manage to get this working using keywords and setfloat

like this:

to turn ON:

 shapes.GetComponent().material.DisableKeyword("_SPECULARHIGHLIGHTS_OFF");
shapes.GetComponent().material.SetFloat("_SpecularHighlights",1f);

to turn OFF:

 shapes.GetComponent().material.EnableKeyword("_SPECULARHIGHLIGHTS_OFF");
shapes.GetComponent().material.SetFloat("_SpecularHighlights",0f);
  • it’s tricky cause there’s no “_specularhighlights_on”, instead you disable or enable “_specularhightlights_off”

@sergio7888 - tem jeito sim, fião.
cc @Arkins_prod_studio

you can create a new matherial with this prefab:[78309-capture-decran-2016-09-15-a-231729.png|78309]
i think it can work :slight_smile:

Hello there,
Just to say thanks for sharing as this helped me today :slight_smile:

Just a quick note: Unity doesn’t update the state of the checkboxes; so even after editing those keywords, it’ll still show checked / unchecked checkbox states regardless of the new value of keywords. But from now on you can ignore those checkboxes if you’re changing it through script.

Even after restarting the project, checkboxes are not refreshed correctly, but new keywords set are saved so all works well :wink:

Thanks,
Charles