unity学习18:unity里的 Debug.Log相关
目录
2 用Debug.DrawLine 和 Debug.DrawRay画线
1 unity里的 Debug.log相关
除了常用的 Debug.Log,还有另外2个
- Debug.Log("Debug.Log");
- Debug.LogWarning("Debug.LogWarning");
- Debug.LogError("Debug.LogError");
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class debugTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Debug.Log");
Debug.LogWarning("Debug.LogWarning");
Debug.LogError("Debug.LogError");
}
// Update is called once per frame
void Update()
{
}
}
2 用Debug.DrawLine 和 Debug.DrawRay画线
2.1 画线
- Debug.DrawLine(new Vector3(290,90,100),new Vector3(290,100,100),Color.blue);
- DrawLine( 起点坐标,终点坐标)
- Debug.DrawRay(new Vector3(290,90,100),new Vector3(290,100,100),Color.red);
- DrawRay( 起点坐标,方向)
- 其实方向,也就是这里的Vector3(290,100,100) 是指
- Vector3(0,0,0) 到Vector3(290,100,100)的方向,把起点从Vector3(0,0,0)挪到Vector3(290,90,100)这里来形成的一个新射线
- 这么详细解释下
- step1: 有一个向量Vector3(290,100,100), 画出来,Vector3(0,0,0) → 指向Vector3(290,100,100), 图上的红色箭头
- step2:然后把这个向量挪动,方向不变,起点挪动到Vector3(290,90,100) 这里来,生成了图上红色的细线
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class debugTest : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
Debug.Log("Debug.Log");
Debug.LogWarning("Debug.LogWarning");
Debug.LogError("Debug.LogError");
}
// Update is called once per frame
void Update()
{
Debug.DrawLine(new Vector3(290,90,100),new Vector3(290,100,100),Color.blue);
Debug.DrawRay(new Vector3(290,90,100),new Vector3(290,100,100),Color.red);
}
}
2.2 调试的东西只会出现scene窗口,不会出现在game窗口
- 调试的东西只会出现scene窗口,不会出现在game窗口
- 比如上面的画线
原文地址:https://blog.csdn.net/xuemanqianshan/article/details/145145206
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!