You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
659 B

using UnityEngine;
[CreateAssetMenu(fileName = "StringList", menuName = "ScriptableObject/Util/StringList")]
public class StringList : ScriptableObject
{
[SerializeField] string[] strings;
public string[] Strings => strings;
public string this[int index] => strings[index];
public int Length => strings.Length;
public string GetRandomString()
{
return strings[Random.Range(0, strings.Length)];
}
public bool TryGetString(int index, out string result)
{
result = null;
if(index >= 0 && index < strings.Length)
result = strings[index];
return result != null;
}
}