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













0















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










share|improve this question






















  • 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















0















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










share|improve this question






















  • 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













0












0








0








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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












2 Answers
2






active

oldest

votes


















1














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






share|improve this answer






























    0














    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.






    share|improve this answer






















      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
      );



      );













      draft saved

      draft discarded


















      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









      1














      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






      share|improve this answer



























        1














        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






        share|improve this answer

























          1












          1








          1







          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






          share|improve this answer













          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







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 11:47









          Kieran DevlinKieran Devlin

          639418




          639418























              0














              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.






              share|improve this answer



























                0














                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.






                share|improve this answer

























                  0












                  0








                  0







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 8 at 11:41









                  rob5300rob5300

                  936




                  936



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                      2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

                      Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme