Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 3
0
        private static void HandleMovedAssets(string[] movedAssets, string[] movedFromAssetPaths)
        {
            for (var i = 0; i < movedAssets.Length; i++)
            {
                Utility.DebugLog(string.Format("moved {0} to {1}", movedFromAssetPaths[i], movedAssets[i]));
                var sid = AssetDatabase.AssetPathToGUID(movedAssets[i]);
                if (Utility.IsModelPath(movedAssets[i]))
                {
                    var clipIds = APResources.GetAnimationClipAssetIdInModel(movedAssets[i]);
                    foreach (var id in clipIds)
                    {
                        APCache.MoveTo(sid, movedAssets[i]);
                        var clip = APCache.GetValue(APAssetType.AnimationClip, id);
                        SyncManager.MovedFromAssets.Enqueue(id);
                        SyncManager.MovedToAssets.Enqueue(clip);
                    }
                }

                APCache.MoveTo(sid, movedAssets[i]);
                var asset = APCache.GetValue(sid);
                SyncManager.MovedFromAssets.Enqueue(sid);
                SyncManager.MovedToAssets.Enqueue(asset);
            }
        }