1
我正在Unity中进行我的第一个游戏。我试图在我的游戏领域画线。 我有一个线颜色的问题,但现在它解决了(How to set correct color to lines?)构建不正确的线条颜色
但是,当我建立我的游戏,并运行它,我再次看到粉红色的林。
请注意,在Unity编辑器的游戏窗口中一切正常。
我的代码:
private void DrawLine(Vector3 start, Vector3 stop, GameObject template)
{
GameObject toInstiateGridLine = template;
GameObject gridLineInstance = Instantiate(toInstiateGridLine, start, Quaternion.identity) as GameObject;
LineRenderer gridLineRenderer = gridLineInstance.GetComponent<LineRenderer>();
gridLineRenderer.material.color = Color.black;
gridLineRenderer.SetVertexCount(2);
gridLineRenderer.SetWidth(0.01f, 0.01f);
gridLineRenderer.SetColors(Color.black, Color.black);
gridLineRenderer.SetPosition(0, start);
gridLineRenderer.SetPosition(1, stop);
}
您是否检查了项目图形设置以确保着色器(来自其他问题的答案)包含在内? – 31eee384
您是否沿着使用旧版本脚本的方式创建了新场景?你可能没有构建你想要的场景。 – Draco18s
@ 31eee384我不使用Material mat = new Material(Shader.Find(“Unlit/Texture”));我使用: gridLineRenderer.material.color = Color.black; –