Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
4
Question by DaveCrowdStar · Apr 29, 2016 at 06:31 AM · canvasfontscalingpixelsingle

How to do One Pixel Lines in the Canvas UI

I have a one pixel line between many elements in a scrollview. I use a sprite with a height of 1 and a stretched width.

I was using ScaleWithScreenSize using the iPhone6 as my Reference Resolution and that seemed to work fine. Then when I went to look on the iphone, many of the lines seemed to flicker when scrolling. I guess it has trouble knowing whether to draw the line or not?

How do I maintain the single pixel? I want it to always render this dividing line.

I then thought that I should change my Canvas to be ConstantPixelSize. I figured I would just manually scale things which required scaling, and that way preserve unscaled, single pixel elements. But then I realized that the font did not properly scale, and the font size cannot be a decimal. This means that even if I multiply the rect size to the correct size, the font size will remain large. If I scale the font size, i will always have an integer size.

As an example, I have a ipad pro and an iphone. I want the font to be the same size relative to the screen on both (say 5% of the screen height). I would like my dividing lines to be 1 pixel on both. How can I achieve this? Is it possible?

Comment
Add comment · Show 3
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 DaveCrowdStar · Apr 29, 2016 at 07:04 PM 0
Share

Another possibility would be to scale the fonts differently. Even having them as floats would be nice. Then I could just scale everything proportionately. Ins$$anonymous$$d of setting the Header to be 48 and scaling the canvas, I could set it to anchor at like 5%. The only insurmountable problem with a constant pixel size is the font

avatar image mLevelRay · Sep 19, 2016 at 02:17 PM 0
Share

I'm having this same issue. $$anonymous$$y very simple solution was to make them 3px. At 2px there was still a noticeable flicker,but at 3px your guaranteed 2px of line at any given time.

avatar image Nickjd331 · Oct 08, 2020 at 09:19 AM 0
Share

I too would like to know the best solution for this. mLevelRay's solution sounds good but could result in mismatched line widths (2 or 3 pixels depending on position), so if there is an even better way I would love to know.

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

6 People are following this question.

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

Related Questions

Pixel perfect UI text/canvas point filtering 0 Answers

Getting pixel perfect text with either text meshes or GUI Text on a worldspace canvas 0 Answers

World Space UI low Quality 1 Answer

Using Hinge Joint 2D with scaled UGUI 0 Answers

How to scale the image through scripting so that the height of the image will be equal to the height of the screen and the width of the image will be scaled with the same percentage? 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