Hi, I have a texture on a plane that I’m scaling over time & would like the image to remain ‘centred’ but just change in size. Currently when it is scaling up (the image gets larger) the image appears to be moving up & to the right of the screen. What I would like is for the image in the centre of the screen to remain centred but just increase in size. This is the script I’m using:
using UnityEngine;
using System.Collections;
public class TextureScaling : MonoBehaviour {
public Renderer rend;
void Start() {
rend = GetComponent<Renderer>();
}
void Update() {
// zoom in
float scaleX = rend.material.mainTextureScale.x -0.1f *Time.deltaTime;
float scaleY = rend.material.mainTextureScale.y -0.1f*Time.deltaTime;
rend.material.mainTextureScale = new Vector2(scaleX, scaleY);
}
}
Can anyone point me towards what I need to do to keep it centred?
Thanks