Click here to Skip to main content
15,884,001 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using the Image Target Detection example from AR Core SDK. I want to change the color of the object at runtime through script. A material is attached to that object.

// Create an anchor to ensure that ARCore keeps tracking this augmented image.
      Anchor anchor = image.CreateAnchor(image.CenterPose);
      visualizer = (AugmentedImageVisualizer)Instantiate(
      AugmentedImageVisualizerPrefab, anchor.transform);
      visualizer.Image = image;
      m_Visualizers.Add(image.DatabaseIndex, visualizer);


      Renderer rend = visualizer.GetComponent<Renderer>();
      rend.sharedMaterial.shader = Shader.Find("BaseColor");
      Color red = new Color(255,0,0);
      rend.sharedMaterial.SetColor("_Color", red);


This is my current code which I have tried to implement after taking hint from different answers but nothing seems to work.

What I have tried:

Renderer rend = visualizer.GetComponent<Renderer>();
rend.sharedMaterial.shader = Shader.Find("BaseColor");
Color red = new Color(255,0,0);
rend.sharedMaterial.SetColor("_Color", red);
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900