What is the difference between Application.streamingAssetsPath and Application.persistentDataPath?How are...
I have doubt regarding certain concepts between these two.For Application.streamingAssetsPath,I should create a StreamingAssets folder in my project,so that I can save files to it and later reload it.So what is the role of Application.persistentDataPath and the role of Application.streamingAssetsPath?
If I have assets and data(Position,health etc) to be saved and later reload them in mobile devices(Android and IOS) and PC.Which is the best option?
Below I save using Application.streamingAssetsPath
using (FileStream fs = new FileStream(Application.streamingAssetsPath + "/Position.json", FileMode.Create))
{
BinaryWriter filewriter = new BinaryWriter(fs);
filewriter.Write(JsonString);
fs.Close();
}
c# unity3d
|
show 1 more comment
I have doubt regarding certain concepts between these two.For Application.streamingAssetsPath,I should create a StreamingAssets folder in my project,so that I can save files to it and later reload it.So what is the role of Application.persistentDataPath and the role of Application.streamingAssetsPath?
If I have assets and data(Position,health etc) to be saved and later reload them in mobile devices(Android and IOS) and PC.Which is the best option?
Below I save using Application.streamingAssetsPath
using (FileStream fs = new FileStream(Application.streamingAssetsPath + "/Position.json", FileMode.Create))
{
BinaryWriter filewriter = new BinaryWriter(fs);
filewriter.Write(JsonString);
fs.Close();
}
c# unity3d
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09
|
show 1 more comment
I have doubt regarding certain concepts between these two.For Application.streamingAssetsPath,I should create a StreamingAssets folder in my project,so that I can save files to it and later reload it.So what is the role of Application.persistentDataPath and the role of Application.streamingAssetsPath?
If I have assets and data(Position,health etc) to be saved and later reload them in mobile devices(Android and IOS) and PC.Which is the best option?
Below I save using Application.streamingAssetsPath
using (FileStream fs = new FileStream(Application.streamingAssetsPath + "/Position.json", FileMode.Create))
{
BinaryWriter filewriter = new BinaryWriter(fs);
filewriter.Write(JsonString);
fs.Close();
}
c# unity3d
I have doubt regarding certain concepts between these two.For Application.streamingAssetsPath,I should create a StreamingAssets folder in my project,so that I can save files to it and later reload it.So what is the role of Application.persistentDataPath and the role of Application.streamingAssetsPath?
If I have assets and data(Position,health etc) to be saved and later reload them in mobile devices(Android and IOS) and PC.Which is the best option?
Below I save using Application.streamingAssetsPath
using (FileStream fs = new FileStream(Application.streamingAssetsPath + "/Position.json", FileMode.Create))
{
BinaryWriter filewriter = new BinaryWriter(fs);
filewriter.Write(JsonString);
fs.Close();
}
c# unity3d
c# unity3d
edited Jan 2 at 11:07
zyonneo
asked Dec 31 '18 at 8:21
zyonneozyonneo
4082720
4082720
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09
|
show 1 more comment
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09
|
show 1 more comment
1 Answer
1
active
oldest
votes
Generally, use Application.persistentDataPath
for data that was not available during build time and will be modified after being distributed (and should never be modified by a game update), and use Application.streamingAssetsPath
for game data that exists before your build that you want to be able to read with IO systems during the game (and might be modified in a game update). For example, player save data likely should be placed in Application.persistentDataPath
and dialogue files might be placed in Application.streamingAssetsPath
.
The biggest technical difference is that usually Application.persistentDataPath
can be saved in a location separate from the game data, so that an uninstall or update of the game will not cause a player to lose their data. Most of the difference is in intent, in that Application.persistentDataPath
is intended for saving data between runs of a game, and Application.streamingAssetsPath
is intended to allow developers to have game files that can be accessed by path name.
If you are storing the current position, current health, and current status of a character that you are keeping track of, you will want Application.persistentDataPath
. If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath
would be a better pick.
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it inpersitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985176%2fwhat-is-the-difference-between-application-streamingassetspath-and-application-p%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally, use Application.persistentDataPath
for data that was not available during build time and will be modified after being distributed (and should never be modified by a game update), and use Application.streamingAssetsPath
for game data that exists before your build that you want to be able to read with IO systems during the game (and might be modified in a game update). For example, player save data likely should be placed in Application.persistentDataPath
and dialogue files might be placed in Application.streamingAssetsPath
.
The biggest technical difference is that usually Application.persistentDataPath
can be saved in a location separate from the game data, so that an uninstall or update of the game will not cause a player to lose their data. Most of the difference is in intent, in that Application.persistentDataPath
is intended for saving data between runs of a game, and Application.streamingAssetsPath
is intended to allow developers to have game files that can be accessed by path name.
If you are storing the current position, current health, and current status of a character that you are keeping track of, you will want Application.persistentDataPath
. If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath
would be a better pick.
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it inpersitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
add a comment |
Generally, use Application.persistentDataPath
for data that was not available during build time and will be modified after being distributed (and should never be modified by a game update), and use Application.streamingAssetsPath
for game data that exists before your build that you want to be able to read with IO systems during the game (and might be modified in a game update). For example, player save data likely should be placed in Application.persistentDataPath
and dialogue files might be placed in Application.streamingAssetsPath
.
The biggest technical difference is that usually Application.persistentDataPath
can be saved in a location separate from the game data, so that an uninstall or update of the game will not cause a player to lose their data. Most of the difference is in intent, in that Application.persistentDataPath
is intended for saving data between runs of a game, and Application.streamingAssetsPath
is intended to allow developers to have game files that can be accessed by path name.
If you are storing the current position, current health, and current status of a character that you are keeping track of, you will want Application.persistentDataPath
. If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath
would be a better pick.
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it inpersitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
add a comment |
Generally, use Application.persistentDataPath
for data that was not available during build time and will be modified after being distributed (and should never be modified by a game update), and use Application.streamingAssetsPath
for game data that exists before your build that you want to be able to read with IO systems during the game (and might be modified in a game update). For example, player save data likely should be placed in Application.persistentDataPath
and dialogue files might be placed in Application.streamingAssetsPath
.
The biggest technical difference is that usually Application.persistentDataPath
can be saved in a location separate from the game data, so that an uninstall or update of the game will not cause a player to lose their data. Most of the difference is in intent, in that Application.persistentDataPath
is intended for saving data between runs of a game, and Application.streamingAssetsPath
is intended to allow developers to have game files that can be accessed by path name.
If you are storing the current position, current health, and current status of a character that you are keeping track of, you will want Application.persistentDataPath
. If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath
would be a better pick.
Generally, use Application.persistentDataPath
for data that was not available during build time and will be modified after being distributed (and should never be modified by a game update), and use Application.streamingAssetsPath
for game data that exists before your build that you want to be able to read with IO systems during the game (and might be modified in a game update). For example, player save data likely should be placed in Application.persistentDataPath
and dialogue files might be placed in Application.streamingAssetsPath
.
The biggest technical difference is that usually Application.persistentDataPath
can be saved in a location separate from the game data, so that an uninstall or update of the game will not cause a player to lose their data. Most of the difference is in intent, in that Application.persistentDataPath
is intended for saving data between runs of a game, and Application.streamingAssetsPath
is intended to allow developers to have game files that can be accessed by path name.
If you are storing the current position, current health, and current status of a character that you are keeping track of, you will want Application.persistentDataPath
. If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath
would be a better pick.
edited Dec 31 '18 at 22:58
answered Dec 31 '18 at 22:46
adisibadisib
1086
1086
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it inpersitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
add a comment |
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it inpersitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it in persitentDataPath
– derHugo
Jan 2 at 8:28
If you are storing the data for the starting position, maximum health, and other stats of a character that you will use for initialization, Application.streamingAssetsPath would be a better pick.
you would do this rather in the classes directly .. no need to store those in a Textfile ... and you only would save it there if you don't want to be able to change them later .. then you would again rather place it in persitentDataPath
– derHugo
Jan 2 at 8:28
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
That may be true, but the question seemed to imply that they wanted it to be in a separate file for whatever reason. I try to take on the implied context rather than assume my own. For example, they could have an external program generating character data, in which case they would want it generating files, rather than code.
– adisib
Jan 2 at 20:09
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53985176%2fwhat-is-the-difference-between-application-streamingassetspath-and-application-p%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
StreamingAssets are built into the apk/ipa and the files cannot be modified. You also have to take extra care on Android to avoid having them compressed because they are very slow to load that way. The PersistentDataPath is where any files you save on the device are stored. You can add/delete/change files here, and on iOS these files are saved to iCloud backups if you don't flag them to not be backed up.
– Retired Ninja
Dec 31 '18 at 8:28
@RetiredNinja For IOS and Android the paths are different.I have to write two paths in my code .eg -if #UNITY_IOS Application.persistentDatapath and if #UNITY_ANDROID Application.persistentDatapath.
– zyonneo
Dec 31 '18 at 8:46
Not sure what you're saying. Yes, the contents of persistentDataPath are different on different platforms, but Unity handles that, there's nothing you need to do about it.
– Retired Ninja
Dec 31 '18 at 9:06
@RetiredNinja I mean if i want my game to work both in android and IOS ...and save games in both versions.what should I do
– zyonneo
Dec 31 '18 at 9:09
In short: use persistentDataPath if you need access to the files from outside the App (e.g. for changing settings in in an XML file via Texteditor etc). You can read in the docs where to find that persistentDataPath on the device for different plattforms. If you don't need that external access you can just go for streamingAssets. Unity handles the paths on all platforms so the code stays the same for both Android and iOs .. that's the whole idea of using Unity ;)
– derHugo
Dec 31 '18 at 11:09