• 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
Question by Shadoninja · Apr 26, 2018 at 02:26 PM · prefabprefabsresourcesresources.load

About to gut my use of the Resources folder. What are the best practices going forward?

I have been using the Resources folder a lot. I have recently been informed that this is considered a very bad and dangerous thing to use for bigger projects. I dug in a little and found some evidence supporting this opinion: https://unity3d.com/learn/tutorials/topics/best-practices/resources-folder


Current approach:

An enemy spawner triggers a new enemy spawn. The spawner calls Resources.Load() on the appropriate enemy prefab, initializes it, and kicks it off into the world.


Best-practice approach(?):

An enemy spawner has a reference to all enemy type prefabs as public variables on the script. When an enemy spawn is triggered, the spawner just initializes the prefab that is a public variable on it.

Am I understanding this properly? Is there any documentation that goes over the best practices here when looking for alternatives to the Resources folder?

Comment

People who like this

0 Show 2
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 TreyH · Apr 26, 2018 at 02:34 PM 0
Share

What were some of the complaints you heard about Resources that worried you?

avatar image Shadoninja TreyH · Apr 26, 2018 at 02:45 PM 0
Share

Here is documentation from them on it: https://unity3d.com/learn/tutorials/topics/best-practices/resources-folder

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by TanselAltinel · Apr 26, 2018 at 03:03 PM

First and foremost, if you are instantiating a lot of game objects from prefabs, use pools.

By using pools, you'll have no need for Resources folder.

Here's a great starting point: https://unity3d.com/learn/tutorials/topics/scripting/object-pooling

I'm using PoolManager from path-o-logical games and after I instantiate my prefab, I can change anything on it by accessing components and scripts. Though any pooling system will work similarly, so you don't have to purchase an asset for it.

Comment

People who like this

0 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 TreyH · Apr 26, 2018 at 03:10 PM 0
Share

I don't think this is related to the question. Object pooling and managing how assets are organized within your build / deployment aren't really the same thing. OP doesn't seem to be using pools given how the question was phrased, but those issues aren't related to the concerns raised in their linked article.

avatar image TanselAltinel TreyH · Apr 26, 2018 at 03:13 PM 0
Share

OP is using Resources folder to load prefabs. This is the number on NO DO in Unity game development.

I've provided a useful answer to OP as how he is managing his game. He didn't ask a general question about Resources folder. He asked what would be a best practice to ditch usage of Resource folder and go on with development, without changing whole game structure.

So, it is not only related to question, it is also a better suitable answer to question instead of advocating Resources folder usage.

avatar image TreyH TanselAltinel · Apr 26, 2018 at 03:19 PM 0
Share

But you didn't tell OP where you are keeping your prefabs. You can pool anything, regardless of where it's sitting (resources, inactive in hierarchy, assetbundle). The example tutorial you linked uses an object sitting in the hierarchy, would you recommend that to OP for their problem?

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

108 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

Related Questions

Eliminating prefabs from resources folder? 1 Answer

how Load Prefabs after build 0 Answers

What does Unity actually do when Loading Resources that already exist? 0 Answers

which is better : putting all files(Images, AudioClips, ...) in Resources and make one generic prefab ? OR make many Prefabs and instantiate them in Runtime ? and why?! 0 Answers

In-Game Resource Management (How to?) 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