I’m trying to make an editor, which shows a procedurally created mesh in the scene view, which is part of an EditorWindow module I’m writing.
What I do
To enable a OnSceneGUI function for this code, I’m using the
SceneView.onSceneGUIDelegate += OnSceneGUI;
which allows an OnSceneGUI function to be called.
In this function, I use the following call to render a mesh with a specified material:
Graphics.DrawMesh( TestMesh, Vector3.zero, Quaternion.identity, MeshMaterial, 0);
Please note the MeshMaterial is a predefined material, which is just a simple diffuse one.
Now, it seems like this causes my mesh to be rendered anew each time the OnSceneGUI is called, and if I put in a boolean check to only call it once it stays (and does not slow down my view of the scene).
Also, I don’t know how to make it disappear again.
Can anyone point me in the direction I should have taken to make this work properly?