I’ve got a simple ScrollUV script on a lava lake in a mobile game, and just tested it on iPad Air, and the texture scrolls very very slowly (like 2fps), while the rest of the scene runs fine. Any ideas about how to improve that? The texture scrolls just fine on iPad 2 and 3.
Here’s the script I’m using:
using UnityEngine;
using System.Collections;
public class ScrollUV : MonoBehaviour {
public Vector2 direction = new Vector2(0,1);
public float speed = 1;
void Update () {
renderer.material.mainTextureOffset += direction * speed * Time.deltaTime;
//renderer.material.SetTextureOffset("_BumpMap", renderer.material.mainTextureOffset);
}
}
I think we had a similar issue with our lava texture being scrolled along… using a script:
We had to add a “% 1” to keep the values between 0 and 1… and it worked fine again.
you should be using sharedMaterial property otherwise its creating a new material, not sure if it only creates a new material the first time .material is called or if it keeps creating a new material but I thought its worth mentioning.
Thanks for the tips. I tried your script, sabbu, but it throws a console error – any suggestions? (I need to use a script since I’m using a glow shader on the texture as well.)
Assets/Lava Textures/Scripts/ScrollUV.cs(1,25): error CS0246: The type or namespace name `MonoBehaviourBase’ could not be found. Are you missing a using directive or an assembly reference?
MonoBehaviourBase is his silly thing. Just make it MonoBehaviour
Also some tips:
Scroll small. Your scroll area for uv is 0…1 So if your texture is 512 pixels, divide 1 by 512 to get the edge and 1/256 would be halfway (0.5). So anything >1 is just causing the gpu to crap out and wrap it (in other words it is always pointless being >1).
Thanks, hippocoder. But I get the same error on MonoBehavior:
Assets/Lava Textures/Scripts/ScrollUV.cs(1,25): error CS0246: The type or namespace name `MonoBehaviour’ could not be found. Are you missing a using directive or an assembly reference?
And in Unity, I’ve got the speed set to .015…but which line determines scroll area?