Exemplo n.º 1
0
        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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void AddNewImportAssets(string assetPath)
        {
            Utility.DebugLog(string.Format("New: {0}", assetPath));

            if (!File.Exists(assetPath) && Directory.Exists(assetPath))
            {
                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 MovieTexture)
                {
                    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);
                }
            }

            if (asset != null)
            {
                SyncManager.AddedAssets.Enqueue(asset);
            }

            Resources.UnloadUnusedAssets();
        }
Exemplo n.º 3
0
        private static void UpdateReimportExistAssets(string assetPath)
        {
            Utility.DebugLog(string.Format("Update: {0}", assetPath));

            var guid = AssetDatabase.AssetPathToGUID(assetPath);

            UnityEngine.Object obj = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));

            if (obj is MovieTexture)
            {
                webCommunicationService.UpdateObjectsIntoCache(APAssetType.MovieTexture, guid, SyncManager.ModifiedAssets);
            }
            else if (obj is Texture)
            {
                webCommunicationService.UpdateObjectsIntoCache(APAssetType.Texture, guid, SyncManager.ModifiedAssets);
            }

            APResources.UnloadAsset(obj);
        }
Exemplo n.º 4
0
        private UnityEngine.Object GetAnimationObjectFromModel(string assetid)
        {
            string guid   = Utility.GetGuidFromAssetId(assetid);
            string fileId = Utility.GetFileIdFromAssetId(assetid);

            Utility.DebugLog(string.Format("Find Animation in {0} with id {1}", guid, fileId));

            if (string.IsNullOrEmpty(guid) || string.IsNullOrEmpty(fileId))
            {
                return(null);
            }

            var objects = AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GUIDToAssetPath(guid));

            Utility.DebugLog(string.Format("Get {0} items in {1}", objects.Length, assetid));

            foreach (var obj in objects)
            {
                if (obj is AnimationClip && Utility.GetLocalIndentifierOfObject(obj).ToString() == fileId)
                {
                    // Release loaded objects
                    //
                    foreach (var item in objects)
                    {
                        if (obj != item)
                        {
                            APResources.UnloadAsset(item);
                        }
                    }

                    return(obj);
                }
            }

            foreach (var item in objects)
            {
                APResources.UnloadAsset(item);
            }

            return(null);
        }