using UnityEditor;
using UnityEngine;
using VRC.SDKBase;

namespace gay.lilyy.aaccore {
    /// <summary>
    /// Adding this to the avatar root will build the FX layer.
    /// </summary>
    public class AACRoot : MonoBehaviour, IEditorOnly {
        public bool experimentalPlayMode = true;
        public bool experimentalUpload = false;

        // unity needs this to show the enable/disable box
        void Start(){}

        #if UNITY_EDITOR
        [CustomEditor(typeof(AACRoot))]
        private class Editor : UnityEditor.Editor
        {
            public override void OnInspectorGUI()
            {
                // Draw the default message
                EditorGUILayout.HelpBox(
                    "Adding this to the avatar root will build the FX layer.",
                    MessageType.Info
                );

                // Draw the 'Enable Experimental Layers' toggle
                var component = (AACRoot)target;
                EditorGUI.BeginChangeCheck();
                bool newValPlay = EditorGUILayout.Toggle("Enable Experimental Layers in Play Mode", component.experimentalPlayMode);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(component, "Toggle Experimental Layers in Play Mode");
                    component.experimentalPlayMode = newValPlay;
                    EditorUtility.SetDirty(component);
                }
                EditorGUI.BeginChangeCheck();
                bool newValUpload = EditorGUILayout.Toggle("Enable Experimental Layers in Uploads", component.experimentalUpload);
                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(component, "Toggle Experimental Layers in Uploads");
                    component.experimentalPlayMode = newValUpload;
                    EditorUtility.SetDirty(component);
                }
            }
        }
        #endif
    }
}