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
0
Question by BenouKat · Jan 30, 2015 at 09:01 AM · uispriteloadmemory4.6

Best way to change sprite in Image (GUI 4.6) ?

Hi everyone,

I try to convert my NGUI project to Unity 4.6 project. Even if you don't know NGUI you can maybe help me.

In NGUI, to change a sprite by another dynamically, we just simply did "mySprite.spriteName = "myNewImage", and it automaticly find the matching image on the Atlas, and display the new sprite.

In GUI 4.6, I see everywhere in UnityAnswers that we need to link OR load all the sprites, and then do a "spriteList.Find()" to get the new sprite and replace the older one.

My problem : In NGUI, the way it was coded didn't require to load in memory all others images. And I just check the inspector for the 4.6 system and I clearly see the loaded image in memory.

What is the point ? The Atlas (or Pack in 4.6) is already loaded in memory, and I need to RELOAD again all sprites of the atlas/pack to being able to switch between them ? There's no way to access the sprite without loading it ?

My question : Am i missing something about switch image in the same atlas and/or memory usage of 4.6, or "this is how it works, too bad, your project just increase its memory needs" ?

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

Answer by Priyanshu · Jan 30, 2015 at 11:16 AM

I have never used NGUI and don't know the method used by it for loading sprites at run time.

  1. All unused assets do not require any memory( Hard Disk memory). That is they are not included in the Game Build.

  2. When a scene starts Unity creates instances of Objects in the scene. Memory(RAM) will be allocated to the objects in the scene and not assets. It will only load sprites which are used in the scene. Hence it depends on you. If you want to load them at the start of the scene or at run-time.

You can use two methods to change sprites:

  1. Save them in the beginning of the scene in a list or array. This method is useful when you do not have large number of objects to load in scene i.e. loading time is small.

  2. Load them while your scene is running using this. Useful when your scene takes a lot of time loading and you want to minimize the number of objects to load at the start of scene.

P.S. - I'm just a beginner. Can't help you much in memory section. Maybe someone can correct me if i'm wrong. Or give better insight.

Comment
Add comment · Show 1 · 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 BenouKat · Jan 30, 2015 at 02:35 PM 0
Share

Thanks for the answer. I know all of this, I was just asking if there's a way to NOT load all the sprites you need to switch at runtime, by accessing directly the sprite-pack of GUI 4.6.

But the more I look on Internet, the more my answer seems to be "no".

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

20 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

Related Questions

Unity 4.6: How to fit center byte array png in the Image UI? 1 Answer

UI 4.6 APK size problem : Sprite both in Atlas and Inspector 0 Answers

Loading built-in resources 1 Answer

Animated Sprite in UI Canvas? 4 Answers

Building scenes and load time 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