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 teh1archon · May 05, 2015 at 08:48 PM · uiguilinerenderergraphdrawline

How do I draw lines in a Rect

Hello,

I need to draw lines in a Panel (with Unity 4.6/5 GUI) to simulate stocks market values as they're changing. How do I do that? The game will be on Facebook and for Android (with varying screen aspects of course) so every GUI element that I did is relative to its parent canvas rather than absolute dimensions (is this wrong)?

What I've tried to do up to now was to get the panel's (where I draw the lines) real-world min and max Xs and Ys to know what my borders are and then it's just mathematics and the use of LineRenderer to make it happen. Unfortunately All I can get via:

 float minX = Camera.main.ScreenToWorldPoint(graphBG.offsetMin).x;
 float minY = Camera.main.ScreenToWorldPoint(graphBG.offsetMin).y;
 float maxX = Camera.main.ScreenToWorldPoint(graphBG.offsetMax).x;
 float maxY = Camera.main.ScreenToWorldPoint(graphBG.offsetMax).y;

Is the canvas that hold all the other canvases in the game (they're all his children). Also that Master Canvas is set to be "Screen Space - Camera" otherwise it just block every other render in Screen Space - Overlay.

So what can I do?

I don't mind paying for a plug-in to do it for me if there's one out there.

Thanks ahead, Shay.

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 omatase · May 06, 2015 at 01:09 AM

I did something like this where I showed a character's experience to next level in a bar. I used the slider control that comes with the new Unity UI and just deactivated the handle game object that gets nested within. It worked pretty well. Just set the "value" to a number between 0 and 1.

 public Slider CharacterXpSlider = null;
 
 CharacterXpSlider.value = (float)newValue / maximumValue;
 
Comment
Add comment · Show 2 · 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 teh1archon · May 08, 2015 at 04:20 AM 0
Share

Seems legit but how can I make several dynamic sliders on the fly? The Graphs are made of several sagements how can I know where each sagement starts and ends?

avatar image omatase · May 08, 2015 at 04:36 AM 0
Share

I just use Instantiate for something like that. This page in the Unity manual talks about that. http://docs.unity3d.com/$$anonymous$$anual/HOWTO-UICreateFromScripting.html

Here's an example

 public GameObject YourPrefabType = null;
 
 ...
 GameObject sliderInstance = (GameObject)Instantiate(YourPrefabType);
 

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Line Renderer in GUI 0 Answers

Drawing lines from mouse position 2 Answers

Gameobject is drawing a line render,when it's not supposed to ! 0 Answers

uGUI Button size based on text size 1 Answer

Draw line in runtime 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