Extract image from local folder through json in UnityWhy can't Python parse this JSON data?Returning JSON from a PHP ScriptHow do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Calculate MD5 checksum for a fileDownload JSON object as a file from browserBig Query table to be extracted as JSON in Local machineDoes Unity need system images in the SDK folder?Serialize and Deserialize Json and Json Array in UnityUnity webview loading webpage locally/by storing cacheParse JSON url image into Scrollview - Unity
I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?
Why are there no referendums in the US?
Different result between scanning in Epson's "color negative film" mode and scanning in positive -> invert curve in post?
CREATE opcode: what does it really do?
How does Loki do this?
What can we do to stop prior company from asking us questions?
Risk of infection at the gym?
What Brexit proposals are on the table in the indicative votes on the 27th of March 2019?
For a non-Jew, is there a punishment for not observing the 7 Noahide Laws?
How to Reset Passwords on Multiple Websites Easily?
Fine Tuning of the Universe
Roman Numeral Treatment of Suspensions
Avoiding estate tax by giving multiple gifts
Closest Prime Number
Increase performance creating Mandelbrot set in python
Purchasing a ticket for someone else in another country?
How to be diplomatic in refusing to write code that breaches the privacy of our users
How can I get through very long and very dry, but also very useful technical documents when learning a new tool?
Sort a list by elements of another list
What is paid subscription needed for in Mortal Kombat 11?
Is there a problem with hiding "forgot password" until it's needed?
How easy is it to start Magic from scratch?
How to check is there any negative term in a large list?
Class Action - which options I have?
Extract image from local folder through json in Unity
Why can't Python parse this JSON data?Returning JSON from a PHP ScriptHow do I POST JSON data with Curl from a terminal/commandline to Test Spring REST?Calculate MD5 checksum for a fileDownload JSON object as a file from browserBig Query table to be extracted as JSON in Local machineDoes Unity need system images in the SDK folder?Serialize and Deserialize Json and Json Array in UnityUnity webview loading webpage locally/by storing cacheParse JSON url image into Scrollview - Unity
I am extracting images from a local image present in my system through Json. The Json file is:
"BackgroundImage": [
"C:/Users/SS1/Downloads/images/black_background.jpg",
"C:/Users/SS1/Downloads/images/Clipboard.png"
],
Is it possible to omit "C:/Users/SS1" so Unity only extracts a folder from the system irrespective of which computer it is?
Thanks,
Saif
c# json unity3d
add a comment |
I am extracting images from a local image present in my system through Json. The Json file is:
"BackgroundImage": [
"C:/Users/SS1/Downloads/images/black_background.jpg",
"C:/Users/SS1/Downloads/images/Clipboard.png"
],
Is it possible to omit "C:/Users/SS1" so Unity only extracts a folder from the system irrespective of which computer it is?
Thanks,
Saif
c# json unity3d
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47
add a comment |
I am extracting images from a local image present in my system through Json. The Json file is:
"BackgroundImage": [
"C:/Users/SS1/Downloads/images/black_background.jpg",
"C:/Users/SS1/Downloads/images/Clipboard.png"
],
Is it possible to omit "C:/Users/SS1" so Unity only extracts a folder from the system irrespective of which computer it is?
Thanks,
Saif
c# json unity3d
I am extracting images from a local image present in my system through Json. The Json file is:
"BackgroundImage": [
"C:/Users/SS1/Downloads/images/black_background.jpg",
"C:/Users/SS1/Downloads/images/Clipboard.png"
],
Is it possible to omit "C:/Users/SS1" so Unity only extracts a folder from the system irrespective of which computer it is?
Thanks,
Saif
c# json unity3d
c# json unity3d
asked Mar 8 at 11:17
saifsaif
31
31
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47
add a comment |
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47
add a comment |
2 Answers
2
active
oldest
votes
Directory.GetFiles()
takes in a relative or a an absolute path. Just put a relative path from the root of the project and then pass it into the relative methods. Alternatively you could just store the file name in the JSON file and then use the application execution path to find the folder using AppDomain.CurrentDomain.BaseDirectory
.
e.g
var fileNames = getFileNamesFromJsonData();
foreach(var fileName in fileNames)
var absolutePath = $"AppDomain.CurrentDomain.BaseDirectory/images/fileName";
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?redirectedfrom=MSDN&view=netframework-4.7.2#overloads
add a comment |
You should not have a full path, but a relative path and store the files in/using StreamingAssets. Then you can load the assets from the path from most platforms without having problems. You should not store these files anywhere else but alongside your game build.
You can also use the application data path as well but streaming assets is the recommended method.
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%2f55062126%2fextract-image-from-local-folder-through-json-in-unity%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Directory.GetFiles()
takes in a relative or a an absolute path. Just put a relative path from the root of the project and then pass it into the relative methods. Alternatively you could just store the file name in the JSON file and then use the application execution path to find the folder using AppDomain.CurrentDomain.BaseDirectory
.
e.g
var fileNames = getFileNamesFromJsonData();
foreach(var fileName in fileNames)
var absolutePath = $"AppDomain.CurrentDomain.BaseDirectory/images/fileName";
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?redirectedfrom=MSDN&view=netframework-4.7.2#overloads
add a comment |
Directory.GetFiles()
takes in a relative or a an absolute path. Just put a relative path from the root of the project and then pass it into the relative methods. Alternatively you could just store the file name in the JSON file and then use the application execution path to find the folder using AppDomain.CurrentDomain.BaseDirectory
.
e.g
var fileNames = getFileNamesFromJsonData();
foreach(var fileName in fileNames)
var absolutePath = $"AppDomain.CurrentDomain.BaseDirectory/images/fileName";
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?redirectedfrom=MSDN&view=netframework-4.7.2#overloads
add a comment |
Directory.GetFiles()
takes in a relative or a an absolute path. Just put a relative path from the root of the project and then pass it into the relative methods. Alternatively you could just store the file name in the JSON file and then use the application execution path to find the folder using AppDomain.CurrentDomain.BaseDirectory
.
e.g
var fileNames = getFileNamesFromJsonData();
foreach(var fileName in fileNames)
var absolutePath = $"AppDomain.CurrentDomain.BaseDirectory/images/fileName";
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?redirectedfrom=MSDN&view=netframework-4.7.2#overloads
Directory.GetFiles()
takes in a relative or a an absolute path. Just put a relative path from the root of the project and then pass it into the relative methods. Alternatively you could just store the file name in the JSON file and then use the application execution path to find the folder using AppDomain.CurrentDomain.BaseDirectory
.
e.g
var fileNames = getFileNamesFromJsonData();
foreach(var fileName in fileNames)
var absolutePath = $"AppDomain.CurrentDomain.BaseDirectory/images/fileName";
https://docs.microsoft.com/en-us/dotnet/api/system.io.directory.getfiles?redirectedfrom=MSDN&view=netframework-4.7.2#overloads
answered Mar 8 at 11:47
Kieran DevlinKieran Devlin
639418
639418
add a comment |
add a comment |
You should not have a full path, but a relative path and store the files in/using StreamingAssets. Then you can load the assets from the path from most platforms without having problems. You should not store these files anywhere else but alongside your game build.
You can also use the application data path as well but streaming assets is the recommended method.
add a comment |
You should not have a full path, but a relative path and store the files in/using StreamingAssets. Then you can load the assets from the path from most platforms without having problems. You should not store these files anywhere else but alongside your game build.
You can also use the application data path as well but streaming assets is the recommended method.
add a comment |
You should not have a full path, but a relative path and store the files in/using StreamingAssets. Then you can load the assets from the path from most platforms without having problems. You should not store these files anywhere else but alongside your game build.
You can also use the application data path as well but streaming assets is the recommended method.
You should not have a full path, but a relative path and store the files in/using StreamingAssets. Then you can load the assets from the path from most platforms without having problems. You should not store these files anywhere else but alongside your game build.
You can also use the application data path as well but streaming assets is the recommended method.
answered Mar 8 at 11:41
rob5300rob5300
936
936
add a comment |
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%2f55062126%2fextract-image-from-local-folder-through-json-in-unity%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
its only text, so only store the relative folder link
– BugFinder
Mar 8 at 11:21
It would change if I upload it to my Android phone and other devices. And so I really need JSON to load textures, videos and so on.
– saif
Mar 8 at 11:27
You're missing the point, the json only contains text value of the name of the file, dont send a local full path
– BugFinder
Mar 8 at 11:47