Example #1
0
        // Populate metadata from the JSON returned by Poly for a single asset
        // See go/vr-assets-service-api
        public PolySceneFileInfo(JToken json)
        {
            m_AssetId   = json["name"].ToString().Substring(7); // strip 'assets/' from start
            m_HumanName = json["displayName"].ToString();

            var format = json["formats"].First(x => x["formatType"].ToString() == "TILT")["root"];

            m_TiltFileUrl = format["url"].ToString();
            m_IconUrl     = json["thumbnail"]?["url"]?.ToString();
            m_License     = json["license"]?.ToString();


            // Some assets (old ones? broken ones?) are missing the "formatComplexity" field
            var    gltfFormat   = json["formats"].First(x => x["formatType"].ToString() == "GLTF");
            string gltfTriCount = gltfFormat?["formatComplexity"]?["triangleCount"]?.ToString();

            if (gltfTriCount == null)
            {
                Debug.Log($"{m_AssetId} has no tricount");
            }
            m_GltfTriangleCount = Int32.Parse(gltfTriCount ?? "1");

            m_DownloadedFile = null;
            m_IconDownloaded = false;
        }
Example #2
0
 public async Task DownloadAsync(CancellationToken token)
 {
     Directory.CreateDirectory(CachePath);
     using (m_DownloadStream = new FileStream(m_FileName, FileMode.Create)) {
         try {
             await Retry(() => App.DriveAccess.DownloadFileAsync(m_File, m_DownloadStream, token));
         } catch (OperationCanceledException) {
             m_DownloadStream.Close();
             File.Delete(m_FileName);
         } finally {
             m_DownloadStream = null;
         }
     }
     File.SetLastWriteTime(m_FileName, m_File.ModifiedTime.Value);
     m_TiltFile = new TiltFile(m_FileName);
 }
Example #3
0
            public GoogleDriveFileInfo(DriveData.File file, string source)
            {
                m_File     = file;
                m_FileName = Path.Combine(CachePath, m_File.Id + ".tilt");
                if (File.Exists(m_FileName))
                {
                    var fileInfo = new FileInfo(m_FileName);
                    if (DriveAccess.IsNewer(m_File, fileInfo))
                    {
                        File.Delete(m_FileName);
                    }
                    else
                    {
                        m_TiltFile = new TiltFile(m_FileName);
                    }
                }

                m_Source = source;
            }
 public DiskSceneFileInfo(string path, bool embedded = false, bool readOnly = false)
 {
     Debug.Assert(embedded == false || readOnly == true); // if embedded, should always be readonly.
     m_embedded = embedded;
     if (m_embedded)
     {
         m_fullpath  = path;
         m_TiltFile  = null;
         m_humanName = kInvalidHumanName;
     }
     else
     {
         m_fullpath  = Path.GetFullPath(path);
         m_TiltFile  = new TiltFile(m_fullpath);
         m_humanName = Path.GetFileNameWithoutExtension(SaveLoadScript.RemoveMd5Suffix(m_fullpath));
     }
     m_AssetId      = null;
     m_SourceId     = null;
     m_readOnly     = readOnly;
     m_creationTime = null;
 }