Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Evola · Mar 04, 2013 at 05:23 PM · resources.load

Resource.Load outside the editor

Hello, I have been reading a lot about Resource.Load() but I still have an error when I deploy the app in my Nexus7. I'm trying to play 60 .png images, sequentially with this code:

 dirInfo = new DirectoryInfo(resPath);
             secTam = dirInfo.GetFiles().Length;
             conSec = new Texture2D[secTam];
             
             for(int i = 0; i < conSec.Length; i++){
                 if(i < 10){
                 conSec[i] = Resources.Load("Secuencias/Conejo/Comp 1_1_0000" + i, typeof(Texture2D)) as Texture2D;
                 }else if(i < 100){
                     conSec[i] = Resources.Load("Secuencias/Conejo/Comp 1_1_000" + i, typeof(Texture2D)) as Texture2D;
                 }
             }
     
     ...
     
     
     IEnumerator PlaySec(){
             playing = true;
             for(int i = 0; i < conSec.Length; i++){
                 conMat.SetTexture("_MainTex", conSec[i]);
                 yield return new WaitForSeconds(repTime);
             }
             if(replay){
                 StopCoroutine("PaySec");
                 StartCoroutine("PlaySec");
             }else {
                 playing = false;
             }
         }


I have created a folder called "Resources/Secuencias/Conejo" inside the assets folder where i have put my Images with the name "Comp 1_1_000xx".(xx[00,65])

This code is working in the editor!! I have a OnGUI.Box telling me the length of the Texture2D array conSec[]. When I use the editor the length is 65 but when I deploy the app in the Nexus the length is 0.

What I'm doing wrong?

Thanks to all!!

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 Bunny83 · Mar 04, 2013 at 07:08 PM

This doesn't work:

 dirInfo = new DirectoryInfo(resPath);
 secTam = dirInfo.GetFiles().Length;
 conSec = new Texture2D[secTam];

because this code directly accesses the resources folder in your project directory. When you build a game the assets are packed into your game, in your case inside the APK file. You can't access them via the filesystem. The only way is to use Resources.Load and you have to use fix assetnames. The content in resources folder is fix and can't change once you created a build. There's no way i know to determine what assets are in a resource folder.

Comment
Add comment · Show 1 · 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 Evola · Mar 04, 2013 at 07:18 PM 0
Share

Yes!! You are right, that was the problem. Using an integer for the length of the images array the problem is fixed. Thanks!!

avatar image
0

Answer by selzero · Mar 04, 2013 at 06:10 PM

try to simplify the example, can you load just one picture from the resources folder (no subfolders)

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

12 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

Related Questions

Loading Resources in a Native Plugin 0 Answers

resources.load material JavaScript 1 Answer

How does Resources.Load work internally 1 Answer

Can you load images from outside the resources folder? 1 Answer

Resources.Load without a Resources folder? 1 Answer


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