コード例 #1
0
        /// <summary>
        /// プロジェクト情報の取得
        /// </summary>
        public async void LoadProjectInfo(Action onSuccess = null)
        {
            APIData = BacklogAPIData.Load();

            // エディタが再生中かつ一時停止中だと認証時にawaitで止まってしまうので、キャッシュがない時は一時停止を解除する
            bool isPaused = EditorApplication.isPaused;

            if (EditorApplication.isPlaying)
            {
                bool isCached = File.Exists($"{Application.dataPath}/../{APIData.CacheFileName}");
                if (!isCached)
                {
                    EditorApplication.isPaused = false;
                }
            }

            // 認証
            var client = new BacklogClient(APIData.SpaceKey, APIData.Domain);
            await client.AuthorizeAsync(new OAuth2App()
            {
                ClientId             = APIData.ClientId,
                ClientSecret         = APIData.ClientSecretId,
                RedirectUri          = APIData.RedirectURI,
                CredentialsCachePath = APIData.CacheFileName,
            });

            EditorApplication.isPaused = isPaused;

            // 各種データ取得
            Space            = client.GetSpaceAsync().Result.Content;
            Project          = client.GetProjectAsync(APIData.ProjectKey).Result.Content;
            Data.TicketTypes = Project.GetTicketTypesAsync().Result.Content;
            Data.Priorities  = client.GetPriorityTypesAsync().Result.Content;
            Data.Categories  = Project.GetCategoriesAsync().Result.Content;
            Data.Milestones  = Project.GetMilestonesAsync().Result.Content;
            Data.Users       = Project.GetUsersAsync().Result.Content;

            onSuccess?.Invoke();
        }