using UnityEditor; using UnityEngine; using Google.Apis.Drive.v3; using System.Collections.Generic; using System.Linq; using Sirenix.OdinInspector; using Sirenix.OdinInspector.Editor; using TriflesGames.GDriveUtility.Editor; using TriflesGames.SDKManagement.Editor.SDKFiles; namespace TriflesGames.SDKManagement.Editor { public class SDKManagerWindow : OdinEditorWindow { [TableList(AlwaysExpanded = true)] [OnValueChanged(nameof(ListFiles))] [SerializeField] private List _sdkList = new List(); [MenuItem("Trifles Games/Google Drive/Manage SDKs")] private static void ShowWindow() { var window = GetWindow(); window.titleContent = new GUIContent("SDK Manager"); window.Show(); } protected override void OnEnable() { base.OnEnable(); ListFiles(); } [Button(ButtonSizes.Medium)] public void Refresh() { ListFiles(); } private void ListFiles() { var credential = GDriveUtils.CreateCredentials(DriveService.Scope.DriveReadonly); if (credential == null) { var message = "Credentials file is not valid! Please create a credentials file from 'Trifles Games/SDK Magament/Set Credentials'"; EditorUtility.DisplayDialog("Error", message, "Ok"); return; } var service = SDKUtils.CreateService(credential); var files = SDKUtils.GetSDKs(service); var info = SDKUtils.GetInfo(); if (files != null && files.Count > 0) { _sdkList = files.Select(f => SDKFileFactory.Create(f, info)).ToList(); } } } }