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 Stephane-Imbert · Mar 06, 2015 at 02:20 PM · androiduiiosresolutionui image

Use different sprites in new Unity UI for SD vs HD

Hi all,

We are looking at the new Unity UI coming from using NGUI. Looking at the documentation for the Canvas Scaler and Designing UI for Multiple resolutions, I understand how to set the layout for my UI components and how to get them to scale properly.

One thing I am unclear on however is the ability to specify a different set of images depending on the resolution (SD vs HD), similar to what NGUI provides with Reference Atlases.

We want to load different sprites (or sprite atlases) depending on the supported resolution for the device. Two reasons: (1) on higher resolution devices we want pixel perfect images (larger images) but (2) on lower resolution devices we want to use as little memory as possible (since lower res devices tend to also be lower RAM)

alt text

It seems the Canvas Scaler only allow us to either (a) provide large textures scaled down for lower resolution devices (correct visuals but larger memory footprint) or (b) provide small textures scaled up on higher resolution devices (lower memory footprint but scaling artifacts)

I haven't seen any documentation that addresses this topic specifically. Is there a way to do this?

Thanks.

Stephane

sd-vs-hd.png (33.4 kB)
Comment
Add comment · Show 1
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 hexagonius · Mar 06, 2015 at 04:06 PM 0
Share

We also stumbled over this with our project. We were compensating with 2D Toolkit for Sprites. You could probably write your own Script, that deter$$anonymous$$es the device and chooses to Resources.Load whatever atlas you need. $$anonymous$$y guess is you're out of luck, there's no such thing integrated into Unity yet.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Yury-Habets · Mar 07, 2015 at 03:58 AM

You might want to use Asset bundles: http://docs.unity3d.com/Manual/AssetBundlesIntro.html

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 Stephane-Imbert · Mar 08, 2015 at 03:51 PM 0
Share

I have looked at asset bundles, specifically assetBundles variants. The one issue I am running into with bundles is that I cannot get them to work for assets used by a prefab. If I have the prefab in one asset bundle and the assets it uses in a separate bundle, the prefab seems to lose the connection to its dependencies (even though variants are supposed to maintain the ID).

avatar image
0

Answer by jrhtcg · Mar 08, 2015 at 05:02 PM

I did not test the code below, but it should be close to what you need. Create a script and attach to each UI component. Assign the HdSprite in the inspector.

 public Sprite HdSprite;
 void Start()
 {
     if (Screen.width > 800)
     {
         this.GetComponent<Image>().sprite = HdSprite;
     }
 }
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
avatar image
0

Answer by TimB · Mar 24, 2015 at 06:16 PM

You should check out https://www.youtube.com/watch?v=rMCLWt1DuqI if you haven't seen it yet. He begins discussing it in the first few minutes. I am going through the same process as you deciding to try the Unity UI/2D for our next project or stick with our NGui / 2D toolkit approach. I would love to come up with a solution using the native Unity tools, but I am currently leaning towards just using 2D toolkit for everything, including UI.

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Divide resolution and stretch to screen/window/canvas 1 Answer

Q about Building my game for so many devices 2 Answers

How to modify EditText appearance on Android and iOS? 0 Answers

Adjusting UI to cellphone screen size 0 Answers

Texture looks low-res/chunky/pixelated on mobile 3 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