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.驗證是否存在指定目錄/文件,創(chuàng)建目錄
using System.IO;
bool a=Directory.Exists(path);
bool b=file.Exists(path);
Directory.CreateDirectory(path);
5.設置鼠標貼圖/恢復默認貼圖
Cursor.SetCursor(mouseTex1, Vector2.zero, CursorMode.ForceSoftware);
Cursor.SetCursor(null, Vector2.zero, CursorMode.ForceSoftware);
6.重載當前場景
using UnityEngine.SceneManagement;
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
7.獲取當前對象同級的索引 / 將當前對象的同級索引設置為0
int index = target.transform.GetSiblingIndex();
target.transform.SetSiblingIndex(0);
————————————————
版權聲明:本文為CSDN博主「York_New」的原創(chuàng)文章,遵循 CC 4.0 BY-SA 版權協(xié)議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/York_New/article/details/78920943