unity

unity EditorWindow拖入文件或文件夹

有些话、适合烂在心里 提交于 2019-12-01 23:27:57
将脚本放在Assets内的Editor文件夹里。 TestWindow.cs using UnityEngine; using UnityEditor; public class TestWindow:EditorWindow{ [MenuItem("Tools/TestWindow")] static void createTestWindow() { var window=EditorWindow.GetWindow<TestWindow>(false,"TestWindow"); window.minSize=new Vector2(400,400); window.Show(); } private void OnGUI() { if(Event.current.type==EventType.DragUpdated){ DragAndDrop.visualMode=DragAndDropVisualMode.Generic;//鼠标外观 }else if(Event.current.type==EventType.DragExited){ if(mouseOverWindow==this){//鼠标位于当前窗口 //Rect rect=EditorGUILayout.GetControlRect(); //rect.Contains(Event.current

Unity中的对象池

自闭症网瘾萝莉.ら 提交于 2019-12-01 23:01:10
namespace ObjectPool { public class GameObjectPool { public GameObjectPool.InitCallbackDelegate initCallback; private Dictionary<string, Queue<GameObject>> _pool; private Transform _manager; public GameObjectPool(Transform manager) { this._manager = manager; this._pool = new Dictionary<string, Queue<GameObject>>(); } public void Clear() { foreach (KeyValuePair<string, Queue<GameObject>> keyValuePair in this._pool) { foreach (GameObject go in keyValuePair.Value) GameObject.Destroy(go); } this._pool.Clear(); } public int count { get { return this._pool.Count; } } public GameObject GetObject

Unity 3D热更新知识入门小结之AssetBundle(1)

浪子不回头ぞ 提交于 2019-12-01 19:39:44
一、AssetBundle定义及作用 1. AssetBundle是一个压缩包,相当于一个文件夹,包含特定于平台的非代码的归档文件(模型、贴图、预制体、声音及场景 ),在游戏运行时候就会被加载。AssetBundle的文件是分为A serialized file和Resource files两类。 (1)A serialized file(序列化文件):资源被分解到它们各自的对象中,并写入到这个单个文件中。 (2)Resource files(资源文件):特定二进制资源(图片和声音)单独保存以便于加载。 2. AssetBundle能够表示相互间的依赖关系,其压缩包通常是采用LZMA和LZ4压缩算法,目的就是减少包的大小,从而可以满足更快网络速率的传输。 3. AssetBundles可以用来下载内容(DLC),加载针对使用用户平台的优化资产并减少运行时内存压力,即是减小安装包的大小。 二、AssetBundle使用流程 1. 流程 (1)指定资源的AssetBundle属性; (2)开始构建AssetBundle包; (3)上传AssetBundle包到相应的服务器; (4)用户游戏加载AssetBundle包及资源。 2. 代码打包方法 using UnityEditor; using System.IO; public class CreateAssetBundle { /

Unity EventSystem 详解(Unity Version 5.5.1)不是原创

假如想象 提交于 2019-12-01 19:29:49
nity EventSystem Message System Input Modules Supported Events Raycasters 1. Message System(改进的消息系统) 基本上可以看成是以前SendMessage的升级版。 使用方法(照抄官网): step1. 声明一个接口,继承自IEventSystemHandler public interface ICustomMessageTarget : IEventSystemHandler { // functions that can be called via the messaging system void Message1(); void Message2(); } step2. 实现这个接口 , 把这个脚本挂在某个物体上,这里假设为物体AAA public class CustomMessageTarget : MonoBehaviour, ICustomMessageTarget { public void Message1() { Debug.Log ("Message 1 received"); } public void Message2() { Debug.Log ("Message 2 received"); } } step3. 在任何脚本中使用 ExecuteEvents

Unity3D

女生的网名这么多〃 提交于 2019-12-01 16:12:22
参考资料 关于Unity协同程序(Coroutine)的全面解析 Unity之协程 来源: https://www.cnblogs.com/wangwangfei/p/11692243.html

unity UDP 发送与接收

孤人 提交于 2019-12-01 10:07:34
1 using System.Collections.Generic; 2 using System.Net; 3 using System.Net.Sockets; 4 using System.Text; 5 using System.Threading; 6 using UnityEngine; 7 using System; 8 9 public class UDPClient2Client : MonoBehaviour 10 { 11 public static UDPClient2Client Instance = null; 12 private UdpClient client; 13 private Thread thread = null; 14 private IPEndPoint remotePoint; 15 public string ip="127.0.0.1"; 16 private int port = 9090; 17 18 public Action<string> receiveMsg = null; 19 20 private string receiveString = null; 21 void Awake() 22 { 23 if (Instance == null) 24 { 25 Instance = this; 26

unity 获取本地ip地址

雨燕双飞 提交于 2019-12-01 10:05:51
1 using System.Collections; 2 using System.Collections.Generic; 3 using System.Net.NetworkInformation; 4 using System.Net.Sockets; 5 using UnityEngine; 6 7 public class Ip 8 { 9 public enum ADDRESSFAM 10 { 11 IPv4, IPv6 12 } 13 /// <summary> 14 /// 获取本机IP 15 /// </summary> 16 /// <param name="Addfam">要获取的IP类型</param> 17 /// <returns></returns> 18 public static string GetIP(ADDRESSFAM Addfam) 19 { 20 if (Addfam == ADDRESSFAM.IPv6 && !Socket.OSSupportsIPv6) 21 { 22 return null; 23 } 24 string output = ""; 25 foreach (NetworkInterface item in NetworkInterface.GetAllNetworkInterfaces()) 26 { 27

unity 使用xml创建外部配置文件

*爱你&永不变心* 提交于 2019-12-01 10:05:09
1 using System.Collections; 2 using System.Collections.Generic; 3 using UnityEngine; 4 using System.IO; 5 using System.Xml; 6 7 public class XmlManager 8 { 9 private string Path = Application.streamingAssetsPath + "/Config.xml"; 10 public static Dictionary<string, string> XmlData=new Dictionary<string, string>(); 11 //默认配置 12 private Dictionary<string, string> XmlDefault = new Dictionary<string, string> { 13 {"是否开启垂直同步,0关闭,1默认65Fps,2默认30FPS","0" }, 14 {"显示FPS","0" }, 15 {"限制FPS","65" }, 16 { "FPS字体大小","30"}, 17 { "屏幕宽", "1920 "}, 18 { "屏幕高", "1080 "}, 19 { "屏幕全屏", "0"}, 20 { "窗口化无边框","0"}, 21

我是如何一步步编码完成万仓网ERP系统的(四)登录的具体实现

烂漫一生 提交于 2019-12-01 07:58:15
   https://www.cnblogs.com/smh188/p/11533668.html(我是如何一步步编码完成万仓网ERP系统的(一)系统架构)    https://www.cnblogs.com/smh188/p/11534451.html (我是如何一步步编码完成万仓网ERP系统的(二)前端框架)    https://www.cnblogs.com/smh188/p/11535449.html (我是如何一步步编码完成万仓网ERP系统的(三)登录)    https://www.cnblogs.com/smh188/p/11541033.html (我是如何一步步编码完成万仓网ERP系统的(四)登录的具体实现)    https://www.cnblogs.com/smh188/p/11542310.html (我是如何一步步编码完成万仓网ERP系统的(五)产品库设计 1.产品类别)    https://www.cnblogs.com/smh188/p/11546917.html (我是如何一步步编码完成万仓网ERP系统的(六)产品库设计 2.百度Ueditor编辑器)    https://www.cnblogs.com/smh188/p/11572668.html (我是如何一步步编码完成万仓网ERP系统的(七)产品库设计 3.品牌图片跨域上传)   

unity 如何打开本地文件夹,并选中文件

梦想的初衷 提交于 2019-12-01 07:56:43
1 public static void OpenDirectory(string path, bool isFile = false) 2 { 3 if (string.IsNullOrEmpty(path)) return; 4 path = path.Replace("/", "\\"); 5 if (isFile) 6 { 7 if (!File.Exists(path)) 8 { 9 Debug.LogError("No File: " + path); 10 return; 11 } 12 path = string.Format("/Select, {0}", path); 13 } 14 else 15 { 16 if (!Directory.Exists(path)) 17 { 18 Debug.LogError("No Directory: " + path); 19 return; 20 } 21 } 22 //可能360不信任 23 System.Diagnostics.Process.Start("explorer.exe", path); 24 } 来源: https://www.cnblogs.com/AaronBlogs/p/11671145.html