Wanzyee Studio

Download file when double click this asset. More...

Inherits ScriptableObject.

Public Member Functions

void Download ()
 According to the settings to download the file with displaying the progress bar. More...
 

Public Attributes

bool sync
 Block the main thread while downloading. More...
 
string url = "https://"
 The remote URL to download from. More...
 
string[] args = {}
 The arguments of the url, if which is a composite format string. More...
 
string file = "Assets/"
 The local file path to save to. More...
 
bool overwrite
 Overwrite silently or show a confirm dialog if the file existed. More...
 
bool reveal
 Reveal the file after done. More...
 
bool open
 Open the file after done. More...
 

Detailed Description

Download file when double click this asset.

The causes of this are:

  1. Many of our game data tables, e.g., languages, are edited in Google Sheet and downloaded to csv assets.
  2. Now, I'd like to download all the csv with one click.
  3. The solution comes to us below.

Make each downloader asset with:

  1. The url format "https://docs.google.com/spreadsheets/d/{0}/export?gid={1}&format=csv".
  2. And fill the args with specified document id and gid.
  3. Check out the other options, finally click to download.

Then further more to speed up:

  1. Use the Shortcut package to assist development.
  2. Type "AssetDatabase.OpenAsset(objects);" to a new CodeExecutor.codeSnippet.
  3. Drag the downloaders to the executor, click and all done.

Refer to this page, the URL format to download from Google Sheet: "https://docs.google.com/spreadsheets/d/LONG_ID_STRING/export?gid=GID&format=csv"

Member Function Documentation

void Download ( )

According to the settings to download the file with displaying the progress bar.

Member Data Documentation

bool sync

Block the main thread while downloading.

It looks no difference when download one file at a time, since the progress bar shown. But blocking may be better when batch downloading by turns. Note, not to set sync if the url might be redirected, otherwise the process may be blocked.

string url = "https://"

The remote URL to download from.

It should also be able to copy a file from a local path.

string [] args = {}

The arguments of the url, if which is a composite format string.

string file = "Assets/"

The local file path to save to.

bool overwrite

Overwrite silently or show a confirm dialog if the file existed.

bool reveal

Reveal the file after done.

bool open

Open the file after done.