guids | 要上传到加速器的 GUID 数组。如果数组为空,则上传所有资源。 |
uploadAllRevisions | 指定是否应上传与提供的 GUID 对应的资源的所有版本。每次编辑资源时,都会创建一个新版本。版本还包括非主资源。也就是说,不是通过其默认导入器为资源类型生成的资源,而是由其他导入器生成的资源。一个例子是预览导入器。它使用相同的资源 GUID,但使用不同的导入器生成资源预览。 |
将指定的 GUID 上传到加速器。如果 keys 为空,则上传所有资源。
使用此方法以异步方式将资源上传到加速器。当使用 Unity 打开已导入的项目但之前未使用加速器导入时,可以使用此 API。此方法允许您上传由 guids 数组指定的资源。如果提供的数组为空或为 null,则上传所有资源。此外,如果您希望在持续集成服务器上运行此命令,请使用命令行参数 -cacheServerUploadExistingImports。**注意:**使用此 API 时,也将上传非主资源。例如,如果您有一个带有预览的预制件,则在仅指定预制件的 GUID 时,预制件及其预览都将上传到加速器。
using UnityEngine; using UnityEditor;
public class CacheServerExamples { [MenuItem("CacheServer/UploadAllAssetsToCacheServer")] public static void UploadAllAssetsToCacheServer() { //This will upload all Assets to Accelerator CacheServer.UploadArtifacts(); }
}
using UnityEngine; using UnityEditor;
public class CacheServerExamples { [MenuItem("CacheServer/UploadAllPrefabsToCacheServer")] public static void UploadAllPrefabsToCacheServer() { var prefabFileGUIDs = AssetDatabase.FindAssets("t:Prefab"); var guids = new GUID[prefabFileGUIDs.Length]; var counter = 0; foreach (var curGUID in prefabFileGUIDs) { guids[counter] = new GUID(curGUID); ++counter; }
//This will upload all Prefabs to Accelerator CacheServer.UploadArtifacts(guids); } }
using UnityEngine; using UnityEditor; public class CacheServerExamples { [MenuItem("CacheServer/UploadAllScriptsToCacheServer")] public static void UploadAllScriptsToCacheServer() { var scriptFileGUIDs = AssetDatabase.FindAssets("t:Script"); var guids = new GUID[scriptFileGUIDs.Length]; var counter = 0; foreach (var curGUID in scriptFileGUIDs) { guids[counter] = new GUID(curGUID); ++counter; } //This will upload all Scripts to Accelerator CacheServer.UploadArtifacts(guids); } }
using UnityEngine; using UnityEditor;
public class CacheServerExamples { [MenuItem("CacheServer/UploadAllTextureVersionsToCacheServer")] public static void UploadAllTextureVersionsToCacheServer() { var textureGUIDs = AssetDatabase.FindAssets("t:Texture"); var guids = new GUID[textureGUIDs.Length]; var counter = 0; foreach (var curGUID in textureGUIDs) { guids[counter] = new GUID(curGUID); ++counter; }
//Every time an asset is modified, and imported, a new revision //of that Asset is created. As such, the history of the import //results of an Asset are kept around, and purged when the Editor //is restarted. //Supplying the uploadAllRevisions as true, then all revisions //of an asset will be uploaded. CacheServer.UploadArtifacts(guids, true); } }