码迷,mamicode.com
首页 > 编程语言 > 详细

unity创建一个数组,让它随机输出数组里的东西

时间:2017-12-12 01:07:17      阅读:4009      评论:0      收藏:0      [点我收藏+]

标签:gpo   csharp   ima   src   es2017   system   blog   ati   body   

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class Choice : MonoBehaviour {
    public Text tips;
    // Use this for initialization
    void Start () {
         
    }
    public void ChioceBtnEvent()
    {
        string[] NameArray = new string[] {"001婷婷", "002贺堂", "003   莹","004润生","005满想","006   鑫",
            "007丽叶","008梦怡","009燕杰","010小华","011维豪","012朋",
            "013梦凡","014银利","015玉娣","016剑锋","017   龙","018   宁",
           };
        int a = Random.Range(0,18);
        tips.text = "结果是:"+"\n"+NameArray[a].ToString();
 
 
    }
     
}

  技术分享图片

把代码拖到按钮上,然后绑定内容,运行就可以输出. 

unity创建一个数组,让它随机输出数组里的东西

标签:gpo   csharp   ima   src   es2017   system   blog   ati   body   

原文地址:http://www.cnblogs.com/Du652597991qq/p/8025664.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!