Editor camera events

Hello,
how can I plug in this code into editor’s camera tryed googling but didnt find anything :

  • using UnityEngine;
  • using System.Collections;
  • [ExecuteInEditMode]
  • public class NavDebug : MonoBehaviour {
    • void OnPreRender(){
  • GL.Begin(GL.TRIANGLES);
  • //draw code
  • GL.End();
  • }
  • }

Hey there,

Are you just trying to draw lines as helpers in the edit view?

I’m trying to draw Triangles oops I will edit

There is good news!

Unity has a lot of built in shape and line drawing tools called Handles. They are used for this purpose.

Docs

Here is the page talking about drawing lines.

Regards,

Hmm I cant see function for drawing Triangles

You will just have to create 3 points in space and draw a line between them using DrawPolyLine. You can create a helper function pretty quickly if you need to do this a lot.

However the triangle won’t be filled right ?

If you want it filled you can just

use Unity - Scripting API: Handles.DrawSolidRectangleWithOutline

and make two of the verts the same.

hmm the problem I found after figuring things out is that I must have the Object selected In order to draw the triangle.As OnPreRender method suggests I want to draw the triangles all the time.

Even though It was good experience to learn how to use Unity Editor I lost lots of time .Could somebody tell me what I asked and not go around my question I asked at first place.