예제 #1
0
        public void GetPreviews(string projectPath, string[] folderPath, StorageEventHandler <Preview[][]> callback)
        {
            projectPath = AssetsFolderPath(projectPath);

            ISerializer serializer = RTSL2Deps.Get.Serializer;

            Preview[][] result = new Preview[folderPath.Length][];
            for (int i = 0; i < folderPath.Length; ++i)
            {
                string path = Path.Combine(projectPath, folderPath[i]);
                if (!Directory.Exists(path))
                {
                    continue;
                }

                string[]  files    = Directory.GetFiles(path, "*" + PreviewExt);
                Preview[] previews = new Preview[files.Length];
                for (int j = 0; j < files.Length; ++j)
                {
                    previews[j] = Load <Preview>(serializer, files[j]);
                }

                result[i] = previews;
            }

            callback(new Error(), result);
        }
예제 #2
0
        private void OnGetPreviewsCompleted(ProjectItem[] folders, ProjectAsyncOperation <ProjectItem[]> ao, ProjectEventHandler <ProjectItem[]> callback, Error error, Preview[][] result)
        {
            for (int i = 0; i < result.Length; ++i)
            {
                ProjectItem folder   = folders[i];
                Preview[]   previews = result[i];
                if (previews != null && previews.Length > 0)
                {
                    for (int j = 0; j < previews.Length; ++j)
                    {
                        Preview   preview = previews[j];
                        AssetItem assetItem;

                        if (m_idToAssetItem.TryGetValue(preview.ItemID, out assetItem))
                        {
                            if (assetItem.Parent == null)
                            {
                                Debug.LogErrorFormat("asset item {0} parent is null", assetItem.ToString());
                                continue;
                            }

                            if (assetItem.Parent.ItemID != folder.ItemID)
                            {
                                Debug.LogErrorFormat("asset item {0} with wrong parent selected. Expected parent {1}. Actual parent {2}", folder.ToString(), assetItem.Parent.ToString());
                                continue;
                            }

                            assetItem.Preview = preview;
                        }
                        else
                        {
                            Debug.LogWarningFormat("AssetItem with ItemID {0} does not exists", preview.ItemID);
                        }
                    }
                }
            }

            ProjectItem[] projectItems = folders.Where(f => f.Children != null).SelectMany(f => f.Children).ToArray();
            if (callback != null)
            {
                callback(error, projectItems);
            }

            ao.Error       = error;
            ao.Result      = projectItems;
            ao.IsCompleted = true;
        }