- Home /
 
How to change material that is being scrolled for Material.SetTextureOffset
I'm using this to try and move the texture on my clothing for a vrchat character but it always only moves the skin. I wanted to know if there is a way that I can set the script to move another material. Right now it says "(instance)" next to the body material.
Like is it a raw image or is a $$anonymous$$aterial? I know how to do scrolling with raw images but if it with materials I would still be glad to help
Answer by KittenSnipes · Jan 26, 2018 at 10:09 AM
Your material would most likely need to be attached to a renderer. You can change the material like so:
     //Reference to the renderer
     Renderer thisRenderer;
 
     //Material to change the current render material to
     public Material MaterialToChangeTo;
 
     //Y offset of the material 
     public float yOffset = .25f;
 
     //X offset of the material
     public float xOffset = .25f;
 
     // Use this for initialization
     void Start()
     {
         //Get the renderer of our object
         thisRenderer = GetComponent<Renderer>();
 
         //Change the current material to the material we want
         thisRenderer.material = MaterialToChangeTo;
     }
 
     // Update is called once per frame
     void Update()
     {
         //Do that cool scroll effect on our material
         thisRenderer.material.mainTextureOffset = new Vector2(thisRenderer.material.mainTextureOffset.x + xOffset * Time.deltaTime, thisRenderer.material.mainTextureOffset.y + yOffset * Time.deltaTime);
     }
 
              it says UCE0001: ';' expected. Insert a semicolon at the end. I used this script or do I add this to the other one? void Start() { //Get the renderer of our object thisRenderer = GetComponent();
      //Change the current material to the material we want
      thisRenderer.material = $$anonymous$$aterialToChangeTo;
  }
 
  // Update is called once per frame
  void Update()
  {
      //Do that cool scroll effect on our material
      thisRenderer.material.mainTextureOffset = new Vector2(thisRenderer.material.mainTextureOffset.x + xOffset * Time.deltaTime, thisRenderer.material.mainTextureOffset.y + yOffset * Time.deltaTime);
  }
                 Answer by josedlmayer · Jan 31, 2018 at 12:11 AM
@KittenSnipes I'm trying to make the material on a character move in vrchat
Your answer