﻿using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(JaceCamSetup))]
public class JaceCamSetupEditor : Editor
{
  JaceCamSetup jc;
  GUIStyle labelRed;

  void OnEnable() {
    jc = target as JaceCamSetup;
    labelRed = new GUIStyle(EditorStyles.label);
    labelRed.normal.textColor = Color.red;
  }

  public override void OnInspectorGUI()
  {
    DrawDefaultInspector();

    EditorGUILayout.Space();

    GUILayout.Label("Position the Camera object to your liking, then press \"Setup JaceCam\" to finalize.");

    GUI.enabled = jc.HeadBone && jc.AvatarDescriptor;
    if (GUILayout.Button("Setup JaceCam")) {
      jc.Setup();
    }
    GUI.enabled = true;

    if (!jc.AvatarDescriptor) {
      GUILayout.Label("Avatar Descriptor unset!", labelRed);
    }
    if (!jc.HeadBone) {
      GUILayout.Label("Head Bone unset!", labelRed);
    }
  }
}