| 1 | /************************************************************************************ |
| 2 | Filename : ONSPAudioSourceEditor.cs |
| 3 | Content : This script adds editor functionality to OculusSpatializerUserParams script. |
| 4 | Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved. |
| 5 | |
| 6 | Licensed under the Oculus SDK Version 3.5 (the "License"); |
| 7 | you may not use the Oculus SDK except in compliance with the License, |
| 8 | which is provided at the time of installation or download, or which |
| 9 | otherwise accompanies this software in either electronic or hard copy form. |
| 10 | |
| 11 | You may obtain a copy of the License at |
| 12 | |
| 13 | https://developer.oculus.com/licenses/sdk-3.5/ |
| 14 | |
| 15 | Unless required by applicable law or agreed to in writing, the Oculus SDK |
| 16 | distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | See the License for the specific language governing permissions and |
| 19 | limitations under the License. |
| 20 | ************************************************************************************/ |
| 21 | #define CUSTOM_LAYOUT |
| 22 | |
| 23 | using UnityEditor; |
| 24 | using UnityEngine; |
| 25 | using System.Collections.Generic; |
| 26 | |
| 27 | [CustomEditor(typeof(ONSPAudioSource))] |
| 28 | |
| 29 | public class OculusSpatializerUserParamsEditor : Editor |
| 30 | { |
| 31 | // target component |
| 32 | private ONSPAudioSource m_Component; |
| 33 | |
| 34 | // OnEnable |
| 35 | void OnEnable() |
| 36 | { |
| 37 | m_Component = (ONSPAudioSource)target; |
| 38 | } |
| 39 | |
| 40 | // OnInspectorGUI |
| 41 | public override void OnInspectorGUI() |
| 42 | { |
| 43 | GUI.color = Color.white; |
| 44 | Undo.RecordObject(m_Component, "OculusSpatializerUserParams"); |
| 45 | |
| 46 | { |
| 47 | #if CUSTOM_LAYOUT |
| 48 | m_Component.EnableSpatialization = EditorGUILayout.Toggle("Spatialization Enabled", m_Component.EnableSpatialization); |
| 49 | m_Component.EnableRfl = EditorGUILayout.Toggle("Reflections Enabled", m_Component.EnableRfl); |
| 50 | m_Component.Gain = EditorGUILayout.FloatField("Gain", m_Component.Gain); |
| 51 | |
| 52 | Separator(); |
| 53 | |
| 54 | Label ("OCULUS ATTENUATION"); |
| 55 | m_Component.UseInvSqr = EditorGUILayout.Toggle("Enabled", m_Component.UseInvSqr); |
| 56 | Label (""); |
| 57 | Label("RANGE (0.0 - 1000000.0 meters)"); |
| 58 | m_Component.Near = EditorGUILayout.FloatField("Minimum", m_Component.Near); |
| 59 | m_Component.Far = EditorGUILayout.FloatField("Maximum", m_Component.Far); |
| 60 | |
| 61 | Label(""); |
| 62 | Label("VOLUMETRIC RADIUS (0.0 - 1000.0 meters)"); |
| 63 | m_Component.VolumetricRadius = EditorGUILayout.FloatField("Radius", m_Component.VolumetricRadius); |
| 64 | |
| 65 | Separator(); |
| 66 | |
| 67 | Label("REVERB SEND LEVEL (-60.0 - 20.0 decibels)"); |
| 68 | m_Component.ReverbSend = EditorGUILayout.FloatField(" ", m_Component.ReverbSend); |
| 69 | |
| 70 | Separator(); |
| 71 | |
| 72 | #else |
| 73 | DrawDefaultInspector (); |
| 74 | #endif |
| 75 | } |
| 76 | |
| 77 | if (GUI.changed) |
| 78 | { |
| 79 | EditorUtility.SetDirty(m_Component); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // Utilities, move out of here (or copy over to other editor script) |
| 84 | |
| 85 | // Separator |
| 86 | void Separator() |
| 87 | { |
| 88 | GUI.color = new Color(1, 1, 1, 0.25f); |
| 89 | GUILayout.Box("", "HorizontalSlider", GUILayout.Height(16)); |
| 90 | GUI.color = Color.white; |
| 91 | } |
| 92 | |
| 93 | // Label |
| 94 | void Label(string label) |
| 95 | { |
| 96 | EditorGUILayout.LabelField (label); |
| 97 | } |
| 98 | |
| 99 | } |
| 100 | |