Ejemplo n.º 1
0
        public static Component GetOne(Type t, string targetName)
        {
            ValidateCache();

            List <string> paths = PrefabCache.Instance.GetPrefabs(t);

            if (paths == null)
            {
                return(null);
            }

            (string bestPath, _) = NameProcessor.GetMatching(paths, targetName);

            return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath).GetComponent(t));
        }
Ejemplo n.º 2
0
        public static Object GetOne(Type t, string targetName)
        {
            List <string> paths = AssetDatabase.FindAssets("t:" + t.Name)
                                  .Select(AssetDatabase.GUIDToAssetPath)
                                  .ToList();

            if (paths.Count == 0)
            {
                return(null);
            }

            (string bestPath, _) = NameProcessor.GetMatching(paths, targetName);

            return(AssetDatabase.LoadAssetAtPath(bestPath, t));
        }
Ejemplo n.º 3
0
        public static GameObject GetOne(string targetName)
        {
            ValidateCache();

            (Type bestType, int typeScore)   = NameProcessor.GetMatching(PrefabCache.Instance.AllTypes, targetName);
            (string bestPath, int pathScore) = NameProcessor.GetMatching(PrefabCache.Instance.AllPaths, targetName);

            if (typeScore > pathScore)
            {
                List <string> paths = PrefabCache.Instance.GetPrefabs(bestType);

                if (paths != null)
                {
                    (bestPath, _) = NameProcessor.GetMatching(paths, targetName);
                }
            }

            return(AssetDatabase.LoadAssetAtPath <GameObject>(bestPath));
        }