public override void OnInspectorGUI()
        {
            var settings = serializedObject.targetObject as Settings;

            serializedObject.Update();

            //AssetName
            GUILayout.Label(Constant.Inspactor.TextSetName, BoldLabelStyle);
            EditorGUILayout.LabelField(settings.TextSetAssetName);

            GUILayout.Label("Instance Type", BoldLabelStyle);
            EditorGUILayout.LabelField("Singleton (Use Resources folder)");

            GUILayout.Label("Generate TextSet Path", BoldLabelStyle);
            EditorGUILayout.LabelField(settings.TextSetAssetPath());

            GUILayout.Label("Genrete KeyFile Path", BoldLabelStyle);
            EditorGUILayout.LabelField(settings.KeyAssetPath());

            Separator();

            EditorGUI.BeginChangeCheck();

            //Language
            GUILayout.Label(Constant.Inspactor.Language, BoldLabelStyle);
            reorderableList.DoLayoutList();
            serializedObject.ApplyModifiedProperties();

            //Data
            GUILayout.Label(Constant.Inspactor.DataSouce, BoldLabelStyle);
            EditorGUILayout.LabelField(settings.SelectedDataSource.ToString());

            GUILayout.Label(Constant.Inspactor.SpreadSheetURL, BoldLabelStyle);
            settings.GoogleSpreadSheetUrl = EditorGUILayout.TextField(settings.GoogleSpreadSheetUrl);

            Separator();

            //Button
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(Constant.Inspactor.ButtonGenerate))
            {
                LocalTextLogger.Verbose("Create Button Click");
                GoogleSpreadSheetImporter.SyncGoogleSpreadSheetApi(settings);
            }

            if (GUILayout.Button(Constant.Inspactor.ButtonValidate))
            {
                LocalTextLogger.Verbose("Validate Button Click");

                Validate(settings);
            }
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                LocalTextLogger.Verbose("Setting updated. Save Setting");
                EditorUtility.SetDirty(settings);
                AssetDatabase.SaveAssets();
            }
        }
Ejemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            var settings = serializedObject.targetObject as Settings;

            serializedObject.Update();

            EditorGUI.BeginChangeCheck();

            //Asset Name
            GUILayout.Label(Constant.Inspactor.TextSetName, BoldLabelStyle);
            settings.TextSetAssetName = EditorGUILayout.TextField(settings.TextSetAssetName);

            GUILayout.Label(Constant.Inspactor.TextSetDir, BoldLabelStyle);
            EditorGUILayout.LabelField(string.IsNullOrEmpty(settings.TextSetGenerateDirectory)
                ? Constant.Inspactor.FolderNotSelected
                : settings.TextSetGenerateDirectory);

            var folderForTextSet = EditorGUILayout.ObjectField(Constant.Inspactor.Folder,
                                                               settings.TextDataGenerateFolder, typeof(Object), false);

            if (folderForTextSet != settings.TextDataGenerateFolder)
            {
                settings.TextDataGenerateFolder = folderForTextSet;
                var assetPath = AssetDatabase.GetAssetPath(folderForTextSet);
                settings.TextSetGenerateDirectory = assetPath;
            }

            Separator();

            //Key Class Name
            GUILayout.Label(Constant.Inspactor.KeyClass, BoldLabelStyle);
            settings.KeyDefinitionClassName = EditorGUILayout.TextField(settings.KeyDefinitionClassName);

            GUILayout.Label(Constant.Inspactor.KeyClassDir, BoldLabelStyle);
            EditorGUILayout.LabelField(string.IsNullOrEmpty(settings.KeyClassGenerateDirectory)
                ? Constant.Inspactor.KeyClassDir
                : settings.KeyClassGenerateDirectory);

            var folderForKeyFile = EditorGUILayout.ObjectField(Constant.Inspactor.Folder,
                                                               settings.KeyClassGenerateFolder, typeof(Object), false);

            if (folderForKeyFile != settings.KeyClassGenerateFolder)
            {
                settings.KeyClassGenerateFolder = folderForKeyFile;
                var assetPath = AssetDatabase.GetAssetPath(settings.KeyClassGenerateFolder);
                settings.KeyClassGenerateDirectory = assetPath;
            }

            Separator();

            //Language List
            GUILayout.Label(Constant.Inspactor.Language, BoldLabelStyle);
            reorderableList.DoLayoutList();
            serializedObject.ApplyModifiedProperties();

            Separator();

            //Data
            GUILayout.Label(Constant.Inspactor.DataSouce, BoldLabelStyle);
            settings.SelectedDataSource = (Settings.DataSource)EditorGUILayout.EnumPopup(settings.SelectedDataSource);

            GUILayout.Label(Constant.Inspactor.DataFormat, BoldLabelStyle);
            settings.SelectedDataFormat = (Settings.DataFormat)EditorGUILayout.EnumPopup(settings.SelectedDataFormat);

            GUILayout.Label(Constant.Inspactor.SpreadSheetURL, BoldLabelStyle);
            settings.GoogleSpreadSheetUrl = EditorGUILayout.TextField(settings.GoogleSpreadSheetUrl);

            Separator();

            //Button
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(Constant.Inspactor.ButtonGenerate))
            {
                LocalTextLogger.Verbose("Create Button Click");
                GoogleSpreadSheetImporter.SyncGoogleSpreadSheetApi(settings);
            }

            if (GUILayout.Button(Constant.Inspactor.ButtonValidate))
            {
                LocalTextLogger.Verbose("Validate Button Click");

                Validate(settings);
            }
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                LocalTextLogger.Verbose("Setting updated. Save Setting");
                EditorUtility.SetDirty(settings);
                AssetDatabase.SaveAssets();
            }
        }