public void UpdateObjectsIntoCache(APAssetType type, APAsset asset, Queue <APAsset> modifedAssets = null) { if (APCache.HasAsset(type, asset.Id)) { APCache.SetValue(type, asset.Id, asset); if (modifedAssets != null) { modifedAssets.Enqueue(asset); } } }
private static void AddModelInCache(string modelAssetPath) { var guid = AssetDatabase.AssetPathToGUID(modelAssetPath); var asset = APResources.GetAPAssetByPath(APAssetType.Model, guid); APCache.SetValue(APAssetType.Model, guid, asset); SyncManager.AddedAssets.Enqueue(asset); var animationClipAssetids = APResources.GetAnimationClipAssetIdInModel(modelAssetPath); foreach (var id in animationClipAssetids) { var clip = APResources.GetAPAssetByPath(APAssetType.AnimationClip, id); APCache.SetValue(APAssetType.AnimationClip, id, clip); SyncManager.AddedAssets.Enqueue(clip); } }
public void UpdateObjectsIntoCache(APAssetType type, string assetid, Queue <APAsset> modifedAssets = null) { APAsset asset = APResources.GetAPAssetByPath(type, assetid); if (APCache.HasAsset(type, assetid)) { var previousAssets = APCache.GetValue(type, assetid); if (asset != null && previousAssets != null) { asset.Used = previousAssets.Used; APCache.SetValue(type, assetid, asset); if (modifedAssets != null) { modifedAssets.Enqueue(asset); } } } }
private static void UpdateModelInCache(string modelAssetPath) { var guid = AssetDatabase.AssetPathToGUID(modelAssetPath); webCommunicationService.UpdateObjectsIntoCache(APAssetType.Model, guid, SyncManager.ModifiedAssets); var animationsInCache = APCache.GetAssetsListByTypeFromCache <APAnimation>(APAssetType.AnimationClip); HashSet <string> animationsAssetIdInCache = new HashSet <string>(); foreach (var animation in animationsInCache) { if (animation.Id.ToLower().Contains(guid.ToLower())) { animationsAssetIdInCache.Add(animation.Id); } } var clipIds = APResources.GetAnimationClipAssetIdInModel(modelAssetPath); foreach (var id in clipIds) { if (animationsAssetIdInCache.Contains(id)) { webCommunicationService.UpdateObjectsIntoCache(APAssetType.AnimationClip, id, SyncManager.ModifiedAssets); } else { var clip = APResources.GetAPAssetByPath(APAssetType.AnimationClip, id); APCache.SetValue(APAssetType.AnimationClip, id, clip); SyncManager.AddedAssets.Enqueue(clip); } } foreach (var id in animationsAssetIdInCache) { if (!clipIds.Contains(id)) { var clip = APCache.GetValue(APAssetType.AnimationClip, id); APCache.Remove(id); SyncManager.DeleteAssets.Enqueue(clip); } } }
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); }