[Game Development]Using Unity Sandbox Folder

There are 3 sandbox folder paths

  1.  Application.streamingAssetsPath
  2.  Application.persistentDataPath
  3.  Application.temporaryCachePath

Introduction to streamingAssetsPath path

Read and write permissions: read only.

Features: When packaging, the files in the StreamingAssets folder will be packed into the package body intact. After installing the package body startup program, you can directly use Application.streamingAssetsPath to access the files inside.

Precautions:

Android can only use WWW to read and determine whether it exists. All System.IO methods are invalid. For example, File.Exists cannot determine whether the file exists, and returns false even if it exists.

Edit mode and IOS mode can use System.IO methods, such as File.Exists, File.Copy, and File.ReadAllLines to read text files

When to use this folder: When building a version package, you need to put the AB package resources into streamingAssetsPath to load and use, or copy the AB package from streamingAssetsPath to persistentDataPath for use .

persistentDataPath persistent data folder

 Read and write permissions: Read and write

Features: The folder is created after the package body is installed, and you can directly use Application.persistentDataPath to access the files inside.

Precautions:

Android can also use the System.IO method. All platforms can read and write this folder without restrictions. What is the difference between streamingAssetsPath and streamingAssetsPath?

What kind of data is put in persistentDataPath? Since streamingAssetsPath does not have write permission, hot update resources can only be placed in persistentDataPath. Hot update resources and version package resources cooperate to determine whether hot update is needed.

temporaryCachePath --Cache directory for temporary data (read-only) Don't care about it yet, don't use it

Android printing sandbox path

streamingAssetsPath:

jar:file:///data/app/包名-1/base.apk!/assets

persistentDataPath:

/storage/emulated/0/Android/data/包名/files

Iphone real machine debugging print sandbox path:

추천

출처blog.csdn.net/liuyongjie1992/article/details/133646620