- Home /
How to see mesh in game mode ?
Hello everyone,
I'd like to see the mesh in-game mode,
I mean, i'd like to see exactly what i see when i'm overviewing my scene in ShadedWireframe mode, but in the game mode.
Is it possible to do this with option(s) in Unity3D or do i have to code it myself ?
If i actually have to code it myself, this is not a problem, but can you give me some tips because i have no idea about the path to follow.
Here is a picture about what i see in my scene mode and i my game mode, and i'd like to see the same thing in game mode that in scene mode.
Thx you for your futur answers,
Ps : Sorry for my bad english, this isn't my native langage.
Answer by ReCoF · Apr 10, 2015 at 12:25 PM
Thank you for you answer !
Actually, i find the solution right before you answered me.
So in order to help people which the same problem than me, here is the solution : I created the following script : "ShadedWireframe"
public class ShadedWireframe : MonoBehaviour {
void OnPreRender() {
GL.wireframe = true;
}
void OnPostRender() {
GL.wireframe = false;
}
}
And you have to associate it to the camera.
Be careful, because it doesn't work if you associate this script to your object.
After, that you don't have to do anything else.
The only things that can be a little bit annoying is the fact that you also see the mesh of the skybox.
I hope it will help someone.
Answer by chmodseven · Oct 12, 2018 at 09:22 AM
I came across this thread while trying to solve this myself, and while the solution works well the first time you apply it, I wanted it to be toggleable and ran into an issue where wireframe mode would not display properly after the first time. Eventually I solved it, so here's a toggleable version (press "Z", in this example, or alter the isInWireframeMode variable in the Inspector or via code) that might help someone else down the track.
It doesn't need two cameras or depth setting hacks like other solutions I've seen - just attach to the regular camera. You can set your own preferred background color for the wireframe mode in the inspector if you don't want black, although the white for the foreground lines apparently can't be changed without digging into GL code more extensively. Enjoy!
using UnityEngine;
[RequireComponent (typeof (Camera))]
public class WireframeViewer : MonoBehaviour
{
public Color wireframeBackgroundColor = Color.black;
public bool isInWireframeMode;
private Camera cam;
private CameraClearFlags origCameraClearFlags;
private Color origBackgroundColor;
private bool previousMode;
private void Start ()
{
cam = GetComponent<Camera> ();
origCameraClearFlags = cam.clearFlags;
origBackgroundColor = cam.backgroundColor;
previousMode = isInWireframeMode;
}
private void Update ()
{
if (Input.GetKeyDown (KeyCode.Z))
{
isInWireframeMode = !isInWireframeMode;
}
if (isInWireframeMode == previousMode)
{
return;
}
previousMode = isInWireframeMode;
if (isInWireframeMode)
{
origCameraClearFlags = cam.clearFlags;
origBackgroundColor = cam.backgroundColor;
cam.clearFlags = CameraClearFlags.Color;
cam.backgroundColor = wireframeBackgroundColor;
}
else
{
cam.clearFlags = origCameraClearFlags;
cam.backgroundColor = origBackgroundColor;
}
}
private void OnPreRender ()
{
if (isInWireframeMode)
{
GL.wireframe = true;
}
}
private void OnPostRender ()
{
if (isInWireframeMode)
{
GL.wireframe = false;
}
}
}
Answer by Cherno · Apr 09, 2015 at 04:53 PM
You need a wireframe shader for that. Google is your friend :)