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
1
Question by valerik · Aug 09, 2013 at 03:42 PM · sceneperformanceinspectorencapsulation

Resources loading vs public linking in inspector

Hello, i think the question is enough clear: what are the difference between load by script resources (http://docs.unity3d.com/Documentation/ScriptReference/Resources.html) and build a scene with elements already linked by inspector property? could it be see as encapsulation vs performance?

Comment
Add comment · Show 5
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 tomekkie2 · Aug 09, 2013 at 03:51 PM 1
Share

I think in most cases this is a matter of the loading time in the Webplayer or memory capacity.

avatar image Jamora · Aug 09, 2013 at 04:17 PM 0
Share

Everything in the Resources floder is added to the build, whether it's used or not. If your assets etc. are not in the Rescources folder, only stuff you have linked in the inspector will be included in the build. I'll let someone who knows more give a more comprehensive answer.

avatar image valerik · Aug 09, 2013 at 11:55 PM 0
Share

Thanks both for answers. $$anonymous$$y main dubt is about performance, which one provides better performance? i add an example for next answer: Given a material, i can load it by script using resources locator loading or just write: public $$anonymous$$aterial my$$anonymous$$aterial; and then by inspector link it to the object that will use it and than save it in scene.

avatar image RyanZimmerman87 · Aug 10, 2013 at 12:00 AM 0
Share

I'm curious for more optimization tips like this myself.

But for now I am assu$$anonymous$$g assigning them in the inspector is the way to go for performance since it seems like how they want you to use Unity.

The only downside to this is that the scenes will take up more memory than if you set up some kind of Level$$anonymous$$anagerScript that initializes all your prefabs to build the levels at run time.

But unless you're trying to keep your game really small like under 50$$anonymous$$B for mobile games for example, I think using the public inspector variables should be fine.

"Everything in the Resources floder is added to the build, whether it's used or not. If your assets etc. are not in the Rescources folder, only stuff you have linked in the inspector will be included in the build. I'll let someone who knows more give a more comprehensive answer."

I thought Unity dynamically deter$$anonymous$$ed what you actually use in the build so they wouldn't include unused assets in an .apk or .exe file for example?

Edit: looks like I missed the resources folder thing I think that is correct it will be auto included.

avatar image valerik · Aug 10, 2013 at 12:56 AM 0
Share

From: http://docs.unity3d.com/Documentation/ScriptReference/Resources.html

In Unity you usually don't use path names to access assets, ins$$anonymous$$d you expose a reference to an asset by declaring a member-variable, and then assign it in the inspector. When using this technique Unity can automatically calculate which assets are used when building a player.

Seems the answer "yes, use public and inspector linking".

But it goes against encapsulation principle of oop. However it's true that unity+c# is half scripting half oop.

If someone know more, please add a comment =)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dacaramo · Jun 19, 2020 at 09:02 PM

Like 7 years late but answering cause a while ago I had the same doubt, and also because i'm wishing to know if somebody thinks that Ressources loading via scripting is indeed useful rather than useless.

@valerik I dont think that loading ressources via scripting will have any advantage over letting unity doing it by it's self, according to the ressources and assets Unity tutorial, they even say that the best practice for the usage of the Ressources system is not using it. https://learn.unity.com/tutorial/assets-resources-and-assetbundles#5c7f8528edbc2a002053b5a7

The only potential use that I can think of is use it when loading a scene. Instead of creating a copy of a pre-existing GameObject by using GameObject.Instantiate() you can directly create the "pre-existing" GameObject from scratch by instantiating it using "new GameObject(String "name", Type[] listOfComponents)". When filling the components array you would need to load ressources from your assets. ... maybe useful when you have too many GameObjects that would need tons of copys and you dont want to have like hundreds of gameobjects just to make copies of them, instead you could directly create the GameObjects with their respective components and properties.

Indeed, in this last case , public linking will downgrade your performance, and will be better to use the Ressources system via scripting.

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

18 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

Related Questions

Sprite changes that only apply in scene view 1 Answer

What faster? Make a saved scene with gameobjects, or create it on start? 1 Answer

Different scenes or single scene for a space rpg ? 1 Answer

How do i NOT break encapsulation with Unity? 2 Answers

Force inspector to use getter/setter? 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