Hey Guys,
I’m attempting to scroll a texture by updating its .y offset value in script. In the inspector, when I’m not running the script, changing the y value works fine and the texture scrolls as expected.
When I run my script, which simply increments the y value, nothing happens. The .y offset value stays at zero and the texture doesn’t move. However…while the script is still running, when I click in the .y field of the offset in the inspector it instantly updates to the correct .y value…but the texture does not move.
The texture is set to “Repeat”.
Its like the .y value is being updated correctly but is not be applied to the material/texture.
Any thoughts on what I’m missing?
Cheers
Touchy
public Vector2 currentOffset;
// Use this for initialization
void Start ()
{
currentOffset = new Vector2(0,0);
}
// Update is called once per frame
void Update ()
{
if(Input.GetKey (KeyCode.U))
{
currentOffset.y += 1;
gameObject.GetComponent<Renderer>().material.mainTextureOffset = currentOffset;
Debug.Log (currentOffset);
}
}