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 naxrius · May 25, 2016 at 02:56 PM · unity 5uilinerendererline rendererlines

Issue drawing lines between buttons - Lines overlap the buttons

I'm trying to draw lines between buttons, but the lines keep overlapping the buttons. I modified my script to draw the lines behind the buttons however they still overlap. Any ideas?

 using UnityEngine;
 using System.Collections;
 
 // This script draws lines between elements of the Bowtie display
 public class DrawLine : MonoBehaviour {
     private LineRenderer lineRenderer;
     private float counter;
     private float dist;
     private Vector3 aPos;
     private Vector3 bPos;
     public Transform origin;
     public Transform destination;
     public float lineDrawSpeed = 6f;
 
     // Use this for initialization
     void Start () {
         lineRenderer = GetComponent<LineRenderer>();
         aPos = new Vector3(origin.position.x, origin.position.y, origin.position.z + 0.2f); // Using these to move the lines back
         bPos = new Vector3(destination.position.x, destination.position.y, destination.position.z + 0.2f);
 
         lineRenderer.SetPosition(0, aPos);
         lineRenderer.SetWidth(.02f, .02f);
 
         dist = Vector3.Distance(origin.position, destination.position);
     }
     
     // Update is called once per frame
     void Update () {
 
         if(counter < dist){
             counter += .1f/lineDrawSpeed;
 
             float x = Mathf.Lerp(0, dist, counter);
 
             Vector3 pointA = aPos;
             Vector3 pointB = bPos;
 
             Vector3 pointAloneLine = x * Vector3.Normalize(pointB - pointA) + pointA;
 
             lineRenderer.SetPosition(1, pointAloneLine);
         }
     
     }
 }
 
front-view.png (384.4 kB)
top-view.png (217.8 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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Prezzo · May 25, 2016 at 04:05 PM

I don't see any buttons in your code, but try to place the lineRenderer higher on the z-axis than the buttons should solve your problem. Try:

 aPos = new Vector3(origin.position.x, origin.position.y, origin.position.z + 10f); // Using these to move the lines back
          bPos = new Vector3(destination.position.x, destination.position.y, destination.position.z + 10f);

Comment
Add comment · Show 1 · 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 naxrius · May 25, 2016 at 05:26 PM 0
Share

The buttons are referenced as "destination" in my code. In the code I posted I already attempted to move the lineRenderer further on the Z axis, by 0.2f, with no luck. Anything higher than 0.2f is too far and doesn't look right :/

avatar image
0

Answer by M-Hanssen · May 25, 2016 at 03:18 PM

You should render the buttons on a different layer than the LineRenderer and assign those layers to different cameras. Use the camera's depth setting to change to order of rendering.

Check this answer for more details:

http://answers.unity3d.com/answers/1169946/view.html

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Xbox Controller and Unity Buttons UI 0 Answers

Scroll Rect with Grid Layout not working properly. 2 Answers

How to match UI Image size with sprite size at runtime? 2 Answers

unity3d GUI scripting 1 Answer

All UI buttons appear and stack on top of each other. 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