FittsLaw/Assets/Oculus/Avatar/Scripts/OvrAvatarSettingsEditor.cs
2018-10-09 20:59:57 -04:00

45 lines
1.6 KiB
C#

#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(OvrAvatarSettings))]
public class OvrAvatarSettingsEditor : Editor {
GUIContent appIDLabel = new GUIContent("Oculus Rift App Id [?]",
"This AppID will be used for OvrAvatar registration.");
GUIContent gearAppIDLabel = new GUIContent("Gear VR App Id [?]",
"This AppID will be used for OvrAvatar registration when building to the Android target.");
[UnityEditor.MenuItem("Oculus Avatars/Edit Configuration")]
public static void Edit()
{
var settings = OvrAvatarSettings.Instance;
UnityEditor.Selection.activeObject = settings;
}
private static string MakeTextBox(GUIContent label, string variable) {
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField(label);
GUI.changed = false;
var result = EditorGUILayout.TextField(variable);
if (GUI.changed)
{
EditorUtility.SetDirty(OvrAvatarSettings.Instance);
GUI.changed = false;
}
EditorGUILayout.EndHorizontal();
return result;
}
public override void OnInspectorGUI()
{
EditorGUILayout.BeginVertical();
OvrAvatarSettings.AppID =
OvrAvatarSettingsEditor.MakeTextBox(appIDLabel, OvrAvatarSettings.AppID);
OvrAvatarSettings.GearAppID =
OvrAvatarSettingsEditor.MakeTextBox(gearAppIDLabel, OvrAvatarSettings.GearAppID);
EditorGUILayout.EndVertical();
}
}
#endif