Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by siddharth3322 · Jul 21, 2016 at 10:25 AM · androidassetsfileapplicationdatapath

Path for Assets/Textures folder File in Android

I want path for pngs exist in Assets/Textures folder for Android platform. I don't know this thing is possible or not, if not possible then what is other way exist for getting path for png files. I want to use that actual png files for other purpose.

I have one reference Application.dataPath but this variable behaving different way in Android platform as per my thinking.

Please suggest me preferred way to do this.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by _Yash_ · Jul 21, 2016 at 11:43 AM

Everything inside Assets folder is packed in binary after build. It does not exist at any path, but if you want to access the png you can place this inside Resources folder and load it at runtime using Resources.Load and then use it.

or

change extention of png file to .byte and read it at runtime like this.

         public TextAsset imageTA; // you can load it with Resources.Load<TextAsset>       
         Texture2D tex = new Texture2D(4, 4);
         tex.LoadImage(imageTA.bytes);
         GetComponent<Renderer>().material.mainTexture = tex;
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image siddharth3322 · Jul 21, 2016 at 11:50 AM 0
Share

What if I need path of png file in string?? How can I get actual path of data exist in Resources folder??

avatar image _Yash_ siddharth3322 · Jul 21, 2016 at 12:28 PM 0
Share

As I said, there is no path for assets, everything is serialized and stored. Resources folders are used when you have lots of assets( 1000 images for example ) and don't want to load all of them when unity start. This way this png file is not loaded when unity starts and you can still access it.

why .byte?

if you opt for .txt unity will try to convert bytes to UTF characters and might corrupt the original image bytes. When you use .byte everything will be intact and you can have your real image inside unity. but if you still want path to folder, sorry it does not exist.

if you want to save data for your app use Application.persistentDataPath

avatar image siddharth3322 _Yash_ · Jul 21, 2016 at 01:02 PM 0
Share

@Yash really thanks for your reply. I have around 80 images and I want to share selected image via common sharing feature. So what way I need to adopt as per your thinking??

Show more comments
avatar image
0

Answer by Naphier · Jul 25, 2016 at 08:22 AM

If you plan to distribute these files with your build then use StreamingAssets. You will need to load them via the WWW class on Android, but can use System.IO on desktop. I believe WWW will work in the editor for this purpose too. StreamingAssets will not convert, pack, or change the file in any way.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

82 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Difference between Application.persistantDataPath Vs Application.dataPath 2 Answers

build file with one game and two game can access it 0 Answers

File paths on Android 0 Answers

How do I find a folder I can write data to on Android? 3 Answers

Access Unity assets natively on Android and iPhone? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges