Unity3d to read resources within the assets directory on Android phones

Source: Internet
Author: User

Unity3d version (v4.6.3)

Android phone inside the package to read files can only use the way www,

The file protocol is "jar:file://" + Application.datapath + "!/assets/"

1. Must have jar: Start

2, assets before a!

3. Directory path delimiter cannot have \

4, because the reading can only use the way of WWW, it also causes the assets files can not be traversed, if it involves the need to copy the resources to a local directory, you can only write a record file, usually a file name one line, such as:

aaa/bbb/ccc.x

Aaa/bbb/ddd.x

Aaa/eee.m

...

Read the record file read all the characters with File.readalltext, and use split to divide each file name, notice that the split payment is \ r \ n

Or use Environment.NewLine as the split parameter

Or you can avoid the problem of line break by using File.ReadAllLines directly

In general: If a file path is more than a \ n or \ r is difficult to find, and cause the read file error.

Above

Unity3d to read resources within the assets directory on Android phones

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.