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.

38 lines
1.7 KiB

  1. /************************************************************************************
  2. Filename : OVRNamedArrayPropertyDrawer.cs
  3. Content : Adds a custom named array drawer to the Unity editor
  4. Created : May 17th, 2018
  5. Copyright : Copyright Facebook Technologies, LLC and its affiliates.
  6. All rights reserved.
  7. Licensed under the Oculus Audio SDK License Version 3.3 (the "License");
  8. you may not use the Oculus Audio SDK except in compliance with the License,
  9. which is provided at the time of installation or download, or which
  10. otherwise accompanies this software in either electronic or hard copy form.
  11. You may obtain a copy of the License at
  12. https://developer.oculus.com/licenses/audio-3.3/
  13. Unless required by applicable law or agreed to in writing, the Oculus Audio SDK
  14. distributed under the License is distributed on an "AS IS" BASIS,
  15. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. See the License for the specific language governing permissions and
  17. limitations under the License.
  18. ************************************************************************************/
  19. using UnityEngine;
  20. using UnityEditor;
  21. // Adds a custom named array drawer to the Unity editor
  22. [CustomPropertyDrawer( typeof(OVRNamedArrayAttribute) )]
  23. public class OVRNamedArrayPropertyDrawer : PropertyDrawer {
  24. public override void OnGUI( Rect rect, SerializedProperty property, GUIContent label ) {
  25. try {
  26. int pos = int.Parse(property.propertyPath.Split('[', ']')[1]);
  27. EditorGUI.PropertyField( rect, property,
  28. new GUIContent( ( (OVRNamedArrayAttribute)attribute ).names[pos] ) );
  29. } catch {
  30. EditorGUI.PropertyField( rect, property, label );
  31. }
  32. }
  33. }