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
- If you are using MonoDevelop
-
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
- For each visual studio project file
首先下载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的源码了。哇咔咔!