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
1
Question by Southgarden116 · Nov 21, 2016 at 07:21 AM · shadermaterialopenglgraphgl

How to draw GL Lines over GameObjects/Images?

I am drawing lines between GameObjects to show their connection (showing a graph) using GL Lines and it always worked fine until I created a background Image using a Sprite. GameObjects are always hiding the Lines and because of the Background Image I can't see the lines anymore. Someone else had the reverse problem here: http://answers.unity3d.com/questions/434827/gllines-over-game-objects.html and I tried to use this shader but it doesn't work for me.

The code I have under OnPostRender() looks like this:

 Shader shader = Shader.Find("Lines/Colored Blended");
 Material lineMat = new Material(shader);
 GL.PushMatrix();
 lineMat.SetPass(0);
 GL.LoadOrtho();
 for (int i = 0; i < drawingGraph.edges.Count; i++)
 {
     Vector3 start = startObj.transform.position;
     Vector3 end = endObj.transform.position;
     GL.Begin(GL.LINES);
         GL.Vertex3(start.x / Screen.width, start.y / Screen.height, start.z);
         GL.Vertex3(end.x / Screen.width, end.y / Screen.height, end.z);
     GL.End();
 }
 GL.PopMatrix();

The shader I'm using is this from the other post:

 Shader "Lines/Colored Blended" {
     SubShader{
         Tags { "RenderType" = "Overdraw" }
         Pass {
             ZWrite Off
             ZTest Always
             Cull Off
             Fog { Mode Off }
             BindChannels {
                 Bind "vertex", vertex Bind "color", color 
             }
         }
     } 
 }

And that's how it looks without the background GameObject: alt text And here with the background: alt text

Can you guys tell me what I'm doing wrong? Thanks!

graph2.png (8.4 kB)
graph1.png (119.5 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 EpsilonQoppa · Nov 21, 2016 at 12:19 PM 0
Share

It looks like your lines are under your background.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Southgarden116 · Nov 22, 2016 at 08:25 PM

I solved it! In case anyone else has that problem: The canvas render mode was set to "Screen Space - Overlay". I switched to "Screen Space - Camera" and it worked.

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

GL - Shader not working in Android 1 Answer

Shader Graph | How to create gradient from scratch 1 Answer

Shader graph shader won't pick up lighting 0 Answers

Material doesn't have a color property '_Color' 4 Answers

Shader Graph transparency issue 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