![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C#
Zhac
菜菜菜
展开
-
Lua读取C#中的List出现的错误LuaException: try to get System.Collections.Generic.List`
情况是我想要把C#的List传入Lua的一个表中,但是一直报错LuaException: try to get System.Collections.Generic.List`for k,v in ipairs(newFighters) do print(k) print(v.xPos) --table.insert(fighters2,{xPos = v.xPos,yPos = v.yPos,groupId =num,groupName = v.groupName,cam原创 2020-05-28 11:25:11 · 1343 阅读 · 0 评论 -
C#中遍历hash表的四种方法
using System;using System.Collections; namespace HashtableExample{ class Program { static Hashtable hashtable = new Hashtable(); static void Main(string[] args) { hashtable.Add("first","Beijing"); hashtable.Add("second","Sh.转载 2020-05-28 10:17:51 · 3029 阅读 · 2 评论 -
Unity 加载ToggleGroup下激活的Toggle
IEnumerable<Toggle> toggleGroup = this.transParent.Find("ScrollViewMask").Find("Content").GetComponent<ToggleGroup>().ActiveToggles(); foreach (var toggle in toggleGroup) { debug.log(toggle) }...原创 2020-05-27 21:16:19 · 1238 阅读 · 0 评论 -
Unity 判断物体是否含有子物体
if (GetComponentsInChildren<Transform>(true).Length <= 1){ Debug.Log("没有子物体");}这个方法是查询物体下含有多少个transform,需要注意的是因为物体本身也含有transform,所以在计算的时候要<=1原创 2020-05-27 09:53:45 · 5568 阅读 · 0 评论 -
添加xLua到项目中和遇到的一些坑
目录1、添加xLua 2、注意事项 3、我遇见的一些坑即解决方法1、添加xLua 在GitHub中下载腾讯xLua的最新版本 把Asset文件夹下的四个文件和Tools文件夹添加到项目中 在项目的Player Setting中添加宏 HOTFIX_ENABLE 把Unity安装目录下的3个dll文件加入刚才导入项目的xLua中 导入dll文件F:\Unity\Editor\Data\Managed Unity.Cecil.dll Uni...转载 2020-05-23 12:16:21 · 3863 阅读 · 0 评论 -
Unity UGUI Button鼠标的悬停事件(利用重写unity中的button来实现)
using UnityEngine;using System.Collections;using UnityEngine.UI;using UnityEngine.EventSystems;public class LearnButton : Button { /// /// 配合Unity的其他方法使用,就能达到你想要的效果!这里只是抛砖引玉,大家有更好...转载 2020-04-30 19:58:20 · 5000 阅读 · 0 评论 -
Unity UGUI获取鼠标在屏幕的准确点击位置
想要获取鼠标在屏幕的准确点击位置,千万不要胡乱写,什么转化坐标系,什么Ray射线检测都是浮云。1,转化坐标系只是相对而言,并不能准确实现当前鼠标点击在屏幕的位置;2,Ray检测,hit是需要碰撞的,没碰撞,获取的是什么??(0,0,0)。所以,请看如下正解。第一种:我用坐标系转化时发现值并没有什么变化,网上乱七八糟的都有。其实很简单,Input.mousePosition本...转载 2020-04-30 11:03:07 · 5413 阅读 · 0 评论 -
Unity获得当前选中的物体(比如ToggleGroup中的一个按钮)
某些情况下,unity场景中存在大量按钮的时候,当我们的点击某个按钮的时候需要同时获得点击的是哪个按钮,但是呢,本人又比较懒,最讨厌那种大量的一个一个的AddListener,所以呢,查阅了Unity的文档之后发现,有这么一个神奇的东西UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject这是一个只读的,...转载 2020-04-29 15:58:50 · 3999 阅读 · 0 评论 -
C#对象转换为Json格式
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.ServiceModel;using System.ServiceModel.Web;using System.IO;using System.Runtime.Serialization.Jso...转载 2020-04-23 16:05:27 · 3202 阅读 · 0 评论 -
C#对于文件的读写
1.File类写入文本文件:private void btnTextWrite_Click(object sender, EventArgs e) { //文件路径 string filePath = @"E:\123\456.txt"; //检测文件夹是否存在,不存在则创建 N...转载 2020-04-23 16:02:56 · 468 阅读 · 0 评论