
Unity
zlQ_
这个作者很懒,什么都没留下…
展开
-
ILSpy查看dll内容
今天用本地的ILSpy查看unity的dll文件内容,提示System.OutOfMemoryException: 引发类型为“System.OutOfMemoryException”的异常。印象中之前可以打开,可能是由于ILSpy版本过低无法正常解析dll从vs里下载最新的ILSpy,打开菜单栏工具->扩展和更新->联机,右侧输入框中输入ILSpy,搜索并下载安装,安装成功后重启vs重启vs后打开菜单工具->ILSpy即可打开最新的ILSpy工具将unity工程下的L原创 2022-02-23 10:35:31 · 4107 阅读 · 0 评论 -
Unity-Vector3打印结果不符合预期
近期在做游戏移植,把部分Unity的代码移植到laya上,发现laya上的表现跟Unity上有差异,debug了一番,最终找到可疑点,代码实现大致是函数内使用三次Random.Range,随机出三个值,做为Vector3的构造参数传入(new Vector3(值1,值2,值3)),然后返回Vector3,在c#中通过Debug.LogError打印返回的Vector3,打印出来的结果不符合预期,于是写了段测试代码,代码和运行结果如下图:代码结果预期结果是-0.1到0.1之原创 2021-05-13 19:34:12 · 893 阅读 · 7 评论 -
Unity--升级Android api level 28踩坑记录
背景:项目使用的Unity版本为5.4.4f1,AndroidtargetSdkVersion为22,接到通知要求targetSdkVersion要升级到28(至少为26)实践:直接将targetSdkVersion从22改为28,通过Unity Build生成android apk包,在不同手机上安装运行问题:在小米cc9e手机上,点击app图标后立即闪退,表现上没有任何提示定位:...原创 2019-09-10 14:40:05 · 6313 阅读 · 0 评论 -
Unity--使用反编译软件ILSpy查看dll中的代码
简介:ILSpy 是一个开源的.NET反编译工具,简洁强大易用是它的特征。在绝大多数情况下,它都能很好的完成你对未知程序集内部代码的探索。下载:https://pan.baidu.com/s/1UgSXEKWrU_1jWr5-wqfHtw新建Unity工程,编译PC平台,生成目录如下图进到CoroutineTest_Data\Managed目录,内容如下图下载ILSpy压缩...原创 2018-10-24 11:47:33 · 6105 阅读 · 1 评论 -
Unity--EditorGUI.ObjectField实现
记录下,以后可以有个参考绘制UI使用的是style.Draw(position, gUIContent, id, DragAndDrop.activeControlID == id);这个style其实就是EditorStyles.objectField有ObjectSelector.get.Show(obj, objType, property, allowSceneObjects)...原创 2018-10-25 18:52:36 · 3948 阅读 · 0 评论 -
Unity--编辑器模式下预览动画
原理:1.使用[ExecuteInEditMode]使得脚本在编辑器模式下可以执行到生命周期函数(Awake,OnDisable等等)2.OnEnable时注册EditorApplication.update回调,OnDisable时反注册EditorApplication.update回调3.使用Animator的Play函数切换动画,使用Animator的Update函数更...原创 2018-10-15 14:52:21 · 9905 阅读 · 0 评论 -
Unity--使用shader给角色描边异常
unity版本:Unity 2018.2.0f2 (64-bit)shader实现如下:// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'#pragma fragmentoption ARB_precision_hint_fastest#include "UnityC...原创 2018-09-29 16:22:49 · 1888 阅读 · 0 评论 -
Unity--PropertyAttribute和PropertyDrawer结合进行配置引用
应用场景,类中引用配置表中的技能id,代码如下图public class PropertyTest : MonoBehaviour{ public string prefabPath = ""; //配置表中的技能id public int skillId = 0;}Inspector中的显示如下图技能配置表如下图id为技能id,prefabP...原创 2018-09-26 11:52:52 · 2871 阅读 · 0 评论 -
Unity--PropertyAttribute和PropertyDrawer结合使用将string转为资源引用(优化)
using UnityEditor;using UnityEngine;[CustomPropertyDrawer(typeof(Reference))]public class ResReferenceDrawer : PropertyDrawer{ public override void OnGUI(Rect position, SerializedProperty pr...原创 2018-09-26 10:10:29 · 738 阅读 · 0 评论 -
Unity--PropertyAttribute和PropertyDrawer结合使用将string转为资源引用
代码如下:using UnityEngine;public class PropertyTest : MonoBehaviour{ public string prefabPath = "";}prefabPath表示引用的prefab路径,在Inspector中显示如下图这种情况需要手动填写prefab的路径,填错prefab路径程序运行就找不到prefab了,...原创 2018-09-26 09:49:39 · 1077 阅读 · 0 评论 -
Unity--泛型函数调用
using UnityEngine;public abstract class Animal{ public abstract void Walk(int step);}public class Dog : Animal{ public override void Walk(int step) { Debug.Log(string.Format...原创 2018-09-25 20:53:22 · 1124 阅读 · 0 评论 -
Unity--反射简单例子
using UnityEngine;using System.Reflection;using System;public class Base{ private int tag = 1; protected int tag1 = 2; public int tag3 = 3; public int TestGetSet1 { g...原创 2018-09-25 20:13:08 · 1281 阅读 · 0 评论