- Home /
How to move quads using script?
I am trying to make a scrolling background with quads to make it suit every resolution. But since texture type "Advanced" was removed from Unity, I cant find a way to move those quads from script. Thanks for any help.
Hi @Lakyn
$$anonymous$$oving a quad is not any different than moving any object.
See the manual:
https://docs.unity3d.com/ScriptReference/Transform.Translate.html https://docs.unity3d.com/ScriptReference/Transform-position.html
I don't quite know what you mean by removal of Advanced texture type - are you actually talking about "moving" texture by animating material UV coordinates?
Yeah thank you for re$$anonymous$$ding @eses. I havent asked clearly. I am trying to animate the background image made as material(attached to a quad object) to be scrolling. I tried it with following script:
public class BGLooper : $$anonymous$$onoBehaviour {
public float speed = 0.1f;
private Vector2 offset = Vector2.zero;
private $$anonymous$$aterial mat;
void Start () {
mat = GetComponent<Renderer>().material;
offset = mat.GetTextureOffset("_$$anonymous$$ainTex");
}
void Update () {
offset.x = speed * Time.deltaTime;
mat.SetTextureOffset("_$$anonymous$$ainTex", offset);
}
}
And it didnt work...
Answer by bpaynom · Sep 07, 2018 at 09:55 AM
Make sure you set the Wrap Mode to Repeat in the Inspector Panel of the texture.
And Change the your line offset.x = speed * Time.deltaTime;
for this one offset.x += speed * Time.deltaTime;
Notice the +=
Your answer
Follow this Question
Related Questions
How do I reduce resource cost of textured quads? 0 Answers
Randomize texture within prefab 0 Answers
Assigning UV Map to model at runtime 0 Answers
GUI.DrawTexture over screen 2 Answers
How to change standard trees' texture 0 Answers