void OnGUI() { if (initialized) { if (createNew) { EditorGUILayout.LabelField("Add credential ", EditorStyles.whiteLargeLabel); registry.url = EditorGUILayout.TextField("url: ", registry.url); } else { EditorGUILayout.LabelField("Edit credential", EditorStyles.whiteLargeLabel); EditorGUILayout.LabelField("url: " + registry.url); } registry.auth = EditorGUILayout.Toggle("Always auth: ", registry.auth); registry.token = EditorGUILayout.TextField("Token: ", registry.token); EditorGUILayout.Space(); tokenMethod = GetTokenView.CreateGUI(tokenMethod, registry); EditorGUILayout.Space(); EditorGUILayout.LabelField("Tip: Restart Unity to reload credentials after saving."); if (createNew) { if (GUILayout.Button("Add")) { Save(); } } else { if (GUILayout.Button("Save")) { Save(); } } if (GUILayout.Button("Cancel")) { Close(); GUIUtility.ExitGUI(); } } }
private static void CreateWindow(TokenMethod method, ScopedRegistry registry) { GetTokenView getTokenView = EditorWindow.GetWindow <GetTokenView>(true, "Get token", true); getTokenView.SetRegistry(method, registry); }
void OnGUI() { if (initialized) { EditorGUILayout.Space(); if (createNew) { EditorGUILayout.LabelField("Add scoped registry ", EditorStyles.whiteLargeLabel); registry.name = EditorGUILayout.TextField("Name", registry.name); EditorGUI.BeginChangeCheck(); registry.url = EditorGUILayout.TextField("URL", registry.url); if (EditorGUI.EndChangeCheck()) { UpdateCredential(); } } else { EditorGUILayout.LabelField("Edit scoped registry", EditorStyles.whiteLargeLabel); EditorGUILayout.LabelField("Name", registry.name); EditorGUILayout.LabelField("URL", registry.url); } if (scopeList == null) { scopeList = new ReorderableList(registry.scopes, typeof(string), true, false, true, true) { drawElementCallback = (rect, index, active, focused) => { registry.scopes[index] = EditorGUI.TextField(rect, registry.scopes[index]); }, onAddCallback = list => { registry.scopes.Add(""); } }; } EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Package Scopes"); EditorGUILayout.BeginVertical(); scopeList.DoLayoutList(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Authentication / Credentials", EditorStyles.whiteLargeLabel); registry.auth = EditorGUILayout.Toggle("Always auth", registry.auth); registry.token = EditorGUILayout.TextField("Token", registry.token); EditorGUILayout.Space(); tokenMethod = GetTokenView.CreateGUI(tokenMethod, registry); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true)); EditorGUILayout.EndVertical(); EditorGUILayout.HelpBox("Restart Unity to reload credentials after saving.", MessageType.Info); EditorGUILayout.BeginHorizontal(); if (createNew) { if (GUILayout.Button("Add")) { Add(); } } else { if (GUILayout.Button("Save")) { Save(); } } if (GUILayout.Button("Cancel")) { Close(); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } }
void OnGUI() { if (initialized) { if (createNew) { EditorGUILayout.LabelField("Add credential", EditorStyles.whiteLargeLabel); registry.url = EditorGUILayout.TextField("Registry URL", registry.url); } else { EditorGUILayout.LabelField("Edit credential", EditorStyles.whiteLargeLabel); EditorGUILayout.LabelField("Registry URL: " + registry.url); } if (string.IsNullOrEmpty(registry.url)) { EditorGUILayout.HelpBox("Enter the registry URL you want to add authentication for.", MessageType.Warning); } registry.auth = EditorGUILayout.Toggle("Always auth", registry.auth); registry.token = EditorGUILayout.TextField("Token", registry.token); EditorGUILayout.Space(); EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(registry.url)); tokenMethod = GetTokenView.CreateGUI(tokenMethod, registry); if (!string.IsNullOrEmpty(registry.url) && string.IsNullOrEmpty(registry.token)) { EditorGUILayout.HelpBox("Select an authentication method and click on \"Get token\"", MessageType.Warning); } EditorGUI.BeginDisabledGroup(string.IsNullOrEmpty(registry.token)); EditorGUILayout.Space(); EditorGUILayout.BeginVertical(GUILayout.ExpandHeight(true)); EditorGUILayout.EndVertical(); EditorGUILayout.HelpBox("Restart Unity to reload credentials after saving.", MessageType.Info); EditorGUILayout.BeginHorizontal(); if (createNew) { if (GUILayout.Button("Add")) { Save(); } } else { if (GUILayout.Button("Save")) { Save(); } } EditorGUI.EndDisabledGroup(); EditorGUI.EndDisabledGroup(); if (GUILayout.Button("Cancel")) { Close(); GUIUtility.ExitGUI(); } EditorGUILayout.EndHorizontal(); } }
void OnGUI() { if (initialized) { if (createNew) { EditorGUILayout.LabelField("Add scoped registry ", EditorStyles.whiteLargeLabel); registry.name = EditorGUILayout.TextField("name: ", registry.name); EditorGUI.BeginChangeCheck(); registry.url = EditorGUILayout.TextField("url: ", registry.url); if (EditorGUI.EndChangeCheck()) { UpdateCredential(); } } else { EditorGUILayout.LabelField("Edit scoped registry", EditorStyles.whiteLargeLabel); EditorGUILayout.LabelField("Name: " + registry.name); EditorGUILayout.LabelField("url: " + registry.url); } string scope = String.Join(",", registry.scopes); scope = EditorGUILayout.TextField("Scope: ", scope); var splitScopes = scope.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < splitScopes.Length; i++) { splitScopes[i] = splitScopes[i].Trim(); } registry.scopes = splitScopes; registry.auth = EditorGUILayout.Toggle("Always auth: ", registry.auth); registry.token = EditorGUILayout.TextField("Token: ", registry.token); EditorGUILayout.Space(); tokenMethod = GetTokenView.CreateGUI(tokenMethod, registry); EditorGUILayout.Space(); EditorGUILayout.LabelField("Tip: Restart Unity to reload credentials after saving."); if (createNew) { if (GUILayout.Button("Add")) { Add(); } } else { if (GUILayout.Button("Save")) { Save(); } } if (GUILayout.Button("Cancel")) { Close(); GUIUtility.ExitGUI(); } } }