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 febucci · Sep 10, 2016 at 08:50 AM · prefabsloadingreferencememory usage

Are sprites reference (script) loaded every time?

Hi guys, we're developing a game for mobile phone and we're wondering about what is loaded and what is not.

Our game has 4 regions, and each region has 3 maps. Each region has his texture atlas. We have a master script that has ALL the sprites reference for each region and map. For example, if you're on map "1" the wall changes the sprite from "wall_castle" (by getting a reference from this script) but if you're on the map 2, the wall changes the sprite from "wall_town" and so on. Does unity load all atlas or only the used one? We're really worried about that. Thank you for your help ^^

[Sorry for the bad english and explanation]

Comment
Add comment · 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 itsharshdeep · Sep 10, 2016 at 11:15 AM 2
Share

Hi First of all thanks a lot for the great question. I am not very much AAA level experienced in Unity but as far I know that is :

Its depend upon how you are loading the references the texturing into the game: Generally, there are 2 ways (I think there are only 2 ways except asset bundle).

  1. Either you need to make a public variable which contains all the atlas then you can load from that.

  2. Or you load the atlas at the runtime from the resources.

Now question is which one is heavy ( in terms of $$anonymous$$emory Load)

  1. If you have the public references then at starting of the scene all the atlas will comes into the memory because the CPU know that you can assign any texture any time ..so need to reference all the atlases. Example : I will give you $$anonymous$$e example. I have 5 rooms in my game. User need to select from scene 1 that which room he want to go.. then as per his selection scene 2 loads that room . I have assign all the rooms publicly in my game. Like

    public GameObject[] rooms;

    // then at Start() I load the respective room Instantiate( room[selectedIndex]);

Now when I build and select the any of the room and tap on the play button .. $$anonymous$$y game got crashed every time. I was think a lot the reason .. then I came to know that $$anonymous$$y public variable is creating the issue .. Because when I assign a single room to that public room the game run smoothly. NO crash.

To solve that I used the references from Resources folder.. After that game now I used Resources approach in my every game.

  1. But now few days back I came to know that Resources folder remain in memory when game is running i.e. Unity doesn't know that you need to load which assets at what time ..so he keep references of all the resources assets at anytime/everytime.

Now my few days back statement is saying me that the publicly assigning references is much better because when the scene switches they will drop the UN-necessery references , or , previous & forth co$$anonymous$$g references.

So, In conclusion I didn't provide you any result .. but I have share all my experience with you.. WHICH SAYS THAT IT DEPENDS UPON THE TYPE OF ASSETS AND USE OF ASSETS IN GA$$anonymous$$E

Hope someone will clear this picture more.

Thanks for reading this all :)

avatar image febucci itsharshdeep · Sep 11, 2016 at 05:45 PM 0
Share

Thank you for your awesome reply. I understood a lot, and I think that we'll keep using the sprite reference way.

Thank you again, for your time writing and your well explained reply ^^ Have a nice day

0 Replies

· Add your reply
  • Sort: 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Prefab, referencing them, using their methods:bug or intentional? 1 Answer

Asset bundles and scene references 1 Answer

Confusion about DontDestroyOnLoad and very large scenes... 1 Answer

How to assign prefab at runtime? 1 Answer

How to put a reference on a prefab through the script ? 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