U3D 日志、文本打印

来源:互联网 发布:港台电视直播软件app 编辑:程序博客网 时间:2024/06/03 19:02

1.  Debug.Log("hello");

2.  打开控制台查看日志:ctrl+shift+c

3. 输出一个位置的坐标(需要转换成字符串.ToString())

[cpp] view plain copy
  1. Vector3 worldPosition = hc.transform.TransformPoint(unityPosition);  
  2. Debug.Log("worldPosition" + worldPosition.ToString());  


4. 文本输出多个变量,需要用占位符
[cpp] view plain copy
  1. this.lbRightHandRotation.text = string.Format  
  2. ("Right Hand Rotation:{0},{0},{0}", h.Direction.Pitch.ToString() ,h.Direction.Yaw.ToString(), h.Direction.Roll.ToString());  


5. 文本打印(hour等是int类型)

[cpp] view plain copy
  1. time_text.text = hour.ToString() + "时" + min.ToString() + "分" + sec.ToString() + "秒";  

6. 如果使用using System.Diagnostics;

CS0104  'Debug' is an ambiguous reference between 'System.Diagnostics.Debug' and 'UnityEngine.Debug'

如果此时想要打印日志,直接用print(“打印”);

原创粉丝点击