コード例 #1
0
        public static List <string> FindAssetOnlyName(CustomPath path)
        {
            if (!Application.isEditor)
            {
                return(null);
            }
            List <string> ret      = new List <string>();
            string        fileName = string.Empty;

            foreach (string t in path._pathParts)
            {
                if (t.Contains('.'))
                {
                    fileName = t;
                }
            }

            foreach (var t in AssetDatabase.GetAllAssetPaths())
            {
                if (t.Contains(fileName))
                {
                    ret.Add(t);
                }
            }
            return(ret);
        }
コード例 #2
0
        public static IProcedureParsable FindAssetWithPath(CustomPath path)
        {
            int tempIndex = path.FileNameIndex + 1;

            if (path.FileName.EndsWith(PrefabExtension))
            {
                GameObject targetGameObject = AssetDatabase.LoadAssetAtPath <GameObject>(path.FilePath);
                if (targetGameObject == null)
                {
                    return(null);
                }
                Transform targetObject = targetGameObject.transform;
                while (path[tempIndex].Contains(ObjPrefix))
                {
                    targetObject = targetObject.Find(path[tempIndex].Substring(2));
                    tempIndex++;
                }

                string             componentName   = path[tempIndex++].Substring(2);
                IProcedureParsable targetComponent = targetObject.GetComponent(componentName) as IProcedureParsable;
                if (targetComponent == null)
                {
                    return(null);
                }

                return(targetComponent);
            }
            else if (path.FilePath.EndsWith(AssetExtension))
            {
                IProcedureParsable targetScriptableObject =
                    AssetDatabase.LoadAssetAtPath <ScriptableObject>(path.FilePath) as IProcedureParsable;
                if (targetScriptableObject == null)
                {
                    return(null);
                }
                return(targetScriptableObject);
            }
            return(null);
        }