﻿//----------------------------------------------------------------------------------
// GVRNavi | Garpix Virtual Reality Navigation
// Copyright (c) 2017 Garpix Ltd.
//
// Plugin Homepage: https://gvrnavi.garpix.com
// Author Homepage: https://garpix.com
// Support: support@garpix.com
// License: Asset Store Terms of Service and EULA
// License URI: See LICENSE file in the project root for full license information.
//----------------------------------------------------------------------------------

using UnityEngine;
using UnityEditor;

namespace GVRNavi
{
    [CustomEditor(typeof(VRRingSimple), true)]
    public class VRRingSimpleEditor : Editor
    {
        SerializedProperty timeToTrigger, closedHeight, openedHeight, HoveredColor, ActiveColor,
            meshRing, OnRingEnter, OnRingExit, OnRingTrigger;

        void OnEnable()
        {
            timeToTrigger = serializedObject.FindProperty("timeToTrigger");
            closedHeight = serializedObject.FindProperty("closedHeight");
            openedHeight = serializedObject.FindProperty("openedHeight");
            HoveredColor = serializedObject.FindProperty("HoveredColor");
            ActiveColor = serializedObject.FindProperty("ActiveColor");
            meshRing = serializedObject.FindProperty("meshRing");
            OnRingEnter = serializedObject.FindProperty("OnRingEnter");
            OnRingExit = serializedObject.FindProperty("OnRingExit");
            OnRingTrigger = serializedObject.FindProperty("OnRingTrigger");
        }

        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            VRRingSimple ring = target as VRRingSimple;
            EditorGUILayout.PropertyField(timeToTrigger);
            EditorGUILayout.PropertyField(closedHeight);
            EditorGUILayout.PropertyField(openedHeight);
            EditorGUILayout.PropertyField(meshRing);
            EditorGUILayout.Space();
            Color c = EditorGUILayout.ColorField(new GUIContent("Normal Color"), ring.NormalColor);
            if (ring.NormalColor != c)
            {
                ring.NormalColor = c;
                ring.UpdateColor();
            }
            EditorGUILayout.PropertyField(HoveredColor);
            EditorGUILayout.PropertyField(ActiveColor);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(OnRingEnter);
            EditorGUILayout.PropertyField(OnRingExit);
            EditorGUILayout.PropertyField(OnRingTrigger);
            serializedObject.ApplyModifiedProperties();
        }
    }
}