UGUI源码调试

本文介绍如何从源码编译Unity GUI (UGUI)系统,并提供了详细的步骤指导,包括配置开发环境、构建项目、调试信息转换等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



How do I get started?

  • Clone this repository onto a location on your computer.
  • Configure your IDE for the Unity coding standard, look in the .editorconfig file for more information
  • Open the project in Visual Studio or MonoDevelop

    • If you are using MonoDevelop
      • Ensure you enable XBuild (Preferences -> Projects -> Build ->"Compile projects using MSBuild/XBuild")
      • You may need to restart MonoDevelop
    • Build the solution
  • A folder will be created in the root directory called "Output", the generated dll's will output here in the correct folder structure

    • If you wish to use these dll's
    • Locate your Unity install location
    • Windows: Copy the contents of Output folder to: Data\UnityExtensions\Unity\GUISystem\{UNITY_VERSION}
    • OSX: Copy the contents of Output folder to: Unity.app/Contents/UnityExtensions/Unity/GUISystem/{UNITY_VERSION}
  • If you want the dll's to copy automatically on build

    • For each visual studio project file
      • Open the file in a text editor
      • Locate the section: <Target Name="AfterBuild">
      • Follow the instructions in the comments



首先下载Unity4.6的正式版再到BitBucked拉取UGUI的代码

    注意如果之前有4.6的试用版的话,需要先把试用版卸载,因为它和BitBucked上最新的代码不兼容。

    然后用Unity4.6自带的MonoDevelop打开UISystem.sln解决方案,或者用VS studio2010以上的版本打开该解决方案。我选择的是后者

    打开解决方案后会看到三个工程

    

  • UnityEditor.UI工程:生成Edtior/UnityEditor.UI.dll,主要是包含各UGUI控件在Editor的Inspector功能。
  • UnityEngine.UI工程:生成Standalone/UnityEngine.UI.dll,主要是UGUI在发布包中使用的功能。
  • UnityEngine.UI-Editor工程:生成UnityEngine.UI.dll,主要是UGUI在编辑器中使用的功能。

    打开解决方案后什么都不用改,直接选择Build,构建项目。会在解决方案目录中生成名为Output的目录

    将这些文件直接覆盖到{UNITY安装路径}\Editor\ Data\UnityExtensions\Unity\GUISystem\{UNITY_VERSION}
    再重新启动Unity就可以使用你自己编译出来的UGUI了。

    不过在Unity中还是无法调试到UGUI的源代码中,因为刚刚编译出来的调试信息文件是pdb,而mono的调试信息文件是mdb。因此我们需要用pdb2mdb工具将它进行一次转换。
    转换工具是Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.0\pdb2mdb.exe

    用法是
    pdb2mdb 程序集名
    不过这里有一个坑,浪费了我很多时间,那就是pdb2mdb的工作路径要在要转换的程序集的路径下。因此我们先需要切换到Output目录下,进行如下操作

再把生成的mdb拷到Editor\Data\UnityExtensions\Unity\GUISystem\{UNITY_VERSION}下面,
之后就可以随心所欲地调试进UGUI的源码了。哇咔咔!

    

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值