Exemplo n.º 1
0
        public GoogleDriveResourceLoader(IResourceProvider provider, string rootPath, string resourcePath,
                                         IRawConverter <TResource> converter, Action <string> logAction) : base(provider, resourcePath)
        {
            RootPath          = rootPath;
            useNativeRequests = nativeRequestTypes.Contains(typeof(TResource));
            this.logAction    = logAction;

            // MP3 is not supported in native requests on the standalone platforms. Fallback to raw converters.
            #if UNITY_STANDALONE || UNITY_EDITOR
            foreach (var r in converter.Representations)
            {
                if (WebUtils.EvaluateAudioTypeFromMime(r.MimeType) == AudioType.MPEG)
                {
                    useNativeRequests = false;
                }
            }
            #endif

            this.converter     = converter;
            usedRepresentation = new RawDataRepresentation();
        }
Exemplo n.º 2
0
        private async UniTask <UnityGoogleDrive.Data.File> GetFileMetaAsync(string filePath)
        {
            foreach (var representation in converter.Representations)
            {
                var fullPath = string.Concat(filePath, representation.Extension);
                var files    = await Helpers.FindFilesByPathAsync(fullPath, fields : new List <string> {
                    "files(id, mimeType, modifiedTime)"
                }, mime : representation.MimeType);

                if (files.Count > 1)
                {
                    Debug.LogWarning($"Multiple '{fullPath}' files been found in Google Drive.");
                }
                if (files.Count > 0)
                {
                    usedRepresentation = representation; return(files[0]);
                }
            }

            throw new Exception($"Failed to retrieve '{Path}' resource from Google Drive.");
        }