void OnGUI() { if (changelog != null) { //If we haven't initialized yet, manually call the InitStyles method. if (!initialized) { InitStyles(); } //draw the heading first... //only center the text if we had an error and need to display an error message if (hadError) { UnfinityGUIUtil.StartCenter(); } string bottomHeaderText = (hadError) ? "" : "\n______________________________________"; GUILayout.Label(changelog[0] + bottomHeaderText, HeadingTextStyle); //only center the text if we had an error and need to display an error message if (hadError) { UnfinityGUIUtil.EndCenter(); } scrollPos = GUILayout.BeginScrollView(scrollPos); GUILayout.BeginVertical(); //start on 1, since we've done the heading already... for (int i = 1; i < changelog.Length; i++) { //only center the text if we had an error and need to display an error message if (hadError) { UnfinityGUIUtil.StartCenter(); } //since we're not on first line, don't use a special font. GUILayout.Label(changelog[i], DefaultTextStyle); //add a little space between lines... GUILayout.Space(10); //only center the text if we had an error and need to display an error message if (hadError) { UnfinityGUIUtil.EndCenter(); } } GUILayout.EndVertical(); GUILayout.EndScrollView(); //Add a button to close the window, if there was no error. if (!hadError) { UnfinityGUIUtil.StartCenter(); if (GUILayout.Button(new GUIContent("Close", "Close this window"), GUILayout.Width(100))) { this.Close(); } UnfinityGUIUtil.EndCenter(); } } else { UnfinityGUIUtil.StartCenter(); GUILayout.Label("Loading the Changelog..."); UnfinityGUIUtil.EndCenter(); } }
void OnGUI() { //if we've checked for an update and our changelog is empty, disable our new changelog button. //OR if we've checked for an update, and the update isn't new, disable the button. if (haveCheckedForUpdate && (release != null && release.changelog == "") || (haveCheckedForUpdate && !isNewUpdate)) { //if we got an update, disable the update button. GUI.enabled = false; } UnfinityGUIUtil.StartCenter(); //if we haven't checked for an update, have a button that checks for updates. if (!haveCheckedForUpdate || !isNewUpdate) { //if the button was pressed, or if we're retrieving the file. if (GUILayout.Button("Check for Updates", GUILayout.MaxWidth(150))) { EditorApplication.update -= CheckForUpdates; EditorApplication.update += CheckForUpdates; } } else // if we HAVE checked for updates, have a "view changelog" button. { string changelogText = (release != null && release.changelog == "") ? "Cannot view Changelog" : "View Changelog"; //if the button was pressed, or if we're retrieving the file. if (GUILayout.Button(changelogText, GUILayout.MaxWidth(150))) { //if we don't have a changelog URL, don't present the user with an option to view on the internet. if (release != null && release.changelogURL == "") { OpenChangeLogViewer(); } else //if we DO have a changelog URL, let the user decide if they want to view it in Unity, or a browser { //in this case, true equals 'In Unity' and false equals 'On the internet' int location = EditorUtility.DisplayDialogComplex("Changelog Location", "How would you like to view the changelog?", "In Unity", "On the internet", "Nevermind!"); //if it's the first button if (location == 0) { OpenChangeLogViewer(); } else if (location == 1) //else, if it's the second button { if (release != null) { Application.OpenURL(release.changelogURL); //The user has chosen to view the changelog on the internet, close this window. this.Close(); } else { EditorUtility.DisplayDialog("Cannot open URL", "There was an error opening the changelog URL. Please close the updater and try again.", "OK"); } } //if it was the third button, we don't really care, since the dialog will close on its own. } } } UnfinityGUIUtil.EndCenter(); if (haveCheckedForUpdate) { //if we got an update, re-enable the GUI for the text labels. GUI.enabled = true; } //if we have an error message, display it. if (startMessage != "") { if (startMessage != "Error!") { UnfinityGUIUtil.StartCenter(); GUILayout.Label(startMessage); UnfinityGUIUtil.EndCenter(); } else { GUILayout.BeginVertical(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(errorMessage); UnfinityGUIUtil.EndCenter(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(errorMessage2); UnfinityGUIUtil.EndCenter(); GUILayout.EndVertical(); } } else // otherwise, continue. { //if we have a release... if (release != null) { haveCheckedForUpdate = true; if (release.version < assetVersion) { GUILayout.BeginVertical(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(hasFutureUpdate); UnfinityGUIUtil.EndCenter(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(hasFutureUpdate2); UnfinityGUIUtil.EndCenter(); GUILayout.EndVertical(); } else { if (release.version == assetVersion) { GUILayout.BeginVertical(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(hasCurrentUpdate); UnfinityGUIUtil.EndCenter(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(hasCurrentUpdate2); UnfinityGUIUtil.EndCenter(); GUILayout.EndVertical(); } else { if (release.version > assetVersion) { GUILayout.BeginVertical(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(newUpdate); UnfinityGUIUtil.EndCenter(); UnfinityGUIUtil.StartCenter(); GUILayout.Label(newUpdate2); UnfinityGUIUtil.EndCenter(); GUILayout.EndVertical(); } } } } } }