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 garv3 · May 05, 2015 at 03:25 AM · texturespritecanvasaspect-ratioresizing

Why does my RenderTexture/Sprite not match the Canvas' Size?

Hi all,

I got some problems using a RenderTexture as the Texture of a RawImage that is a component of a Canvas. If I use a standard Texture, everything works fine. Using a RenderTexture or even a Sprite(2D and UI) causes trouble depending on its resolution. Let's say, my screen and canvas resolution is 1280x720. If I set a RenderTexture or Sprite with 1280x720 pixels as the RawImage texture of my canvas, it fills up the whole canvas. This works for most RenderTextures and Sprites that match the screens (and canvas') aspect ratio. But for some sizes it won't work: 80x45 and 16x9 pixels. Both obviously match the aspect ratio, but both are compressed vertically and the top row of the virtual pixels is left empty. I can see all 80x45 or 16x9 pixels of the texture but they are not square! Their width is greater than their height. This results in a free row on top of the canvas. If I import an image as Texture (NOT as Sprite!), everything works fine. But since I would like to create the Canvas' RawImage at runtime, I have to use RenderTextures.

I would like to provide you with a screen shot visualizing the problem:

Problem with Canvas RawImage Texture

As you can see, there is an empty area at the top of the canvas. Its resolution is 1280x720 and the RawImage has automatically been resized to exactly the same size. The size of the image itself is 16x9 pixels. All 16x9 pixels are shown in the canvas but they are shrinked down and there is this gap on the top.

Any idea, what is going on here? Thanks in advance for all kinds of help and support.

garv3

EDIT: I found that this problem can only be reproduced with non-power-of-two textures. All power-of-two sized textures seem to work. Nut this does not solve my problem.

canvas-problem.png (170.9 kB)
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

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

2 People are following this question.

avatar image avatar image

Related Questions

Get sprite to have top-left corner always at top-left of screen 0 Answers

Aspect Ratio changes GUI Location Code in CSHARP 1 Answer

Sprites and textures appears black on Samsung Galaxy Grand I9082 0 Answers

Texture type -> Advanced -> Mesh type: how it works? 1 Answer

Unity 2018 UGUI Android Sprite Textures Not Rendering Correctly 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