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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

DrawMeshNow GUI Ortho

Discussion in 'Scripting' started by CAOZ, May 29, 2011.

  1. CAOZ

    CAOZ

    Joined:
    May 26, 2011
    Posts:
    4
    How do I draw ie a GUI/Texture in ortho (screen) mode
    I must say the documentation on this subject/object is very poor/none.

    Matrix4x4.Ortho
    static function Ortho (left : float, right : float, bottom : float, top : float, zNear : float, zFar : float) : Matrix4x4
    Description

    Creates an orthogonal projection matrix.

    The returned matrix is such that views left to right, bottom to top area, with zNear and zFar depth clipping planes.

    - What values do I use for left, right, top, bottom?
    - In what event/method do I actual call drawmeshnow?

    In all my attempts I got either nothing or the object drawn in 3d
    I tried

    1.
    float left = 0f;
    float right = Screen.width;
    float bottom = 0f;
    float top = Screen.height;

    Matrix4x4 matrix = Matrix4x4.Ortho(left, right, bottom, top, Camera.current.near, Camera.current.far);

    Graphics.DrawMeshNow(mesh, matrix);

    2.
    GL.PushMatrix();
    GL.LoadIdentity(); // With and without LoadIdentity
    GL.LoadPixelMatrix();

    // I tried using gui matrix
    Graphics.DrawMeshNow(mesh, GUI.matrix);

    // I tried using identity matrix
    Graphics.DrawMeshNow(mesh, Matrix4x4.identity);

    GL.PopMatrix();

    3.
    GL.PushMatrix();
    GL.LoadIdentity(); // With and without LoadIdentity
    GL.LoadPixelMatrix(0, Screen.width, 0, Screen.height);

    // I tried using gui matrix
    Graphics.DrawMeshNow(mesh, GUI.matrix);

    // I tried using identity matrix
    Graphics.DrawMeshNow(mesh, Matrix4x4.identity);

    GL.PopMatrix();

    4.
    Camera.main.orthographic = true;

    // I tried using gui matrix
    Graphics.DrawMeshNow(mesh, GUI.matrix);

    // I tried using identity matrix
    Graphics.DrawMeshNow(mesh, Matrix4x4.identity);

    Camera.main.orthographic = false;

    5.
    Camera.current.orthographic = true;

    // I tried using gui matrix
    Graphics.DrawMeshNow(mesh, GUI.matrix);

    // I tried using identity matrix
    Graphics.DrawMeshNow(mesh, Matrix4x4.identity);

    Camera.current.orthographic = false;
     
  2. CAOZ

    CAOZ

    Joined:
    May 26, 2011
    Posts:
    4
    Anyone?
     
  3. CAOZ

    CAOZ

    Joined:
    May 26, 2011
    Posts:
    4
    Not even any support from Unity?