public static APStreamingAssetsFile GetStreamingAssetFile(string path) { string guid = AssetDatabase.AssetPathToGUID(path); APStreamingAssetsFile file = new APStreamingAssetsFile(); file.Path = path; file.Hash = Utility.GetFileMd5(path); file.Name = Utility.GetFileName(path); file.FileSize = Utility.GetFileSize(path); file.Icon = GetIconID(path); file.APType = AssetType.STREAMING_ASSETS; file.Id = guid; return(file); }
private static void AddNewImportAssets(string assetPath) { Utility.DebugLog(string.Format("New: {0}", assetPath)); if (!File.Exists(assetPath) && Directory.Exists(assetPath)) { return; } if (Utility.IsStreamingAssetsFile(assetPath)) { APStreamingAssetsFile file = APResources.GetStreamingAssetFile(assetPath); APCache.Add(APAssetType.StreamingAssets, file.Id, file); SyncManager.AddedAssets.Enqueue(file); return; } else if (Utility.IsCodeFile(assetPath)) { APCodeFile codeFile = APResources.GetCodeFile(assetPath); APCache.Add(APAssetType.Script, codeFile.Id, codeFile); SyncManager.AddedAssets.Enqueue(codeFile); return; } var guid = AssetDatabase.AssetPathToGUID(assetPath); UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object)); APAsset asset = null; // if new path // if (obj is Texture) { if (obj is MovieTextureType) { var movie = APResources.GetAPAssetByPath(APAssetType.MovieTexture, guid); if (movie != null) { APCache.SetValue(APAssetType.MovieTexture, movie.Id, movie); } SyncManager.AddedAssets.Enqueue(movie); return; } asset = APResources.GetAPAssetByPath(APAssetType.Texture, guid); if (asset != null) { APCache.SetValue(APAssetType.Texture, asset.Id, asset); } } else if (Utility.IsModels(obj, assetPath)) { AddModelInCache(assetPath); return; } else if (obj is AnimationClip) { asset = APResources.GetAPAssetByPath(APAssetType.AnimationClip, guid); if (asset != null) { APCache.SetValue(APAssetType.AnimationClip, asset.Id, asset); } } else if (obj is AudioClip) { asset = APResources.GetAPAssetByPath(APAssetType.AudioClip, guid); if (asset != null) { APCache.SetValue(APAssetType.AudioClip, asset.Id, asset); } } else if (obj is Font) { asset = APResources.GetAPAssetByPath(APAssetType.Font, guid); if (asset != null) { APCache.SetValue(APAssetType.Font, asset.Id, asset); } } else if (obj is Shader) { asset = APResources.GetAPAssetByPath(APAssetType.Shader, guid); if (asset != null) { APCache.SetValue(APAssetType.Shader, asset.Id, asset); } } else if (obj is Material || obj is PhysicMaterial || obj is PhysicsMaterial2D) { asset = APResources.GetAPAssetByPath(APAssetType.Material, guid); if (asset != null) { APCache.SetValue(APAssetType.Material, asset.Id, asset); } } else if (Utility.IsPrefab(assetPath)) { asset = APResources.GetAPAssetByPath(APAssetType.Prefab, guid); if (asset != null) { APCache.SetValue(APAssetType.Prefab, asset.Id, asset); } } else { if (assetPath.ToLower().StartsWith("assets")) { asset = APResources.GetOtherFile(assetPath); if (asset != null) { APCache.Add(APAssetType.Others, asset.Id, asset); } } } if (asset != null) { SyncManager.AddedAssets.Enqueue(asset); } Utility.DebugLog("New object type = " + obj); }