تصميم وجوه عشوائية لدومينو- UNITY3D
ملاحظة : ننشى داخل Assets مجلد اسمه Resources وبداخل هذا المجلد ننشى مجلد اخر اسمه facedomin ونضع داخله الصور
diceSides = Resources.LoadAll<Sprite> ("facedomin/");
//---------------------------- Script Code ---------------------------------------//
using System.Collections;
using UnityEngine;
public class Domin : MonoBehaviour {
private Sprite[] diceSides;
private SpriteRenderer rend;
void Start () {
rend = GetComponent<SpriteRenderer> ();
diceSides = Resources.LoadAll<Sprite> ("facedomin/");
}
private void OnMouseDown(){
StartCoroutine ("RollTheDice");
}
private IEnumerator RollTheDice(){
int randomDiceside = 0;
int finalside = 0;
for(int i=0;i<=30;i++){
randomDiceside = Random.Range (0,6);
rend.sprite=diceSides[randomDiceside];
yield return new WaitForSeconds (0f);
}
finalside = randomDiceside + 1;
}
}
//---------------------------------------------------------------------------------------------------//
إرسال تعليق