
C#
BuladeMian
该博客所用图片资源均作学习分享用途,请勿用于商业行为。传播者自负。如果本博客所写文章侵犯到您的权益,请主动联系留言,我们将及时删除相关内容。请支持使用正版软件。
展开
-
[Unity][ILRuntime][C#]热更新运行官方示例U3D项目报错
下载项目,项目版本Unity 2020unity 2019.4.19f1c1报错Library\PackageCache\com.unity.collab-proxy@1.3.9\Editor\UserInterface\Bootstrap.cs(23,20): error CS0117: 'Collab' does not contain a definition for 'ShowChangesWindow'Project视图搜索Bootstrap,属于Unity Collab..原创 2021-11-02 14:07:56 · 3174 阅读 · 0 评论 -
[Unity][ILRuntime][C#]从零开始接入热更新
参考资料:1.ILRuntime Unity热更新2.从零开始 — ILRuntime (ourpalm.github.io)3.unity python热更新_Unity C#热更新方案 ILRuntime学习笔记(一) Hello World4.原创 2021-11-02 13:57:03 · 958 阅读 · 1 评论 -
[Unity]通过设置MeshRender的uv来显示图片的帧动画
3d物体的仅Quad可用。如果用其他3D物体,会报错Mesh.uv is out of bounds. The supplied array needs to be the same size as the Mesh.vertices array..../// <summary> /// Sets the frame. /// </summary> /// <param name="frame">Frame.</p..原创 2021-10-27 17:17:15 · 1117 阅读 · 0 评论 -
[Unity][ILRuntime]热更新和MonoBehaviour延迟或每秒执行几种方法
协程UpdateInvoke和InvokeRepeatingSystem.Timers.Timer相关资料:1.[Unity][C#][ILRuntime]热更新执行倒计时2.3.参考资料:1.Unity延时方法Invoke和InvokeRepeating2.3.原创 2021-09-30 10:34:37 · 524 阅读 · 0 评论 -
[Unity]根据自身旋转角度获得 矢量
... GameObject g = new GameObject(); g.transform.position = trans1.transform.position; g.transform.rotation = trans1.transform.rotation; Vector3 vec3 = g.transform.forward; Debug.Log(" g.transform.eulerAngle...原创 2021-09-29 14:18:10 · 636 阅读 · 0 评论 -
[Unity][C#]for循环update和广播哪个对所有子物体的速度更快
A物体-B物体-B物体-B物体-B物体...for循环A.cs... for (int i = 0; i < listchilds.Count; i++) { listchilds[i].test(); }...B.cs...public void test(){...}...updateB.cs... p...原创 2021-09-25 15:09:11 · 257 阅读 · 0 评论 -
[C#]比较两个时间的差值
...using System;... public DateTime start;//开始时间 public DateTime end;//结束时间... start = DateTime.UtcNow;... end = DateTime.UtcNow; TimeSpan ts = TimeManager.converTime_long((end.Ticks - start.Ticks)/10000000);.....原创 2021-09-09 16:41:01 · 732 阅读 · 0 评论 -
[Unity][C#]可变参数object形参传递参数强制转换问题
System.object能放什么类型,好像什么类型都可以。通过可变参数params object[] paramsList传递一个string或者多个...test2("dd");test2("aa","bb","cc");...paramsList = (object[])o;//强制类型 不一定生效.会被转成 string而不是string[]paramsList = o as object[];//这样才生效,必定会转换为string[].....原创 2021-09-06 09:20:44 · 1419 阅读 · 0 评论 -
[Unity]PlayerPrefs保存复杂的数据
把要保存的数据写成一个JSON类,里面放一些数组之类的变量。然后用json的方法,转换成字符串。相关资料1然后通过PlayerPrefs.SetString保存数据。如果不想让这些 数据暴露,把这个要保存到PlayerPrefs的字符串进行加密。相关资料5。读取的时候,通过PlayerPrefs.GetString,获得一个加密后的字符串,解密,再通过JSON读取解密后的字符串,直接就转换 成了 数据类。相关资料:1.[Unity][JSON]数据类保存为字符串2..原创 2021-08-30 16:47:12 · 656 阅读 · 0 评论 -
[Unity][C#][ILRuntime]热更新执行倒计时
KeyNotFoundException: Cannot find Delegate Adapter for:TimeManager.OnTimedEvent(Object source, ElapsedEventArgs e), Please add following code:appdomain.DelegateManager.RegisterMethodDelegate<System.Object, System.Timers.ElapsedEventArgs>();...原创 2021-08-20 09:59:13 · 600 阅读 · 0 评论 -
[Unity]update每秒执行
... float time = 0;//记录已经经过多少秒... void Update() { time += Time.deltaTime; if (time >= 1f)//一秒 { time = 0; Debug.Log("测试update的调用 到了一秒"); }// Debug.Log("测试update的调用 "+Time.de...原创 2021-08-19 16:25:07 · 2929 阅读 · 1 评论 -
[Unity][C#]合并两个有序数组为一个有序数组
...using System.Collections;using System.Collections.Generic;using UnityEngine;... private List<int> list_A = new List<int>() { 1,3,5,7,9 }; private List<int> list_B = new List<int>() { 2,4,6...原创 2021-08-13 18:00:25 · 1349 阅读 · 0 评论 -
[FairyGUI][Unity][C#]FGUI获得鼠标悬浮点击当前对象
...using FairyGUI;... Stage.inst.onClick.Add(btnClick);//鼠标点击 //Stage.inst.onTouchMove.Add(btnClick);//鼠标悬浮... private void btnClick(EventContext context) { //Debug.Log("click :1:" + (GObject)context.sender);//Stage...原创 2021-08-11 14:17:33 · 2049 阅读 · 0 评论 -
[Unity][Android][C#]Object关键字错误不能识别
由于Unity编辑器 传递参数 到Android 的 变量 不一样,因此要保证一样。是System.Object小写object写成System.Object[] args是可以的大写Object写成这样是可以的UnityEngine.Object[] args原创 2021-08-03 14:29:23 · 262 阅读 · 0 评论 -
[C#]可变参数数组传递
a.class...public static void test1(params object[] args)//params可变参数数组关键字{ ...Debug.Log("可变参数数组");if(args.Length > 0){ for(int i=0;i < args.Length;i++){Debug.Log("可变参数数组 i:"+i+"/"+args[i]);}} ...}...b.class... p..原创 2021-08-03 14:23:17 · 493 阅读 · 0 评论 -
[Unity][FairyGUI]设置组件GComponent隐藏
...GComponent gc = gos[i].asCom.GetChild("n29").asCom; //gc.visible = false; gc.scale = Vector2.zero;...原创 2021-07-30 10:31:09 · 1057 阅读 · 0 评论 -
[Unity][C#][ILRuntime]热更新中使用update倒计时
...class test : IRLMonoBehaviour{... //主工程调用到热更新层 OnAwake protected override void OnAwake() { ... //加入update注册 ILRuntimeWrapper.Instance.RegistUpdate(Update); ... } //主工程调用到热更新层 OnClose public overri...原创 2021-07-27 11:07:40 · 495 阅读 · 0 评论 -
[Unity][C#]Regex正则表达式判断字符串
...using System.Text.RegularExpressions;//...void Start() {... IsValidEmail("你好"); IsValidEmail("の"); IsValidEmail("丶"); IsValidEmail("✎©"); IsValidEmail("✎©123"); IsValidEmail("safd✎DF©123"...原创 2021-07-23 15:59:04 · 2151 阅读 · 1 评论 -
[Unity][ILRuntime][C#]热更新中数组Dictionary通过value获得key
KeyNotFoundException: Cannot find Delegate Adapter for:scienceTree/<>c__DisplayClass15_0.<click>b__1(KeyValuePair`2 q), Please add following code:appdomain.DelegateManager.RegisterFunctionDelegate<System.Collections.Generic.KeyValuePair&...原创 2021-07-21 17:53:36 · 632 阅读 · 1 评论 -
[Unity][FairyGUI]获得按钮事件用控制器播放动画
... void Start() { FairyGUI.UIPanel view = GetComponent<FairyGUI.UIPanel>();//Unity物体名称UIPanel GComponent mainview = view.ui;//获得FairyGUi对象 GComponent ROO1 = mainview.GetChild("label_task_01").asCom;//FairyGU...原创 2021-07-09 17:55:43 · 834 阅读 · 1 评论 -
[Unity][C#][NGUI]按钮点击事件避免重复添加委托
UIButton是NGUI的按钮脚本,UGUI同理。... public static void AddBtnOnclick_1(UIButton btn, EventDelegate ev) { if (btn != null) { Debug.Log(" AddBtnOnclick_1 :" + btn.name + " ev:" + ev.ToString()); btn.onClick..原创 2021-07-09 10:59:00 · 659 阅读 · 0 评论 -
[Unity][C#]如何快速获得一个浮点变量的整数和小数点部分
... float f = 2.556468f; int i_1 = (int)f; float f_1 = f-i_1;...原创 2021-07-07 19:57:21 · 2263 阅读 · 2 评论 -
[Unity][ILRuntime][C#]重复添加委托事件问题
...EventDelegate.Add(btn_.onClick, testClick);//重复添加...void testClick(){...}...类似这样的代码逻辑重复添加,直接卡死原创 2021-07-07 11:45:16 · 552 阅读 · 0 评论 -
[Unity][JAVA]与服务器时间比较
从服务器中获取的是一个long的变量,单位是秒。与服务器时间比较就得用.../// <summary> /// 获取时间戳 /// </summary> /// <returns></returns> public static string GetTimeStamp() { TimeSpan ts = DateTime.UtcNow -..原创 2021-06-30 17:48:42 · 143 阅读 · 0 评论 -
[Unity]同时加载多场景根目录物体查找管理
同一个场景,同时加载多个场景,并快速查找其他场景的根目录物体。新建2个场景test1,test2场景test1场景test2SceneControl_test1using UnityEngine;using UnityEngine.SceneManagement;public class SceneControl_test1 : MonoBehaviour{ private void Awake() { Scene scene...原创 2021-06-29 16:11:54 · 1107 阅读 · 3 评论 -
[Unity][射线检测]3DNGUI与地图场景中物体重合
有的时候 3DNGUI 用于 地图场景 的一些 3DUI 显示。但是会出现BUG。... void Update() { if (UICamera.hoveredObject != null) { Debug.Log(" UICamera.hoveredObject: " + UICamera.hoveredObject); return;//如果 悬浮NGUI 不为 空,则 不进行 射线检测..原创 2021-06-26 11:54:00 · 298 阅读 · 1 评论 -
[Unity][C#][ILRuntime]Dictionary嵌套错误
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.System.Reflection.TargetInvocationExcepti...原创 2021-06-26 11:28:36 · 2111 阅读 · 0 评论 -
[Unity][ILRuntime]VS热更新Debugger调试工具
参考资料:1.ILRuntime学习——从零开始2.3.原创 2021-06-23 16:59:08 · 2034 阅读 · 5 评论 -
[Unity]Object of type ‘ILRuntime.Runtime.Intepreter.ILTypeInstance‘ doesn‘t match target type ‘Unity
Object of type 'ILRuntime.Runtime.Intepreter.ILTypeInstance' doesn't match target type 'UnityEngine.Collider'原创 2021-06-23 10:07:14 · 667 阅读 · 1 评论 -
[Unity][ILRuntime]热更新委托调用OnTriggerEnter
Unity项目中在要调用的物体上,含有碰撞体组件,以其设置其IsTrigger为真。using System.Collections;using System.Collections.Generic;using UnityEngine;public class ColliderDetect : MonoBehaviour{ // Start is called before the first frame update public delegate void...原创 2021-06-21 17:24:01 · 431 阅读 · 0 评论 -
[Unity]移除物体的所有组件
预制体的无效组件,只能 手动 移除原创 2021-06-19 11:09:50 · 1617 阅读 · 2 评论 -
[Unity][ILRuntime]热更新Cannot find ValueTypeBinder for type:UnityEngine.Vector3
不知道为什么 就是用不了 这个 V原创 2021-06-17 15:20:15 · 421 阅读 · 1 评论 -
[Unity]跨场景查找物体
参考资料:1.unity加载场景时的回调函数2.3.原创 2021-06-16 17:32:01 · 2369 阅读 · 1 评论 -
[Unity][ILRuntime]热更新缺失引用
找到 re原创 2021-06-16 15:41:21 · 355 阅读 · 0 评论 -
[Unity].csproj文件中文乱码
用记事本方式打开,另存为UTF-8格式的wenj原创 2021-06-16 15:36:59 · 298 阅读 · 0 评论 -
[Unity][C#]TimeSpan时间自减
相关资料:1.2.原创 2021-06-16 11:32:30 · 1109 阅读 · 0 评论 -
[Unity][C#]秒数快速转换天小时分钟
...using System;...void Start() { changeTime(3670); } /// <summary> /// 改变 秒数 为 时间 /// </summary> /// <param name="second"></param> public void changeTime(int second_) { ...原创 2021-06-11 16:59:44 · 1051 阅读 · 0 评论 -
[Unity][C#]给函数形参赋值会怎么样
using System.Collections;using System.Collections.Generic;using UnityEngine;public class testFunction : MonoBehaviour{ // Start is called before the first frame update void Start() { test("123"); test(null); ...原创 2021-06-10 14:24:54 · 408 阅读 · 0 评论 -
[Unity][NGUI]呼吸灯
两个灯一个灯原创 2021-06-07 11:41:47 · 523 阅读 · 1 评论 -
[Unity][JSON]分割字符串并添加字典Dictionary的成员
...using System.Collections.Generic;... public static void StringToDictionary(Dictionary<int,int> d_,string str_) { int x1 = 0, x2 = 0; string[] strArray = str_.Split(';'); Debug.Log("???? ...原创 2021-06-05 15:11:38 · 368 阅读 · 1 评论