Skip to content

Instantly share code, notes, and snippets.

@andanteyk
Last active September 15, 2017 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andanteyk/0bdaad2f7fb91248ab2951e5f241910d to your computer and use it in GitHub Desktop.
Save andanteyk/0bdaad2f7fb91248ab2951e5f241910d to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
// 5.6.0f3 で確認
// Image がついているオブジェクトにつける
public class NewBehaviourScript : MonoBehaviour {
// インスペクタで適宜設定する
public Sprite[] sprites;
private Image _img;
// Use this for initialization
void Start () {
_img = GetComponent<Image>();
}
// Update is called once per frame
void Update () {
int i = Random.Range(0, sprites.Length); // (適当に選ぶ)
_img.sprite = sprites[i]; // これで書き変わる
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment