예제 #1
0
        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));
        }
예제 #2
0
 public GameObject Get(string name, out ResourcePair.PoolOptions options)
 {
     return(FindResource(0, resources.Length, name, out options).Object as GameObject);
 }
예제 #3
0
        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);
        }