跳到主要內容

Unity 路徑變數

Application.dataPath

  • 指向遊戲檔案路徑
  • 會依據平台不同
    • Unity Editor: <path to project folder>/Assets
    • Mac player: <path to player app bundle>/Contents
    • iOS player: <path to player app bundle>/<AppName.app>/Data (this folder is read only, use Application.persistentDataPath to save data).
    • Win/Linux player: <path to executablename_Data folder> (note that most Linux installations will be case-sensitive!)
    • WebGL: The absolute url to the player data file folder (without the actual data file name)
    • Android: Normally it points directly to the APK. If you are running a split binary build, it points to the OBB instead.
    • Windows Store Apps: The absolute path to the player data folder (this folder is read only, use Application.persistentDataPath to save data)

Application.consoleLogPath

  • 指向Editor.log路徑

Application.persistentDataPath

  • 指向持久性資料夾,該資料夾可供存放遊戲持久性資料。當程式更新時,資料夾內檔案不會刪除,但使用者可手動刪除。
  • 會依據平台不同
    • Windows Store Apps: %userprofile%\AppData\Local\Packages\<productname>\LocalState.
    • iOS/var/mobile/Containers/Data/Application/<guid>/Documents.
    • Android/storage/emulated/0/Android/data/<packagename>/files on most devices (some older phones might point to location on SD card if present), the path is resolved using android.content.Context.getExternalFilesDir

Application.streamingAssetsPath

  • 指向資源資料夾,該資源資料夾可供存放遊戲資源。
  • 於某些平台不支援直接存取,WebGL、Android,然而在這些平台上路徑會回傳Url,可透過WebRequest取得。

Application.temporaryCachePath

  • 指向快取資料夾,可快取使用。


範例




留言