Shader can be set to refresh it?

83498-normal.jpg
I have a question about shader. i used the lab renderer in my project.

if i choose unit by mouse click, the gameobjects effect in game window will be changed immediately. but when i change it by code, the value is changed, But the effect did not change.

If I choose this object again, and the main points open shader detailed list, the effect will be changed, can anybody told me why? Why the use code to control effect will not change immediately?

if i change the texture by code , the effect will chane immediately!
83499-detail.jpg

thanks for help me

Thank you for including screenshots. Your situation is not 100% clear. Try to use your strongest English skills when posting.

It sounds like you might be discovering the difference between a material in your project’s assets and an instance of that material. In most cases, materials get instantiated when you change them with code. Each object which changes its material with code gets its own instance of that material that lives in memory, and gets destroyed when exiting play mode.

To address ALL instances of a material, when you cannot use the sharedMaterial, you’ll need a reference to every object using the original material. You can then address each instance of that material (on each object individually) to make your changes one by one.

foreach (GameObject go in myCollectionOfGameObjects) {
    go.renderer.material.SetProperty("unlit", true);
}

when i called this,

material.SetInt("g_bUnlit", 1);

it will be checking, but the effect not changed. i must to choose the material, then effect will be changed immediately.