我想从可编写脚本的对象中随机选择一个项目,然后将随机选择的项目打印到控制台。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(fileName = "Country", menuName = "Country/Country", order = 0)]
public class country : ScriptableObject
{
[System.Serializable]
public class Item
{
public string Name;
public string Currency;
public string Capital;
public string[] City;
}
public Item[] m_Items;
}
如何继续将以下值打印到控制台?
public Item PickRandomly()
{
int index = Random.Range(0, m_Items.Length);
return m_Items[index];
}