Skip to content
Snippets Groups Projects
AuthenticationWindow.cs 1.85 KiB
Newer Older
using System;
using UnityEditor;
using UnityEngine;

namespace GitHub.Unity
{
    [Serializable]
    class AuthenticationWindow : BaseWindow
        private const string Title = "Sign in";

        [SerializeField] private AuthenticationView authView;

        [MenuItem("GitHub/Authenticate")]
        public static void Launch()
        {
        public static IView Open(Action<bool> onClose = null)
Don Okuda's avatar
Don Okuda committed
            AuthenticationWindow authWindow = GetWindow<AuthenticationWindow>();
            if (onClose != null)
                authWindow.OnClose += onClose;
            authWindow.minSize = new Vector2(290, 290);
Don Okuda's avatar
Don Okuda committed
            authWindow.Show();
            if (authView == null)
            {
                CreateViews();
            }
        public override void OnEnable()
            // Set window title
            titleContent = new GUIContent(Title, Styles.SmallLogo);
            Utility.UnregisterReadyCallback(CreateViews);
            Utility.RegisterReadyCallback(CreateViews);

            Utility.UnregisterReadyCallback(ShowActiveView);
            Utility.RegisterReadyCallback(ShowActiveView);
        private void CreateViews()
        {
            if (authView == null)
                authView = new AuthenticationView();

            Initialize(EntryPoint.ApplicationManager);
            authView.InitializeView(this);
        private void ShowActiveView()
        {
            authView.OnShow();
            Refresh();
        }

        public override void Finish(bool result)
        {
            Close();
            base.Finish(result);
        }