Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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 /
  • Help Room /
avatar image
0
Question by Imagine_1994 · Apr 18, 2019 at 01:33 PM · uicanvaslinerenderergraphline drawing

Is it possible draw linerenderer in a UI space?

Hi guys, I have a small problem with LineRenderer and the UI. I'll show you a screen of my project

alt text

I wanna draw a graph that show the movement of the Cube (that you can see under the graph) that it make going up and down. And I do this in real time, with a refresh of the graph any second.

Using LineRenderer, doing it was very easy, but the drawing appear in any case in the game scene and not in the Canvas and really I don't know how can i draw the line in the black space at the right of the screen.

Can anyone help me? At the bottom you can see the code that i used to draw the actual line.

 public class Graph : MonoBehaviour {
 
     public float graphWidth;
     public float graphHeight;
     LineRenderer newLineRenderer;
     List<int> decibels;
     int vertexAmount = 50;
     float xInterval;
     GameObject parentCanvas;
 
     public GameObject Diver;
     List <int> profondita=new List<int>();
     private float startTime;
     int tempo_riferimento;
 
     // Use this for initialization
     void Start ()
     {
 
         startTime = Time.time;
 
 
         newLineRenderer = GetComponentInChildren<LineRenderer>();
         newLineRenderer.SetVertexCount(vertexAmount);
         xInterval = 1;//graphWidth / vertexAmount;
 
     }
 
 
     void Update(){
         float t = Time.time - startTime;
 
         //ogni secondo
         if (tempo_riferimento != (int)t) {
             tempo_riferimento = (int)t;
             profondita.Add ((int)Diver.transform.position.y+5);
             Draw (profondita);
         }
     }
 
     //Display 1 minute of data or as much as there is.
     public void Draw(List<int> depths)
     {
         if (depths.Count == 0)
             return;
 
         float x = 0;
 
         for (int i = 0;  i < depths.Count; i++)
         {
             int _index = depths.Count - i - 1;
 
             float y = decibels [_index];// * (graphHeight/130); //(Divide grapheight with the maximum value of decibels.
             x = i * xInterval;
 
             newLineRenderer.SetPosition(i, new Vector3(x - graphWidth / 2 , y - graphHeight / 2 , 0));
         }
     }
 }
schermata-2019-04-18-alle-151709.png (92.8 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 KevRev · Apr 18, 2019 at 09:00 PM 0
Share

You could try projecting it onto the smaller display.

Give the line its own layer. Create a new camera that only shows that layer. Create a raw image and apply the material to the black screen. Create a texture and apply to the black screen material. Assign the same render texture to the new camera (render to texture).

Then whatever the camera sees should appear on the black screen.

Be sure to exclude the line layer from your main camera.

I'm doing this from memory on my mobile, so apologies if I've missed any steps, but this should hopefully give you enough to go on.

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

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

How do I draw line on panels and canvas? 0 Answers

UI Canvas elements stopped showing after long time of play. 0 Answers

C# - The name does not exist in the current context 1 Answer

Having constant trouble with Unity's inbuilt UI system. 2 Answers

Canvas not filling up the whole screen in Unity 5 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