unity 使用数字图片来代替数字0到9显示

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Trackracecomplete : MonoBehaviour
{
///
/// 数字图片
///
[SerializeField] private Sprite[] sprites;
private string _Time= “23:57:49”;
[SerializeField]
private List _numimgs;

void Start()
{
    string[] _TimeArray= _Time.Split(':');
    int num1 = int.Parse(_TimeArray[0]) / 10 % 10;
    int num2 = int.Parse(_TimeArray[0]) % 10;
    int num3 = int.Parse(_TimeArray[1]) / 10 % 10;
    int num4 = int.Parse(_TimeArray[1]) % 10;
    int num5 = int.Parse(_TimeArray[2]) / 10 % 10;
    int num6 = int.Parse(_TimeArray[2]) % 10;
    Debug.Log("num1:" + num1 + "num2:" + num2 + "num3:" + num3 + "num4:" + num4 + "num5:" + num5 + "num6:" + num6+"ces:"+ sprites[num1]);
    _numimgs[0].sprite = sprites[num1];
    _numimgs[1].sprite = sprites[num2];
    _numimgs[2].sprite = sprites[num3];
    _numimgs[3].sprite = sprites[num4];
    _numimgs[4].sprite = sprites[num5];
    _numimgs[5].sprite = sprites[num6];
}

}

你可能感兴趣的:(unity,游戏引擎)