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 Tesorero204 · Jan 07, 2020 at 05:40 PM · scriptableobjectloadingsearch

Searching and loading a specific instance of a Scriptableobject from the editor by its name

Hi! I've been trying to do this with Resources.Load<>(); but to no avail. this is my ScriptableObject.

[CreateAssetMenu(fileName = "New Move", menuName = "Move")] public class Move : ScriptableObject { public enum Type{Water, Fire, Ice, Light, Dark, Kami}; public bool isDamaging; public bool isUsable = true; public int dmg; public int reloadTime; public GameObject spawn; public Type type; }
I'm not very experienced with scripting, I'm rather a beginner, so some help would be appreciated. How can I search for a specific instance of it sitting in the editor in my Assets folder through script?

Comment
Add comment · Show 1
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 Tesorero204 · Jan 07, 2020 at 05:41 PM 0
Share

If the code is hard to read, here's a more organized version of it:

 [CreateAsset$$anonymous$$enu(fileName = "New $$anonymous$$ove", menuName = "$$anonymous$$ove")]
 public class $$anonymous$$ove : ScriptableObject
 {
 public enum Type{Water, Fire, Ice, Light, Dark, $$anonymous$$ami};
 public bool isDamaging;
 public bool isUsable = true;
 public int dmg;
 public int reloadTime;
 public GameObject spawn;
 public Type type;
 }
 

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by AltaNox · Jan 07, 2020 at 06:13 PM

Resources.Load<>() it's the correct method. Just remember that the Resources class only loads stuff from a folder in your project called Resources. This is stated in the documentation for Resources.Load. From that point you only need to provide the correct path for the scriptable object.


For example, if the file is just under Resources and it is called FireMove

 Move move = Resources.Load<Move>("FireMove");

If the file is under a folder called Scriptables inside Resources

 Move move = Resources.Load<Move>("Scriptables/FireMove");

This should do what you want.


As a side note, you should probably take a look at Asset Bundles. These are what you should ideally be using for loading assets at run time. It's a bit more complicated but it is the preferred way to do it since it provides a lot more flexibility. Resources is an easy and fast way to load something but if you want to do anything serious with it, it won't hold up that well. Anyway, maybe for your project Resources is enough but that is up to you.

Comment
Add comment · Show 2 · 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 Tesorero204 · Jan 07, 2020 at 06:33 PM 0
Share

Thanks! I'll investigate about Asset Bundles for future projects.

avatar image AltaNox Tesorero204 · Jan 07, 2020 at 06:59 PM 0
Share

No problem :) If the problem is solved please mark the answer as accepted.

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

122 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 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

Using ScriptableObjects data loaded with the Addressable Package 0 Answers

Instancing ScriptableObject at Runtime, loading and saving via JsonUtility 1 Answer

How to load ScriptableObject from asset file immediately? 1 Answer

Saving items and reading their data 1 Answer

How to Save and Load a list of Scriptable Objects from a File? 2 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