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 WildMage · Feb 21, 2018 at 09:31 AM · scriptable objectresources.loadall

Resources.LoadAll stopped working since 2017.2

I used to load some resources using Resources.LoadAll(""). It worked fine from 5.0 to 2017.1 but since 2017.2 the resources are randomly not found.

I did not find a way to understand why sometimes it works and sometimes it does not.

Any idea?

Comment
Add comment · Show 3
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 tormentoarmagedoom · Feb 21, 2018 at 11:53 AM 0
Share

I'm using it with no problem. Can you post your code please?

avatar image WildMage · Feb 21, 2018 at 12:31 PM 0
Share

Thanks for your answer.

Here is what I do:

 ScreenshotConfigAsset[] objs = Resources.LoadAll ("");
 if (objs.Length == 0) {
         string path = "Assets/Resources/ScreenshotWindowConfig.asset";
         Debug.Log ("Creating new config file at " + path);
         m_ConfigAsset = ScriptableObject.CreateInstance<ScreenshotConfigAsset> ();
         AssetDatabase.CreateAsset (m_ConfigAsset, path);                
         AssetDatabase.SaveAssets ();
         AssetDatabase.Refresh ();
 } else {
        m_ConfigAsset = objs [0];
 }
 

$$anonymous$$aybe it comes from the fact that I then manually move the .asset file from "Assets/Resources" to a sub Resources folder like "Assets/$$anonymous$$yPlugin/Resources". The doc says it should work and most of the time the asset is found, but sometimes I see a new asset being created in the "Assets/Resources" folder.

avatar image itchyOwl · Feb 22, 2018 at 08:29 AM 0
Share

I'm not sure about passing an empty string, but generally passing a path includes subfolders, so it should work. If it occurs randomly, there's something weird going on. I suggest using the generic version with a specific type, since you only seek for one type of assets.

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by itchyOwl · Feb 22, 2018 at 08:22 AM

 T[] instances = Resources.LoadAll<T>(pathUnderResources);

Works for me.

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 WildMage · Nov 12, 2018 at 04:28 PM 0
Share

Thanks for your answers. I was already doing it, but did not experience that issue since.

avatar image
1

Answer by tormentoarmagedoom · Feb 22, 2018 at 08:13 AM

I always Use Resources.LoadAll like this:

 GameObject[] GameObjectsList = Resources.LoadAll (path) as GameObject;

with the "as Gameobject" at the end to prevent wrong loadings.

I'm not sure if is this. Try it and give feedback!

 If was this, accept the answer!
 :D
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 Bonfire-Boy · Feb 22, 2018 at 11:05 AM 1
Share

This won't compile, Resources.LoadAll()returns an array so can't be cast to GameObject

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

77 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

Related Questions

Instantiate random prefab from folder using Resources.LoadAll 2 Answers

Scriptable object gets deleted with a class that holds it? 1 Answer

Error from declaring List within ScriptableObject 1 Answer

Best way to make a ton of weapons,Best way to build a ton of weapons 1 Answer

Need help understanding scriptable objects. 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