This question was
closed Oct 28, 2016 at 02:07 PM by
Landern.
Question by
susanto23_ · Oct 28, 2016 at 10:05 AM ·
unity 5drawline
drawline can't display game? give me a solution
private const float TILE_SIZE = 1.0f;
private const float TILE_OFFSET = 0.5f;
private int selectionX = -1;
private int selectionY = -1;
private void Update(){
PapanCatur ();
UpdateSelection ();
}
private void UpdateSelection ()
{
if (!Camera.main)
return;
RaycastHit hit;
if (Physics.Raycast (Camera.main.ScreenPointToRay (Input.mousePosition), out hit, 25.0f, LayerMask.GetMask ("ChekersPlane"))) {
selectionX = (int)hit.point.x;
selectionY = (int)hit.point.z;
} else {
selectionX = -1;
selectionY = -1;
}
}
private void PapanCatur(){
Vector3 widthLine = Vector3.right * 8;
Vector3 heightline = Vector3.forward * 8;
for(int i = 0; i<=8; i++){
//debug.drawline cant display in game unity
Vector3 start = Vector3.forward * i;
Debug.DrawLine (start, start + widthLine,Color.yellow,0.0f, true);
for (int j = 0; j <= 8; j++) {
start = Vector3.right * j;
Debug.DrawLine (start, start + heightline,Color.yellow,0.0f,true);
}
}
//draw the selection
if (selectionX >= 0 && selectionY >= 0) {
Debug.DrawLine (
Vector3.forward * selectionY + Vector3.right * selectionX,
Vector3.forward * (selectionY + 1) + Vector3.right * (selectionX + 1));
Debug.DrawLine (
Vector3.forward * (selectionY + 1 ) +Vector3.right * selectionX,
Vector3.forward * selectionY + Vector3.right * (selectionX + 1));
}
}
}
Comment
You haven't asked a question, nor supplied a problem. Please expand.
Sorry, in this case. I can't display after i play in the unity. I think have a proble in debug.drawline,
Have you made sure that Gizmos are enabled in play mode? They aren't by default and are necessary for Debug.DrawLine to work.
what is Gizmos? i don't know.. how to enable Gizmos in play mode?