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

Graphics.DrawMesh wont work with transparent shader.

Discussion in 'Scripting' started by Pavlon, Oct 30, 2019.

  1. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    Greetings I have some issue with the Graphics.DrawMesh function I use it to draw a selection grid.
    The problem is I only can see it inside the editor window when using a transparent shader.

    editorview.png gameview.png
    Left is editor view and right is the game view.

    Code (CSharp):
    1.         Tags { "Qeue" = "Transparent"  "RenderType" = "Transparent" }
    2.         LOD 100
    3.         ZWrite OFF
    4.         Blend SrcAlpha OneMinusSrcAlpha
    With this settings its only visible inside the editor.

    Using this settings works in editor and game view.
    Code (CSharp):
    1.         Tags { "RenderType" = "Opaque" }
    2.         LOD 100

    The code i use when calling Graphics.DrawMesh

    Code (CSharp):
    1.        Graphics.DrawMesh(topMesh, renderPosition, Quaternion.identity, materialClean, drawLayer);
    2.                     if (IsInsideBounds(x, z + 1, currentMap.GetLength(0), currentMap.GetLength(1)) && currentMap[x, z + 1] != 0 || z + 1 == endZ)
    3.                         Graphics.DrawMesh(frontMesh, renderPosition, Quaternion.identity, materialClean, drawLayer);
    4.                     if (IsInsideBounds(x + 1, z, currentMap.GetLength(0), currentMap.GetLength(1)) && currentMap[x + 1, z] != 0 || x + 1 == endX)
    5.                         Graphics.DrawMesh(rightMesh, renderPosition, Quaternion.identity, materialClean, drawLayer);
    6.                     if (IsInsideBounds(x, z - 1, currentMap.GetLength(0), currentMap.GetLength(1)) && currentMap[x, z - 1] != 0 || z == startZ)
    7.                         Graphics.DrawMesh(backMesh, renderPosition, Quaternion.identity, materialClean, drawLayer);
    8.                     if (IsInsideBounds(x - 1, z, currentMap.GetLength(0), currentMap.GetLength(1)) && currentMap[x - 1, z] != 0 || x == startX)
    9.                         Graphics.DrawMesh(leftMesh, renderPosition, Quaternion.identity, materialClean, drawLayer);
    10.                     continue;
    For render layers i tryed setting it to 0 and 1.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    I don't think this is the correct spelling of Queue ... is that the problem?
     
    Pavlon likes this.
  3. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    You are f..kn brilliant.

    I spent more then 5 hours trying to figure out whats going wrong.
     
    neoshaman and Kurt-Dekker like this.
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,797
    Glad to hear it. I just posted in another thread how I'm always making errors too... it's annoying when you have an ad-hoc string tag like that where the compiler can't help you and say "I don't know what a Qeue is..."