Search Issue Tracker

Won't Fix

Votes

0

Found in

2019.4

2020.3

2020.3.0f1

2021.1

2021.2

Issue ID

1326869

Regression

No

[macOS] "Metal: cannot write to unused constant buffer." error is thrown when using UnityEngine.GL inside OnSceneGUI

Metal

-

How to reproduce:
1. Open the attached project's "case_1326869-Project.zip" Scene labeled "Test"
2. In the Hierarchy, select the "Test" GameObject
3. In the Inspector, enter "8" under "Vertices Num" field
4. Click the "Init" button
5. Move the mouse over the Scene View

Expected result: No errors or warnings are thrown and a line is drawn
Actual result: Nothing is drawn and a "Metal: cannot write to unused constant buffer." error and "Metal: Vertex shader missing buffer binding at index 0" warning is thrown

Reproducible with: 2019.4.24f1, 2020.3.3f1, 2021.1.2f1, 2021.2.0a12
Couldn't test with: 2018.4.34f1 (Package dependencies break the project)

  1. Resolution Note (2021.2.X):

    There is an error in the usage of GL class. As material is never set up, unity uses the last shader set, which, in case of scene view rendering, would be some builtin blit shader. The solution would be to setup the material, e.g.

    private void OnSceneGUI()
    {
    if(mat == null)
    {
    Shader shader = Shader.Find("Hidden/Internal-Colored");
    mat = new Material(shader);
    mat.hideFlags = HideFlags.HideAndDontSave;
    }

    mat.SetPass(0);
    <...>

    i copied this directly from https://docs.unity3d.com/ScriptReference/Material.SetPass.html

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.