Created
June 3, 2023 10:05
-
-
Save Denchyaknow/0f4c2a583ab08f836f6e55ae8214c4db to your computer and use it in GitHub Desktop.
Examples of the different types of paths in Unity and their outputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Examples of the different types of paths in Unity and their outputs: | |
Application.dataPath: //This property returns the path to the Assets folder of the project. In the editor, it returns the path to the Assets folder. In a build, it returns the path to the data folder of the build. | |
// Usage | |
Debug.Log(string.Format("Assets path: {0}", Application.dataPath)); | |
// Example output in the editor: "Assets path: C:/MyProject/Assets" | |
// Example output in a Windows build: "Assets path: C:/MyGame/MyGame_Data" | |
Application.persistentDataPath: //This property returns the path to a persistent data directory. This directory is where you can store data that needs to persist between game sessions. The exact location of this directory depends on the platform. | |
Debug.Log(string.Format("Persistent data path: {0}", Application.persistentDataPath)); | |
// Example output on Windows: "Persistent data path: C:/Users/UserName/AppData/LocalLow/CompanyName/ProductName" | |
// Example output on Android: "Persistent data path: /data/data/com.CompanyName.ProductName/files" | |
Application.streamingAssetsPath: //This property returns the path to the StreamingAssets folder of the project. This folder is where you can store assets that need to be accessed directly, such as large audio or video files. | |
Debug.Log(string.Format("StreamingAssets path: {0}", streamingAssetsPath)); | |
// Example output in the editor: "StreamingAssets path: C:/MyProject/Assets/StreamingAssets" | |
// Example output in a Windows build: "StreamingAssets path: C:/MyGame/MyGame_Data/StreamingAssets" | |
_Note that these are just examples and the exact output may vary depending on your project and platform._ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment