예제 #1
0
        void OnInit(AssetRequest request)
        {
            if (!string.IsNullOrEmpty(request.error))
            {
                LoadVersions(string.Empty);
                return;
            }
            var path = Assets.GetRelativeUpdatePath(versionsTxt);

            if (!File.Exists(path))
            {
                var asset = Assets.LoadAssetAsync(Assets.GetAssetBundleDataPathURL(versionsTxt), typeof(TextAsset));
                asset.completed += delegate
                {
                    if (asset.error != null)
                    {
                        LoadVersions(string.Empty);
                        return;
                    }
                    var dir = Path.GetDirectoryName(path);
                    if (!Directory.Exists(dir))
                    {
                        Directory.CreateDirectory(dir);
                    }
                    File.WriteAllText(path, asset.text);
                    LoadVersions(asset.text);
                    asset.Release();
                };
            }
            else
            {
                LoadVersions(File.ReadAllText(path));
            }
        }