本文将记录Unity开发中遇到的一些简单语法,用于存档方便以后查看,持续更新中。。。
1.获取当前时间并且按固定格式显示
System.DateTime now = System.DateTime.Now;
Debug.Log(now.ToString("yyyy/MM/dd hh:mm:ss"));
2.获取本机IP地址/Mac地址
ipAddress = Network.player.ipAddress;
using System.Net.NetworkInformation;
NetworkInterface[] nis = NetworkInterface.GetAllNetworkInterfaces();
macAddress=nis[0].GetPhysicalAddress();
3.获取当前应用界面的截图
Application.CaptureScreenshot("screen.png");
4.验证是否存在指定目录/文件,创建目录
using System.