Change color of material for a 3D augmented object.

So i’m creating an augmented reality app that let’s me place augmented furniture in a scene and im trying to create buttons that let me change the color of the furniture at runtime.

Furniture model has a meshrenderer component which has only 1 material (colored red)attached to it.
i’m trying to change it to a specific color by clicking a button which calls a method that changes the original red color to that specific color (let’s say blue).

I tried changing the color of the material of the models using this code:

public void ChangeColorToBlue()
        {
            Renderer rend = SelectedObject.GetComponent<Renderer>();      
            rend.material.shader = Shader.Find("Standard");
            Color blue = new Color(0, 0, 255);
            rend.material.SetColor("_Color",blue);

        }

i also tried something like this.

public void ChangeColorToBlue()
        {
          
            MeshRenderer rends = SelectedObject.GetComponent<MeshRenderer>();
            Material[] mats = rends.materials;
            mats[0].color = Color.blue;
            rends.materials = mats;

        }

both of them did not work. i don’t know where the problem is.
i’m hoping someone could help me.
thank you in advance.

From the docs: “Note that a shader might be not included into the player build if nothing references it! In that case, Shader.Find will work only in the editor, and will result in pink “missing shader” materials in the player build.”

For more information: Unity - Scripting API: Shader.Find
Hope this helps!