public override void OnGUI() { base.OnGUI(); mRootLayout.OnGUI(); if (GUIHelpers.DoToolbarEx("User Info")) { GUILayout.BeginVertical("box"); if (User.Token.Value.IsNullOrEmpty()) { User.Username.Value = EditorGUIUtils.GUILabelAndTextField("username:"******"password:"******"登录")) { GetTokenAction.DoGetToken(User.Username.Value, User.Password.Value, token => { User.Token.Value = token; User.Save(); }); } if (!inRegisterView && GUILayout.Button("注册")) { inRegisterView = true; } if (inRegisterView) { if (GUILayout.Button("注册")) { } if (GUILayout.Button("返回注册")) { inRegisterView = false; } } } else { if (GUILayout.Button("注销")) { User.Clear(); } } GUILayout.EndVertical(); } }
public override void OnGUI() { base.OnGUI(); mRootLayout.OnGUI(); GUILayout.BeginVertical("box"); mFrameworkInfoLayout.OnGUI(); mToolbarIndex = GUILayout.Toolbar(mToolbarIndex, ToolbarNames); // 这里开始具体的内容 GUILayout.BeginHorizontal("box"); GUILayout.Label("Package", GUILayout.Width(150)); GUILayout.Label("Server", GUILayout.Width(80)); GUILayout.Label("Local", GUILayout.Width(80)); GUILayout.Label("Access Right", GUILayout.Width(80)); GUILayout.Label("Doc", new GUIStyle { alignment = TextAnchor.MiddleCenter, fixedWidth = 40f }); GUILayout.Label("Action", new GUIStyle { alignment = TextAnchor.MiddleCenter, fixedWidth = 100f }); GUILayout.Label("Release Note", new GUIStyle { alignment = TextAnchor.MiddleCenter, fixedWidth = 100f }); GUILayout.EndHorizontal(); GUILayout.BeginVertical("box"); mScrollPos = GUILayout.BeginScrollView(mScrollPos, false, true, GUILayout.Height(240)); foreach (var packageData in SelectedPackageType) { GUILayout.Space(2); GUILayout.BeginHorizontal(); GUILayout.Label(packageData.Name, GUILayout.Width(150)); GUILayout.Label(packageData.Version, GUILayout.Width(80)); var installedPackage = InstalledPackageVersions.FindVersionByName(packageData.Name); GUILayout.Label(installedPackage != null ? installedPackage.Version : " ", GUILayout.Width(80)); GUILayout.Label(packageData.AccessRight.ToString(), GUILayout.Width(80)); if (packageData.DocUrl.IsNotNullAndEmpty()) { if (GUILayout.Button("Doc", GUILayout.Width(40))) { Application.OpenURL(packageData.DocUrl); } } else { GUILayout.Space(40); } if (installedPackage == null) { if (GUILayout.Button("Import", GUILayout.Width(90))) { EditorActionKit.ExecuteNode(new InstallPackage(packageData)); PackageApplication.Container.Resolve <PackageKitWindow>().Close(); } } else if (installedPackage != null && packageData.VersionNumber > installedPackage.VersionNumber) { if (GUILayout.Button("Update", GUILayout.Width(90))) { var path = Application.dataPath.Replace("Assets", packageData.InstallPath); if (Directory.Exists(path)) { Directory.Delete(path, true); } EditorActionKit.ExecuteNode(new InstallPackage(packageData)); PackageApplication.Container.Resolve <PackageKitWindow>().Close(); } } else if (installedPackage.IsNotNull() && packageData.VersionNumber == installedPackage.VersionNumber) { if (GUILayout.Button("Reimport", GUILayout.Width(90))) { var path = Application.dataPath.Replace("Assets", packageData.InstallPath); if (Directory.Exists(path)) { Directory.Delete(path, true); } EditorActionKit.ExecuteNode(new InstallPackage(packageData)); PackageApplication.Container.Resolve <PackageKitWindow>().Close(); } } else if (installedPackage != null) { // maybe support upload? GUILayout.Space(94); } if (GUILayout.Button("Release Notes", GUILayout.Width(100))) { ReadmeWindow.Init(packageData.readme, packageData.PackageVersions.First()); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); GUILayout.Space(2); GUILayout.EndVertical(); GUILayout.EndVertical(); GUILayout.Space(50); }