コード例 #1
0
 public IEnumerable <AssetModel> List(BundleConfig.BundleTypes type)
 {
     using (var db = DatabaseManager.Open())
     {
         var sql = Sql.Builder.Where("type = @0", BundleConfig.singularOf(type));
         return(db.Query <AssetModel>(sql));
     }
 }
コード例 #2
0
 public int DeleteCategory(BundleConfig.BundleTypes type)
 {
     using (var db = DatabaseManager.Open())
     {
         var sql    = Sql.Builder.Where("type = @0", BundleConfig.singularOf(type));
         int result = db.Delete <AssetModel>(sql);
         return(result);
     }
 }
コード例 #3
0
    public void InitBundles(BundleConfig.BundleTypes type)
    {
        CategoryDropdown     = GetComponentInChildren <Dropdown>();
        CategoryDeleteButton = GetComponentInChildren <Button>();
        CategoryDeleteButton.onClick.AddListener(DeleteOption);

        CategoryType      = type;
        CategoryText.text = CategoryType.ToString();
        RefreshOptions();
    }
コード例 #4
0
        public static string GenerateLocalPath(string assetGuid, BundleConfig.BundleTypes type)
        {
            string directoryPath = Path.Combine(Config.PersistentDataPath, BundleConfig.pluralOf(type));

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            return(Path.Combine(directoryPath, assetGuid));
        }
コード例 #5
0
ファイル: WebUtilities.cs プロジェクト: lgsvl/simulator
        public static string GenerateLocalPath(string assetGuid, BundleConfig.BundleTypes type)
        {
            Assert.IsNotNull(assetGuid, $"{nameof(assetGuid)} must not be null when trying to get LocalPath of ${BundleConfig.singularOf(type)}.");
            string directoryPath = Path.Combine(Config.PersistentDataPath, BundleConfig.pluralOf(type));

            if (!Directory.Exists(directoryPath))
            {
                Directory.CreateDirectory(directoryPath);
            }

            return(Path.Combine(directoryPath, assetGuid));
        }
コード例 #6
0
ファイル: Build.cs プロジェクト: cronos1999/simulator-1
 public BundleData(BundleConfig.BundleTypes type, string path = null)
 {
     bundleType = type;
     bundlePath = path ?? BundleConfig.pluralOf(type);
 }
コード例 #7
0
        public static Task <AssetModel> GetAsset(BundleConfig.BundleTypes type, string assetGuid, string name = null,
                                                 IProgress <Tuple <string, float> > progressCallback          = null)
        {
            Init();
            var assetService = new AssetService();
            var found        = assetService.Get(assetGuid);

            if (found != null)
            {
                if (File.Exists(found.LocalPath))
                {
                    return(Task.FromResult(found));
                }
                else
                {
                    Debug.Log($"removing stale entry from assetService due to missing file: {found.LocalPath}");
                    assetService.Delete(assetGuid);
                }
            }

            var typeString = BundleConfig.singularOf(type);

            if (name == null)
            {
                name = typeString;
            }

            string localPath = WebUtilities.GenerateLocalPath(assetGuid, type);

            Uri uri = new Uri(Config.CloudUrl + "/api/v1/assets/download/bundle/" + assetGuid);

            var progressState = new Tuple <string, float>(name, 0.0f);

            progressCallback?.Report(new Tuple <string, float>(name, 0.0f));
            Debug.Log($"{name} Download at 0%");
            var t = new TaskCompletionSource <AssetModel>();

            downloads.Enqueue(new Download(uri, localPath,
                                           progress =>
            {
                progressCallback?.Report(new Tuple <string, float>(name, progress));
                Debug.Log($"{name} Download at {progress}%");
            },
                                           (success, ex) => {
                if (success)
                {
                    try
                    {
                        var model = new AssetModel()
                        {
                            AssetGuid = assetGuid,
                            Type      = typeString,
                            Name      = name,
                            LocalPath = localPath,
                            DateAdded = DateTime.UtcNow.ToString()
                        };
                        assetService.Add(model);
                        Debug.Log($"{name} Download Complete.");
                        progressCallback?.Report(new Tuple <string, float>(name, 100));
                        t.TrySetResult(model);
                    }
                    catch (Exception e)
                    {
                        t.TrySetException(e);
                    }
                }
                else
                {
                    t.TrySetException(ex);
                }
            }));
            return(t.Task);
        }