纳金网
标题:
unity3d中随机出现图片。
[打印本页]
作者:
比巴卜
时间:
2012-10-11 09:37
标题:
unity3d中随机出现图片。
有六张图片,如何在点击一个物体后,随机出现六张图片中的其中一张,要随机。求代码
作者:
艾西格亚
时间:
2012-10-11 09:55
随机获得图片的代码如下。
//--------------------------------------
using UnityEngine;
using System.Collections;
public class RandomTexture : MonoBehaviour
{
public Texture[] texList;
Texture GetRandomTex()
{
if (texList.Length > 0)
{
//参数为int的Random为左闭右开区间
int random = Random.Range(0, texList.Length);
return texList[random];
}
return null;
}
}
作者:
比巴卜
时间:
2012-10-18 17:29
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5