private ResourcePair FindResource(int startIndex, int stopIndexExclusive, string name, out ResourcePair.PoolOptions options) { if (startIndex == stopIndexExclusive) { options = new ResourcePair.PoolOptions(); // unable to find. return(null); } int mid = (stopIndexExclusive + startIndex) / 2; var middleElement = resources[mid]; int compareResult = name.CompareTo(middleElement.Name); if (compareResult == 0) { options = middleElement.PoolParams; return(middleElement); } if (compareResult < 0) { return(FindResource(startIndex, mid, name, out options)); } return(FindResource(mid + 1, stopIndexExclusive, name, out options)); }
public GameObject Get(string name, out ResourcePair.PoolOptions options) { return(FindResource(0, resources.Length, name, out options).Object as GameObject); }
public T Get <T>(string name, out ResourcePair.PoolOptions options) where T : UnityEngine.Object { var obj = FindResource(0, resources.Length, name, out options).Object; return(obj as T); }