GetTypeOfAsset() public static method

public static GetTypeOfAsset ( string assetPath ) : Type
assetPath string
return System.Type
 public static AssetReference CreateReference(string importFrom)
 {
     return(new AssetReference(
                guid: Guid.NewGuid(),
                assetDatabaseId: AssetDatabase.AssetPathToGUID(importFrom),
                importFrom: importFrom,
                assetType: TypeUtility.GetTypeOfAsset(importFrom)
                ));
 }
 /**
  *      Create Asset info from Loader
  */
 public static Asset CreateNewAssetFromLoader(string absoluteAssetPath, string importFrom)
 {
     return(new Asset(
                guid: Guid.NewGuid(),
                assetDatabaseId: AssetDatabase.AssetPathToGUID(importFrom),
                absoluteAssetPath: absoluteAssetPath,
                importFrom: importFrom,
                assetType: TypeUtility.GetTypeOfAsset(importFrom)
                ));
 }
 /**
  *      new assets which is generated on ImportSetting and PrefabBuilder.
  */
 public static Asset CreateNewAssetWithImportPathAndStatus(string importFrom, bool isNew, bool isBundled)
 {
     return(new Asset(
                guid: Guid.NewGuid(),
                assetDatabaseId: AssetDatabase.AssetPathToGUID(importFrom),
                importFrom: importFrom,
                assetType: TypeUtility.GetTypeOfAsset(importFrom),
                isNew: isNew,
                isBundled: isBundled
                ));
 }
        void Load(BuildTarget target,
                  NodeData node,
                  ConnectionData connectionToOutput,
                  Dictionary <string, List <Asset> > inputGroupAssets,
                  Action <ConnectionData, Dictionary <string, List <Asset> >, List <string> > Output)
        {
            // SOMEWHERE_FULLPATH/PROJECT_FOLDER/Assets/
            var assetsFolderPath = Application.dataPath + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR;

            var outputSource    = new List <Asset>();
            var targetFilePaths = FileUtility.GetAllFilePathsInFolder(node.GetLoaderFullLoadPath(target));

            foreach (var targetFilePath in targetFilePaths)
            {
                if (targetFilePath.Contains(AssetBundleGraphSettings.ASSETBUNDLEGRAPH_PATH))
                {
                    continue;
                }

                // already contained into Assets/ folder.
                // imported path is Assets/SOMEWHERE_FILE_EXISTS.
                if (targetFilePath.StartsWith(assetsFolderPath))
                {
                    var relativePath = targetFilePath.Replace(assetsFolderPath, AssetBundleGraphSettings.ASSETS_PATH);

                    var assetType = TypeUtility.GetTypeOfAsset(relativePath);
                    if (assetType == typeof(object))
                    {
                        continue;
                    }

                    outputSource.Add(Asset.CreateNewAssetFromLoader(targetFilePath, relativePath));
                    continue;
                }

                throw new NodeException(node.Name + ": Invalid Load Path. Path must start with Assets/", node.Name);
            }

            var outputDir = new Dictionary <string, List <Asset> > {
                { "0", outputSource }
            };

            Output(connectionToOutput, outputDir, null);
        }
Esempio n. 5
0
        public void Setup(string nodeName, string nodeId, string connectionIdToNextNode, Dictionary <string, List <Asset> > unused, List <string> alreadyCached, Action <string, string, Dictionary <string, List <Asset> >, List <string> > Output)
        {
            try {
                ValidateLoadPath(
                    loadFilePath,
                    loadFilePath,
                    () => {
                    //throw new NodeException(nodeName + ": Load Path is empty.", nodeId);
                },
                    () => {
                    throw new NodeException(nodeName + ": Directory not found: " + loadFilePath, nodeId);
                }
                    );
            } catch (NodeException e) {
                AssetBundleGraphEditorWindow.AddNodeException(e);
                return;
            }

            // SOMEWHERE_FULLPATH/PROJECT_FOLDER/Assets/
            var assetsFolderPath = Application.dataPath + AssetBundleGraphSettings.UNITY_FOLDER_SEPARATOR;

            var outputSource    = new List <Asset>();
            var targetFilePaths = FileUtility.FilePathsInFolder(loadFilePath);

            try {
                foreach (var targetFilePath in targetFilePaths)
                {
                    if (targetFilePath.Contains(AssetBundleGraphSettings.ASSETBUNDLEGRAPH_PATH))
                    {
                        continue;
                    }

                    // already contained into Assets/ folder.
                    // imported path is Assets/SOMEWHERE_FILE_EXISTS.
                    if (targetFilePath.StartsWith(assetsFolderPath))
                    {
                        var relativePath = targetFilePath.Replace(assetsFolderPath, AssetBundleGraphSettings.ASSETS_PATH);

                        var assetType = TypeUtility.GetTypeOfAsset(relativePath);
                        if (assetType == typeof(object))
                        {
                            continue;
                        }

                        outputSource.Add(Asset.CreateNewAssetFromLoader(targetFilePath, relativePath));
                        continue;
                    }

                    throw new NodeException(nodeName + ": Invalid Load Path. Path must start with Assets/", nodeId);
                }
            } catch (NodeException e) {
                AssetBundleGraphEditorWindow.AddNodeException(e);
                return;
            }
            catch (Exception e) {
                Debug.LogError(nodeName + " Error:" + e);
            }

            var outputDir = new Dictionary <string, List <Asset> > {
                { "0", outputSource }
            };

            Output(nodeId, connectionIdToNextNode, outputDir, new List <string>());
        }