public void Init()
        {
            config = (GoogleSheetsToUnityConfig)Resources.Load("GSTU_Config");
            var finds = AssetDatabase.FindAssets("t:LocalizedSetting", null);

            foreach (var item in finds)
            {
                var path = AssetDatabase.GUIDToAssetPath(item);
                localizedConfig = AssetDatabase.LoadAssetAtPath <LocalizedSetting>(path);
            }
        }
        public SpreadSheetManager()
        {
            if (config == null)
            {
                config = (GoogleSheetsToUnityConfig)UnityEngine.Resources.Load("GSTU_Config");
            }

            ServicePointManager.ServerCertificateValidationCallback = Validator;
            OAuth2 oAuth2       = new OAuth2();
            var    refreshToken = config.REFRESH_TOKEN;

            new SpreadSheetManager(oAuth2.GetOAuth2Parameter(refreshToken));
        }
Example #3
0
        public OAuth2Parameters GetOAuth2Parameter(string refreshToken)
        {
            if (config == null)
            {
                config = (GoogleSheetsToUnityConfig)UnityEngine.Resources.Load("GSTU_Config");
            }

            OAuth2Parameters parameters = new OAuth2Parameters();

            parameters.ClientId     = config.CLIENT_ID;
            parameters.ClientSecret = config.CLIENT_SECRET;
            parameters.RefreshToken = refreshToken;
            OAuthUtil.RefreshAccessToken(parameters);
            return(parameters);
        }
Example #4
0
        public string GetAuthURL()
        {
            if (config == null)
            {
                config = (GoogleSheetsToUnityConfig)UnityEngine.Resources.Load("GSTU_Config");
            }

            OAuth2Parameters parameters = new OAuth2Parameters();

            parameters.ClientId     = config.CLIENT_ID;
            parameters.ClientSecret = config.CLIENT_SECRET;
            parameters.RedirectUri  = REDIRECT_URI;
            parameters.Scope        = SCOPE;
            return(OAuthUtil.CreateOAuth2AuthorizationUrl(parameters));
        }
Example #5
0
        public void Init()
        {
            config = (GoogleSheetsToUnityConfig)Resources.Load(_gstuAPIsConfig);
            var finds = AssetDatabase.FindAssets($"t:{_sheetSettingAsset}", null);

            foreach (var item in finds)
            {
                var path = AssetDatabase.GUIDToAssetPath(item);
                _sheetSetting = AssetDatabase.LoadAssetAtPath <SheetSetting>(path);
            }

            if (_queue == null)
            {
                _queue = new QueueAction();
            }
        }
Example #6
0
        public string AuthWithAccessCode(string accessCode)
        {
            if (config == null)
            {
                config = (GoogleSheetsToUnityConfig)UnityEngine.Resources.Load("GSTU_Config");
            }

            OAuth2Parameters parameters = new OAuth2Parameters();

            parameters.ClientId     = config.CLIENT_ID;
            parameters.ClientSecret = config.CLIENT_SECRET;
            parameters.RedirectUri  = REDIRECT_URI;
            parameters.Scope        = SCOPE;
            parameters.AccessCode   = accessCode;

            OAuthUtil.GetAccessToken(parameters);
            return(parameters.RefreshToken);
        }
        private void DrawLocalization()
        {
            if (localizedConfig == null)
            {
                GUILayout.Label("Create Localization Setting", EditorStyles.boldLabel);
                GUI.backgroundColor = Color.red;
                if (GUILayout.Button("Create", GUILayout.Height(30)))
                {
                    if (AssetDatabase.IsValidFolder(folderPath))
                    {
                        localizedConfig = CreateInstance <LocalizedSetting>();
                        AssetDatabase.CreateAsset(localizedConfig, $"{folderPath}/{assetFile}");

                        config = CreateInstance <GoogleSheetsToUnityConfig>();
                        AssetDatabase.CreateAsset(config, $"{resourcePath}/GSTU_Config.asset");
                    }
                    else
                    {
                        AssetDatabase.CreateFolder("Assets", "Localizations");
                        AssetDatabase.CreateFolder(folderPath, "Resources");
                        AssetDatabase.CreateFolder(folderPath, "Scripts");

                        localizedConfig = CreateInstance <LocalizedSetting>();
                        AssetDatabase.CreateAsset(localizedConfig, $"{folderPath}/{assetFile}");

                        config = CreateInstance <GoogleSheetsToUnityConfig>();
                        AssetDatabase.CreateAsset(config, $"{resourcePath}/GSTU_Config.asset");
                    }

                    AssetDatabase.SaveAssets();
                }
            }
            else
            {
                DrawSheetConfig();
            }
        }
Example #8
0
 public static void SetConfig(GoogleSheetsToUnityConfig config)
 {
     PlayerPrefs.SetString("GSTU_Config", LitJson.JsonMapper.ToJson(config));
     PlayerPrefs.Save();
 }
Example #9
0
        private void DrawLocalization()
        {
            if (_sheetSetting == null)
            {
                GUILayout.Label("Create GSTU Setting", EditorStyles.boldLabel);
                GUI.backgroundColor = Color.red;
                if (!GUILayout.Button("Create", GUILayout.Height(30)))
                {
                    return;
                }

                if (AssetDatabase.IsValidFolder(_folderPath))
                {
                    _sheetSetting = CreateInstance <SheetSetting>();
                    AssetDatabase.CreateAsset(_sheetSetting, $"{_folderPath}/{_sheetSettingAsset}.asset");

                    config = CreateInstance <GoogleSheetsToUnityConfig>();
                    AssetDatabase.CreateAsset(config, $"{_resourcePath}/{_gstuAPIsConfig}.asset");
                }
                else
                {
                    //create export folder
                    AssetDatabase.CreateFolder("Assets", exportFolder);

                    //create export resource folder
                    AssetDatabase.CreateFolder(_folderPath, "Resources");

                    //create export scripts folder
                    AssetDatabase.CreateFolder(_folderPath, "Scripts");

                    _sheetSetting = CreateInstance <SheetSetting>();
                    _sheetSetting.GoogleSheets = new List <SheetConfig> {
                        new SheetConfig()
                    };
                    AssetDatabase.CreateAsset(_sheetSetting, $"{_folderPath}/{_sheetSettingAsset}.asset");

                    config = CreateInstance <GoogleSheetsToUnityConfig>();
                    AssetDatabase.CreateAsset(config, $"{_resourcePath}/{_gstuAPIsConfig}.asset");
                }

                AssetDatabase.SaveAssets();
            }
            else if (!showTextTemplate)
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                GUILayout.Label("");
                GUILayout.Label("Google Sheet Config", EditorStyles.boldLabel);
                for (int i = 0; i < _sheetSetting.GoogleSheets.Count; i++)
                {
                    DrawSheetConfig(i + 1, _sheetSetting.GoogleSheets[i]);
                    GUI.backgroundColor = Color.white;
                }

                GUILayout.EndScrollView();

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Add Google Sheet"))
                {
                    _sheetSetting.GoogleSheets.Add(new SheetConfig());
                }

                if (GUILayout.Button("Expand"))
                {
                    expandAll = !expandAll;
                    for (int i = 0; i < _sheetSetting.GoogleSheets.Count; i++)
                    {
                        _sheetSetting.GoogleSheets[i].isExpand = expandAll;
                    }
                }

                GUI.backgroundColor = Color.yellow;
                if (GUILayout.Button("Save Asset"))
                {
                    EditorUtility.SetDirty(config);
                    EditorUtility.SetDirty(_sheetSetting);
                    AssetDatabase.SaveAssets();
                }

                GUI.backgroundColor = Color.white;
                GUILayout.EndHorizontal();

                GUILayout.Label("");
                GUILayout.Label("Download & Build all data", EditorStyles.boldLabel);
                GUI.backgroundColor = Color.green;
                if (GUILayout.Button("Build all", GUILayout.Height(30)))
                {
                    OnImportClicked();
                }

                GUILayout.Label("", GUILayout.Height(60));
            }
            else if (showTextTemplate)
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
                GUILayout.Label("");
                GUILayout.Label("Build Text Template", EditorStyles.boldLabel);
                _sheetSetting.textTemplate = GUILayout.TextArea(_sheetSetting.textTemplate);

                GUILayout.EndScrollView();
            }
        }
 public void Init()
 {
     config = (GoogleSheetsToUnityConfig)UnityEngine.Resources.Load("GSTU_Config");
 }