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 IbrahimQasim · Jul 05, 2018 at 02:17 PM · uispriteui image

Creating scalable UI elements/images?

Hi!

I want to create certain UI elements, such as crosshairs, markers, etc, that can be flexible in terms of size, rotation etc.

For example, a hexagonal marker with a border of 1 pixel. One way to create this would be to use a sprite component. However, the problem with this is if you increase the size of the image (e.g. when the object gets closer), the thickness of the marker will increase. It's also not possible to use the border feature as the hexagon is not rectangular.

Another method could be to use 6 separate line renderers, but this is annoyingly complicated and also would start adding overhead when there are multiple markers being updated on screen.

I would like to know if there is a way in Unity to create images through script (e.g. for a hexagon I could write a script that draws the correct lines), or if there is some other way to achieve this effect? I remember reading somewhere about being able to write renderers, but I can't remember where.

Comment
Add comment · Show 4
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 Shameness · Jul 05, 2018 at 03:33 PM 0
Share

Have a separate camera* to just render UI elements, or Use UI Canvas. For hexagonal cross hair create asset by yourself and import it to game. For thickness you can use two overlapping hexagon, where middle hexagon scales down to increase thickness. *edit

avatar image IbrahimQasim · Jul 06, 2018 at 02:11 PM 0
Share

Increasing thickness is precisely what I don't want to do. For example, say I have a triangle reticle surrounding a target. When the target gets closer to the camera, it gets bigger, and so the triangle should get bigger as well. However, if I use an image/sprite, the scaling causes the border thickness to increase when I increase the size, and get smaller when I decrease the size. I want the thickness to stay the same throughout.

avatar image WinterboltGames IbrahimQasim · Jul 06, 2018 at 02:13 PM 0
Share

Why not tile the sprite ins$$anonymous$$d of scaling it?

avatar image IbrahimQasim WinterboltGames · Jul 06, 2018 at 02:47 PM 0
Share

I'm not sure how tiling would help, since it would just repeat the image over and over? Do you mean slicing it? Slicing wouldn't work in this case since the borders can only be defined for rectangular images (e.g. square reticles), whereas here I want to have something like a triangle or a circle or a hexagon. Perhaps I should post a picture?

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

172 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 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 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 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 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 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 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 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 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

Detect 2d items only on areas where the sprite covers, and not the whole box! 0 Answers

Angled UI image creates pixels ladder 1 Answer

Order Issues - How to order UI correctly - Canvas, Sprite, Panel with Background (Image) 0 Answers

How do I size a UI Image to fit the sprite exactly? 2 Answers

Pixels Per Unit good practice query 0 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