FairyGUIPackages与Code Auto管理
官网宏定义https://docs.unity3d.com/Manual/PlatformDependentCompilation.html
官方文档https://docs.unity3d.com/Manual/index.html
UnityEdtor的完善工作(离线文档的下载与使用)
需要重新开发UnityEditor的UI自动话工具:包括代码生成/提交Svn/打开协议文档/生成协议/打开离线文档/打开FairyGUI工程和目录
根据代码模版生成代码,模版文件×××.template
还状态刷新需要更新的UnityEditor工具。(可由Python代替)
自动生成UI模块代码
- 列出所有UI的模块
- 能够判别UI模块那些被修改了
- 通过模板生成引用代码 通过继承来扩展(通过对修改关闭,扩展打开)
- 直接提交修改代码
- 新的模块能够创建基本文件
自动生成配表代码
- 解析Excel文档
- 能够判别那些文件被修改了
- 通过字段方式生成相应程序能够引用的格式
代码
class UICodeEditor
{
}
[MenuItem("Tools/AboutUI/OpenFairy Project",false,100)]
public static void OpenFairyGUINew()
{
System.Diagnostics.Process p=new System.Diagnostics.Process();
p.StartInfo.FileName=FileTool.getProjectPath("BuildConfig/Tools/FairyGUI-EditorNew/FairyGUI-Editor.exe")
p.StartInfo.Arguments=FileTool.getProjectPath("UIDesign/UIDesign.fairy");
p.EnableRaisingEvents=true;
p.Start()
}
[MenuItem("Tools/AboutUI/OpenFairy Directory",false,100)]
public static void OpenFairyDirectory()
{
System.Diagnostics.Process.Start(FileTool.getProjectPath("UIDesign/assets/"))
}
public static UICodeEditor win;
[MenuItem("Tools/生成选择单独UI模块代码 %&z",false,-10)]
public static void CreateUICode()
{
win=GetWindow<UICodeEditor>();
win.minSize=new Vector2(135*4,35*10));
win.maxSize=win.minSize;
win.ClearOnGUI();
win.Show();
}
public void ClearOnGUI()
{
int pkgCount=packagePaths.Count;
this.titleContent=new GUIContent("当前共:"+pkgCount+"个模块");
int col=pkgCount/4+1;
this.minSize=new Vector2(100*4,(col+1)*39);
this.maxSize=this.minSize;
listPackageNames=FairyGUIPackages.GetChangePkg();
listSelected=GetSelected();
listPackageNames.ForEach(v=>{if(!listSelected.Contains(v)) listSelected.Add(v); });
}
private static Color oldBgColor=Color.clear;
private List<string> listPackageNames=null;
private static List<string> listSelected;
public void OnGUI()
{
int i=0;
if(oldBgColor==Color.clear)
oldBgColor=GUI.backgroundColor;
if(listSelected==null)
ClearOnGUI();
Queue<int> queue=new Queue<int>();
foreach(var v in packagePaths)
{
if(i%4==0)
{
GUILayout.BeginHorizontal();
queue.Enqueue(1);
}
string pkgName=v.Replace(packagesRoot,"");
if(listSelected.Contains(pkgName))
GUI.backgroundColor=Color.cyan;
if(GUILayout.Button(pkgName,GUILayout.Height(30),GUILayout.Width(100)))
{
if(listSelected.Contains(pkgName))
listSelected.Remove(pkgName);
else if(!string.IsNullOrEmpty(pkgName))
{
listSelected.Add(pkgName);
Selection.activeObject=AssetDatabase.LoadAssetAtPath<Object>("Assets/ZeroBuild/Build/UI/Module/"+pkgName);
}
SaveSelected(listSelected);
}
}
}