32 lines
806 B
C#
32 lines
806 B
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[RequireComponent(typeof(RawImage))]
|
|
public class ImageScrollerUnscaled : MonoBehaviour {
|
|
|
|
[SerializeField]
|
|
private float speedX = default;
|
|
[SerializeField]
|
|
private float speedY = default;
|
|
[SerializeField]
|
|
private bool isStretchWidth = false;
|
|
|
|
private RawImage rawImage;
|
|
private Rect rect;
|
|
|
|
void Awake(){
|
|
rawImage = GetComponent<RawImage>();
|
|
rect = rawImage.uvRect;
|
|
|
|
if(isStretchWidth){
|
|
rect.width = rect.width * ((float)Screen.width / (float)Screen.height) / (9.0f / 16.0f);
|
|
}
|
|
}
|
|
|
|
void LateUpdate(){
|
|
rect.x += speedX * Time.unscaledDeltaTime;
|
|
rect.y += speedY * Time.unscaledDeltaTime;
|
|
rawImage.uvRect = rect;
|
|
}
|
|
}
|