Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.0 KiB

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