Unityパスの概要



Summary Unity Path



まず、Unityのパス変数

  1. Application.dataPath
    アプリケーションデータフォルダへのパス、読み取り専用。
  2. Application.streamingAssetsPath
    一部の外部データファイルを保存できる、アプリケーションのストリーミングデータキャッシュディレクトリ。
  3. Application.temporaryCachePath
    デバイスの一時データキャッシュディレクトリ。
  4. Application.persistentDataPath
    iOS / Androidデバイス上の永続的なデータストレージディレクトリ。このパスにいくつかの永続データファイルを保存できます。このディレクトリ内のファイルは、アプリのアップグレードのために削除されません。

第二に、異なるプラットフォームでのパス

|パス変数| Windows | Android | iOS |
| :------------ | :---------------- | :------------ | :---------- | :---------- |
| Application.dataPath |アプリケーションパス/ appname _Data | / data / app / package name-1 / base.apk | / var / containers / Bundle / Application / app sandbox / xxx。アプリ/データ|
| Application.streamingAssetsPath |アプリケーションパス/ appname _Data / StreamingAssets | jar:file:/// data / app / package name-1 / base.apk!/ assets | / var / containers / Bundle / Application / app sandbox / test.app / Data / Raw |
| Application.temporaryCachePath | C: Users username AppData Local Temp company name product name | 内部のみ: / data / user / 0 /パッケージ名/キャッシュ 外部(SDカード): / storage / emulated / 0 / Android / data / package name / cache | / var / mobile / Containers / Data / Application / app sandbox / Library / Caches |
| Application.persistentDataPath | C: Users username AppData LocalLow company name product name | 内部のみ: / data / user / 0 /パッケージ名/ファイル 外部(SDカード): / storage / emulated / 0 / Android / data / package name / files | / var / mobile / Containers / Data / Application / app sandbox / Documents |

注:Androidプラットフォームでのパスは、SDカードのアクセス権によって異なります。 iOSに関しては、同様の状況はありません。関連機器がないため、当面のテストはありません。条件付きの友達がテストを手伝ってくれます。Unity5.3.4f1で簡単なテストプログラムを作成しました。プロジェクトリンク: http://pan.baidu.com/s/1gfqmORh 。テストフィードバックへようこそ、感謝します!



第三に、一般的なツールと方法

/// /// Get the streaming load path of different platforms /// /// filename /// public static string GetStreamingFilePath(string filename) { string path = '' if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer) { path = Application.dataPath + '/StreamingAssets/' + filename } else if (Application.platform == RuntimePlatform.IPhonePlayer) { path = Application.dataPath + '/Raw/' + filename } else if (Application.platform == RuntimePlatform.Android) { path = 'jar:file://' + Application.dataPath + '!/assets/' + filename } else { path = Application.dataPath + '/config/' + filename } return path } /// /// Get persistent data storage paths for different platforms /// /// filename /// public static string GetPersistentFilePath(string filename) { string filepath = Application.persistentDataPath + '/' + filename #if UNITY_IPHONE // Set file flag to be excluded from iCloud/iTunes backup. UnityEngine.iOS.Device.SetNoBackupFlag(filepath) #endif return filepath }

第四に、参照

  1. Unity3DプラットフォームのパスApplication.xxxPath
  2. Unity3Dモバイルプラットフォームは、フル解像度の外部ファイルを動的に読み取ります
  3. Unityのさまざまなパス
  4. Unityの公式ドキュメント

著者: Sheh Weiwei
この記事のリンク: Http://davidsheh.github.io/2017/02/09/Unityパス関連の概要/
著作権表示: このブログのすべての記事は、特別なステートメントを除いて使用されます。 CC BY-NC-SA 3.0 契約。ソースを教えてください!