using System; using System.Collections.Generic; using UnityEngine; [AddComponentMenu("NGUI/Examples/Equip Random Item")] public class EquipRandomItem : MonoBehaviour { private void OnClick() { if (this.equipment == null) { return; } List items = InvDatabase.list[0].items; if (items.Count == 0) { return; } int max = 12; int num = UnityEngine.Random.Range(0, items.Count); InvBaseItem invBaseItem = items[num]; InvGameItem invGameItem = new InvGameItem(num, invBaseItem); invGameItem.quality = (InvGameItem.Quality)UnityEngine.Random.Range(0, max); invGameItem.itemLevel = NGUITools.RandomRange(invBaseItem.minItemLevel, invBaseItem.maxItemLevel); this.equipment.Equip(invGameItem); } public InvEquipment equipment; }