BlueGit

blue-star ggj-2020

Files

ggj-2020 / Assets / Oculus / Spatializer / editor / ONSPAudioSourceEditor.cs

ONSPAudioSourceEditor.cs

Project Import
timfa Tim Falken · pushed by timfa · 6 years ago
b77834a1 History
ONSPAudioSourceEditor.cs 3.0 KiB Download Raw
1/************************************************************************************
2Filename : ONSPAudioSourceEditor.cs
3Content : This script adds editor functionality to OculusSpatializerUserParams script.
4Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
5
6Licensed under the Oculus SDK Version 3.5 (the "License");
7you may not use the Oculus SDK except in compliance with the License,
8which is provided at the time of installation or download, or which
9otherwise accompanies this software in either electronic or hard copy form.
10
11You may obtain a copy of the License at
12
13https://developer.oculus.com/licenses/sdk-3.5/
14
15Unless required by applicable law or agreed to in writing, the Oculus SDK
16distributed under the License is distributed on an "AS IS" BASIS,
17WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18See the License for the specific language governing permissions and
19limitations under the License.
20************************************************************************************/
21#define CUSTOM_LAYOUT
22
23using UnityEditor;
24using UnityEngine;
25using System.Collections.Generic;
26
27[CustomEditor(typeof(ONSPAudioSource))]
28
29public 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