private void OnClick(Button button) { bool success = true; foreach (Toggle toggle in m_toggleArr) { if (toggle.Select) { if (m_isWnd == true) { string WndName = Path.GetFileNameWithoutExtension(toggle.Data as string); if (!UIWndCode.CreateWnd(WndName, "WndBase", true)) { EditorUtility.DisplayDialog("错误", "生成" + toggle.Label + "代码时出现错误,请查看LOG", "确认"); success = false; } } else { string WndName = Path.GetFileNameWithoutExtension(toggle.Data as string); if (!UIItemCode.CreateItem(WndName, "WndItem", true)) { EditorUtility.DisplayDialog("错误", "生成" + toggle.Label + "代码时出现错误,请查看LOG", "确认"); success = false; } } } } if (success) { EditorUtility.DisplayDialog("成功", "代码创建成功", "确认"); AssetDatabase.Refresh(); } }
void OnGUI() { this.title = "生成界面及代码"; this.minSize = new Vector2(480, 500); GUI.Label(new Rect(0, 50, 100, 20), "窗口名称:"); m_WndName = GUI.TextField(new Rect(100, 50, 200, 20), m_WndName, 18); if (GUI.Button(new Rect(10, 80, 100, 30), "生成窗口")) { UIWndCode.CreateWnd(m_WndName, "WndBase", true); } }