image组件的相关属性
其中SpriteMode,若为单个图片则为Single,图片集则为Multiple
图集的切割
点击Slice可以进行自动切割
为且每个格子都可以进行单独的九宫格切割
当图片被九宫格切割再进行拉伸以后,九宫格的四角不会被拉伸
Tiled(平铺模式)
把图片的上下部分和左右部分的图像进行平铺
filed
Rawimage
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Rawimage : MonoBehaviour
{
private RawImage rawImage;
private float offsetX;
private float offsetY;
// Start is called before the first frame update
void Start()
{
rawImage = GetComponent<RawImage>();
offsetX = 1 / 12f;
offsetY = 1f;
StartCoroutine("Ani");
}
private IEnumerator Ani()
{
while (true)
{
float x = 0;
float y = 0;
while (true)
{
x += offsetX;
rawImage.uvRect = new Rect(x,y,rawImage.uvRect.width,rawImage.uvRect.height);
yield return new WaitForSeconds(0.3f);
}
}
}
}