Exemple #1
0
        private void DownloadConfig()
        {
            string path = $"https://{Application.cloudProjectId}.client-api.unity3dusercontent.com/client_api/v1";

            _settings = Resources.Load <CloudContentSettings>("CloudContentSettings");

            var c = new ContentApi(path);
            var e = new EntriesApi(path);
            var r = new ReleasesApi(path);

            var entry = e.GetEntryByPathPublic(_settings.lastBucketData.bucketId, "config.json");

            if (entry != null)
            {
                string bid = _settings.lastBucketData.bucketId;
                var    rid = r.GetReleaseByBadgePublic(bid, "latest");

                Stream stream = c.GetReleaseContentPublic(bid, rid.Releaseid.ToString(), entry.Entryid.ToString());

                var ms = new MemoryStream();
                stream.CopyTo(ms);

                string rawString = Encoding.ASCII.GetString(ms.ToArray());

                var sb = new StringBuilder(rawString.Length);

                foreach (char i in rawString)
                {
                    if (i != '\n' && i != '\r' && i != '\t')
                    {
                        sb.Append(i);
                    }
                }

                rawString = sb.ToString();
                rawString = Regex.Replace(rawString, @"\s+", "");

                _data = deserializeToDictionary(rawString);
            }
        }