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 tefloon · Mar 04, 2017 at 08:49 AM · performancematerialsserializationload

Serialized variable vs Resources.Load()

Hello community! I've seen many questions discussing the difference between Serialized private members and public ones. I couldn't find an answer to a similar but different problem though, hence my question:

I need to access a Material from within my script. As far as I know I can do one of two things:

  1. Create a variable of type Material with [SerializeField] modifier and drag the desired item in the inspector to connect it.

  2. Use Resources.Load() and assign it to a variable of type Material

My question is if there is any reason to use one over the other, performance-wise or other? I should add that the script will be tied to a prefab, which will be instantiated quite a few times, so the script will also get executed many times.

Best wishes and thank you in advance

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

1 Reply

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

Answer by Hellium · Mar 04, 2017 at 08:51 AM

2.1. Best Practices for the Resources System

Don't use it.

This strong recommendation is made for several reasons:

  1. Use of the Resources folder makes fine-grained memory management more difficult.

  2. Improper use of Resources folders will increase application startup time and the length of builds.

  3. As the number of Resources folders increases, management of the Assets within those folders becomes very difficult.

  4. The Resources system degrades a project's ability to deliver custom content to specific platforms and eliminates the possibility of incremental content upgrades.

AssetBundle Variants are Unity's primary tool for adjusting content on a per-device basis.

Source : https://unity3d.com/fr/learn/tutorials/topics/best-practices/resources-folder

Moreover :

  1. If you change the name / location of the asset, you will have to find very references of this asset in your code and change the path, and, since the path is a simple string, it's very hard to track it all over you code.

  2. The assets you put here may be accessible by the users after the build (at least, on a PC build)

  3. The assets put in the Resources folder are directly put in the build, without compression or optimization from Unity, and are not removed even if you never use them in your code (Unity removes the unused assets in the non-Resource folders.)

Also, check this post : http://answers.unity3d.com/questions/319127/goods-and-bads-about-using-resourcesload.html

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Fast, easy serialization library for Unity? 0 Answers

How to save/load references to components and prefabs 1 Answer

Unity Not Loading 0 Answers

Unity Serializer - saves delete after restarting game 2 Answers

SerializationException: Type UnityEngine.UI.Button is not marked as Serializable. Solution 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