// Copyright (c) Microsoft Corporation. 
// Licensed under the MIT license. 

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
using UnityEditor;
using UnityEngine;

namespace Simplygon.Unity.EditorPlugin
{
    [AddComponentMenu("Simplygon/Simplygon Selection Set")]
    public class SimplygonSelectionSet : MonoBehaviour
    {
        public string SelectionSetName;
        public bool IncludeChildrenInSelectionSet;

        public SimplygonSelectionSet()
        {
            SelectionSetName = "Set1";
            IncludeChildrenInSelectionSet = true;
        }
    }

    [CustomEditor(typeof(SimplygonSelectionSet))]
    public class SimplygonSelectionSetEditor : Editor
    {
        SerializedProperty selectionSetNameProperty;
        SerializedProperty includeChildrenInSelectionSetProperty;

        void OnEnable()
        {
            selectionSetNameProperty = serializedObject.FindProperty("SelectionSetName");
            includeChildrenInSelectionSetProperty = serializedObject.FindProperty("IncludeChildrenInSelectionSet");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            selectionSetNameProperty.stringValue = EditorGUILayout.TextField(new GUIContent("Selection Set Name", "Name of the Simplygon selection set. The selection set can be used in the Simplygon settings."), selectionSetNameProperty.stringValue);
            includeChildrenInSelectionSetProperty.boolValue = EditorGUILayout.Toggle(new GUIContent("Include Children", "Include children in the selection set."), includeChildrenInSelectionSetProperty.boolValue);
            serializedObject.ApplyModifiedProperties();
        }
    }
}
