bool creds() { GUILayout.BeginArea(new Rect(position.width * 0.05f, position.height * 0.36f, position.width * 0.90f, position.height * 0.24f)); GUILayout.BeginHorizontal(); GUILayout.Label("Username: "******"", username, GUILayout.MaxWidth(position.width / 2)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Password: "******"", password, GUILayout.MaxWidth(position.width / 2)); GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(username.Length == 0 || password.Length == 0); if (GUILayout.Button("Connect")) { bool connected = username.Length != 0 && password.Length != 0 && PiXYZ4UnityWrapper.connectToLicenseServer(username, password); //PiXYZ4UnityWrapper.availableLicensesCount(); if (connected) { return(true); } else { m_Informations.target = true; } } EditorGUI.EndDisabledGroup(); if (EditorGUILayout.BeginFadeGroup(m_Informations.faded)) { EditorGUI.indentLevel++; GUIStyle a = new GUIStyle(); a.normal.textColor = Color.red; GUILayout.Label("Credentials error", a); EditorGUI.indentLevel--; EditorGUILayout.EndFadeGroup(); } GUILayout.EndArea(); return(false); }
void onlineTab() { if (lastIndex == -1) { waitEvent = true; } if (lastOptionLength != options.Length && Event.current.type != EventType.Layout) { return; } else if (lastOptionLength != options.Length && Event.current.type == EventType.Layout) { lastOptionLength = options.Length; } GUILayout.Space(10); EditorGUILayout.LabelField("Select your license", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(options.Length < 1); { if (Event.current.type == EventType.Layout) //Updates on layout event { lastIndex = index; } EditorStyles.popup.richText = true; index = EditorGUILayout.Popup(index, options); EditorStyles.popup.richText = false; if (lastIndex != index) { waitEvent = true; } } EditorGUI.EndDisabledGroup(); GUILayout.Space(10); GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton); if (GUILayout.Button("Refresh", buttonStyle, GUILayout.MaxWidth(Screen.width * 0.2f))) { PiXYZ4UnityWrapper.connectToLicenseServer(username, password); } } GUILayout.EndHorizontal(); GUILayout.Space(5); bool installed = false; if (index < options.Length) { string productName, validity, licenseUse, currentlyInstalled; int usedIndex = index; if (waitEvent) { if (Event.current.type != EventType.Layout) { usedIndex = lastIndex; } else { waitEvent = false; } } int daysRemaining = Math.Max(0, (Convert.ToDateTime(PiXYZ4UnityWrapper.licenseValidity(usedIndex)) - DateTime.Now).Days + 1); string remainingTextColor = daysRemaining > 185 ? "green" : daysRemaining > 92 ? "orange" : "red"; installed = PiXYZ4UnityWrapper.licenseOnMachine(usedIndex); productName = PiXYZ4UnityWrapper.licenseProduct(usedIndex); validity = PiXYZ4UnityWrapper.licenseValidity(usedIndex) + " (<color='" + remainingTextColor + "'><b>" + daysRemaining + "</b> Day" + (daysRemaining > 1 ? "s" : "") + " remaining</color>)"; licenseUse = "" + PiXYZ4UnityWrapper.licenseInUse(usedIndex) + " / " + PiXYZ4UnityWrapper.licenseCount(usedIndex); currentlyInstalled = installed ? "<color='green'>true</color>" : "false"; GUIStyle italic = new GUIStyle(GUI.skin.label); italic.fontStyle = FontStyle.Italic; EditorGUI.indentLevel = 1; EditorGUILayout.LabelField("License informations", italic); EditorGUI.indentLevel = 2; EditorStyles.label.richText = true; EditorGUILayout.LabelField("Product name: ", productName); EditorGUILayout.LabelField("Validity: ", validity); EditorGUILayout.LabelField("License use: ", licenseUse); EditorGUILayout.LabelField("Currently installed: ", currentlyInstalled); GUI.skin.label.richText = false; EditorGUI.indentLevel = 0; } else if (options.Length == 0) { GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontStyle = FontStyle.Bold; labelStyle.normal.textColor = Color.red; GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label("No license available in your account.", labelStyle); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Space(30); } GUILayout.EndVertical(); } EditorGUI.BeginDisabledGroup(index >= options.Length); { GUIStyle btnContainerStyle = new GUIStyle(); btnContainerStyle.margin.right = 5; GUILayout.BeginArea(new Rect(position.width * 0.05f, position.height - 30, position.width * 0.90f, 30), btnContainerStyle); { GUILayout.BeginHorizontal(); string installName = installed ? "Reinstall" : "Install"; if (GUILayout.Button(installName)) { //Unity don't like calls to precompiled function while in layout // => delayed call to outside of layouts doRequest = true; } if (installed) { GUILayout.Space(40); if (GUILayout.Button("Release")) { if (EditorUtility.DisplayDialog("Warning", "Release (or uninstall) current license lets you install it on another computer. This action is available only once.\n\nAre you sure you want to release this license ?", "Yes", "No")) { //Unity don't like calls to precompiled function while in layout // => delayed call to outside of layouts doRelease = true; } } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); } EditorGUI.EndDisabledGroup(); if (username.Length > 0 && password.Length > 0) { options = new string[PiXYZ4UnityWrapper.availableLicensesCount()]; for (int i = 0; i < PiXYZ4UnityWrapper.availableLicensesCount(); ++i) { options[i] = "License " + (i + 1) + ": " + PiXYZ4UnityWrapper.licenseProduct(i) + " [" + PiXYZ4UnityWrapper.licenseValidity(i) + "]"; if (PiXYZ4UnityWrapper.licenseOnMachine(i)) { options[i] += " (installed)"; } } } }