Beispiel #1
0
        private static void HandleDeletedAssets(string[] deletedAssets)
        {
            var animationClips = APCache.GetAssetsListByTypeFromCache <APAnimation>(APAssetType.AnimationClip);

            foreach (var assetPath in deletedAssets)
            {
                Utility.DebugLog(string.Format("Deleted: {0}", assetPath));

                if (Utility.IsModelPath(assetPath))
                {
                    foreach (var clip in animationClips)
                    {
                        if (clip.Path.Contains(assetPath))
                        {
                            APCache.Remove(APAssetType.AnimationClip, clip.Id);
                            SyncManager.DeleteAssets.Enqueue(clip);
                            SyncManager.DeleteAssets.Enqueue(APResources.GetBlackListAPAsset(assetPath));
                        }
                    }
                }

                var id    = AssetDatabase.AssetPathToGUID(assetPath);
                var asset = APCache.GetValue(AssetDatabase.AssetPathToGUID(assetPath));
                if (asset != null)
                {
                    APCache.Remove(id);
                    APCache.RemoveFromBlacklist(assetPath);
                    SyncManager.DeleteAssets.Enqueue(asset);
                    SyncManager.DeleteAssets.Enqueue(APResources.GetBlackListAPAsset(assetPath));
                }
            }
        }
Beispiel #2
0
        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);
                }
            }
        }