Unity 代码判断运行平台 void Awake() { #if UNITY_ANDROID Debug.Log("这里安卓设备"); #endif #if UNITY_IPHONE Debug.Log("这里苹果设备"); #endif #if UNITY_STANDALONE_WIN Debug.Log("电脑上运行o"); #endif }switch (Application.platform)
DOTween 使用方法 using UnityEngine;using System.Collections;using DG.Tweening;using UnityEngine.UI;public class TestDoTween : MonoBehaviour { int number = 0; // Use this for initialization void Start () { //FunctionOne(); //FunctionTw
Unity 协程 yield return的使用 public void Start() { //开启协程 Coroutine testCoroutine = StartCoroutine(Test()); //停止指定协程 StopCoroutine(testCoroutine); //协程可以同时开启多个 StartCoroutine("Test"); //经实测,S
Unity3D Texture2D转换成Sprite格式 Sprite sprite = Sprite.Create(texture2d, new Rect(0, 0, 64, 64), Vector2.zero);
在Unity Inspector中显示class变量 通过Unity Inspector,我们能够很方便的给脚本中变量赋值。变量要在Inspector中显示,需要满足下面两个条件:变量是内置类型的,比如float, string, int, double类型的变量变量访问限制为public例如如下脚本:using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public float f; //
Unity3D Base64和Texture2D互相转换 //Base64转Texture2Dpublic Texture2D Base64ToTexture2D(string Base64STR){Texture2D pic = new Texture2D(190, 190, TextureFormat.RGBA32, false);byte[] data = System.Convert.FromBase64String(Base64STR);pic.LoadImage(data);return pic;}//Texture2D转Base64
Unity 获取文件夹下所有文件夹/文件 //Directory.GetDirectories(dir) 得到路径为dir的文件夹下面的所有文件夹以及路径 foreach (string pathString in Directory.GetDirectories(foldPath)) { //删除文件夹 Directory.Delete(pathString, true); } //Directory.GetFiles(dir) ...
python 进制转换 pyhton学习表示二进制 0b+数字 输入 0b10 输出2表示八进制 0o+数字 输入 0o10 输出8表示八进制 0x+数字 输入 0x10 输出16进制转换bin(10) 把其他进制转为二进制int(0b11) 把其他进制转为十进制hex(888) 把其他进制转为十六进制oct(0b111) 把其他进制转为八进制...
Unity3d 分辨率 注册表设定 打包Unity项目的时候设置了无边框全屏,第二次打包设置了窗口,却发现它依然用无边框全屏模式运行。上网查了一个下,说是第一个运行的时候,注册了注册表信息,只要删除注册表信息,让它重新注册一次就行。首先打开注册表,使用快捷键“Win”+ 【R】组合快捷键。在打开后面键入命令:Regedit然后按照路径找到该注册表HKEY_CURRENT_USER\Software\ [CompanyName] \ [ProductName]CompanyName 是打包里的公司名ProductName 是打包里
Unity windows10环境下 语音识别 最近一直在弄一个实时语音识别的功能,上网查资料的时候才发现unity现在已经有了自带的语音识别的接口https://docs.unity3d.com/2019.3/Documentation/ScriptReference/Windows.Speech.DictationRecognizer.htmlusing System.Collections;using System.Collections.Generic;using UnityEngine;using UnityEngine.Window
Unity Hex与Color之间进行颜色转换 using System.Collections;using System.Collections.Generic;using System.Globalization;using UnityEngine;public enum ColorType{ RGB, RGBA}public class ColorAlgorithmConversion : MonoBehaviour { private const string hexRegex = "^#?(?.
Unity 模拟按键 using UnityEngine;using System.Collections;using System.Runtime.InteropServices;public class KeybdEvent : MonoBehaviour { [DllImport("user32.dll", EntryPoint = "keybd_event")] public static extern void Keybd_event( byte bvk,//.
Unity 视频播放器插件 AVPro Video 部分功能 转载链接:https://www.cnblogs.com/mrmocha/p/8087389.htmlusing System.Collections;using System.Collections.Generic;using RenderHeads.Media.AVProVideo;using UnityEngine;using UnityEngine.UI;//控制视频播放类public class VideoController : MonoBehaviour{ //持有控
Unity 2018版本 获取本机ip Network.Player.ipAddress这个API在Unity2018被移除了用如下代码using System.Net;using System.Net.NetworkInformation;using System.Net.Sockets;using UnityEngine;public class IPManager{ public static string GetIP(ADDRESSFAM Addfam) { //Return null if
Unity 读取解析Json 文件 Unity 读取Json文件,可以用Unity自带的json解析,也可以用外部的。Json 引用文件:LitJson.dll 放入Unity项目目录中使用在线Json工具快速创建一个Json: https://www.sojson.com/然后保存到本地,放入Unity目录中的StreamingAssets文件夹然后将json转成C#实体类最后是代码部分using LitJson;using System.Collections;using System.Collections.
C# CRC16 MODBUS 校验 public byte[] GetCRC16(string content) { byte[] bytes = Encoding.UTF8.GetBytes(content); byte[] crc16 = CRC16(bytes); return crc16; } public byte[] CRC16(byte[] bytes) { int length = bytes.Length; ..