Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

Animating Offset on a Quad is causing stretching issue only with iOS devices - Using Wrap Mode: Repeat

$
0
0
I added a 3D Object > Quad and added a graphic on it with the Wrap Mode set to Repeat. I'm animating the Offset to scroll the repeating image for a parallax effect. Everything is working perfectly with in Editor and Android devices. On iOS devices, the image shows fine and then stretches as the offset is changing. I'm attaching 2 screen shots of the image import settings - Quad settings, and the issue on the iPhone. Below is my code: public float scrollSpeed = 0.05f; private Vector2 savedOffset; Rigidbody2D player; void Start () { GameObject player_go = GameObject.FindGameObjectWithTag("Player"); if (player_go == null) { //Debug.LogError("Couldn't find an object with tag 'Player'"); return; } player = player_go.GetComponent(); savedOffset = GetComponent().sharedMaterial.GetTextureOffset("_MainTex"); } void FixedUpdate() { if(player.GetComponent().dead) { return; } float vel = Time.fixedTime * scrollSpeed; float y = Mathf.Repeat(vel, 1); Vector2 offset = new Vector2(y, savedOffset.x%1); offset.x = (float) System.Math.Round (offset.x, 3); //Mathf.Round (offset.x * 10) / 10; Debug.Log ("Offset:" + offset.x); if (offset.x > 1) { offset.x = 0; } GetComponent().sharedMaterial.SetTextureOffset("_MainTex", offset); } void OnDisable() { GetComponent().sharedMaterial.SetTextureOffset("_MainTex", savedOffset); } ![alt text][1] ![alt text][2] [1]: /storage/temp/66075-graphicimportsettings.png [2]: /storage/temp/66076-img-1191.png

Viewing all articles
Browse latest Browse all 4709

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>