当使用C#在Unity3D中动态加载图像时,如何使用按钮更改下一个图像。
public void NextPictureInGallery()
{
int i=0;//index of image
if(i + 1 < image.Length)
{
i++;
}
}
图片位于滚动视图中
答案 0 :(得分:1)
您可以更改ScrollRect的normalized position。
答案 1 :(得分:1)
public Sprite[] myImage; // Its length descried in Inspector and assign sprite images
public Button myBtn;
int i=0;
void Update()
{
if(Input.GetMouseButtonDown(0)) // HeresI'm checking condition for Mouse Input, Change this based on your
{
if(i+1 < myImage.Length)
{
//Make sure it is added in the Inspector.
myBtn.image.sprite = myImage[i];
i++;
}
}
}
检查并告诉我