Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Editor camera events

Discussion in 'Editor & General Support' started by unity-user, Dec 30, 2014.

  1. unity-user

    unity-user

    Joined:
    May 6, 2013
    Posts:
    27
    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();
    • }
    • }
     
  2. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    Hey there,

    Are you just trying to draw lines as helpers in the edit view?
     
  3. unity-user

    unity-user

    Joined:
    May 6, 2013
    Posts:
    27
    I'm trying to draw Triangles oops I will edit
     
  4. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
  5. unity-user

    unity-user

    Joined:
    May 6, 2013
    Posts:
    27
  6. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
    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.
     
  7. unity-user

    unity-user

    Joined:
    May 6, 2013
    Posts:
    27
    However the triangle won't be filled right ?
     
  8. BMayne

    BMayne

    Joined:
    Aug 4, 2014
    Posts:
    186
  9. unity-user

    unity-user

    Joined:
    May 6, 2013
    Posts:
    27
    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.
     
    Last edited: Dec 30, 2014