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.

44 lines
1.4 KiB

  1. namespace VRTK
  2. {
  3. using UnityEditor;
  4. [CustomEditor(typeof(VRTK_NavMeshData), true)]
  5. public class VRTK_NavMeshDataEditor : Editor
  6. {
  7. public new VRTK_NavMeshData target { get { return base.target as VRTK_NavMeshData; } }
  8. private SerializedProperty distanceLimit = null;
  9. private bool _showLayers;
  10. public override void OnInspectorGUI()
  11. {
  12. EditorGUILayout.PropertyField(distanceLimit);
  13. _showLayers = EditorGUILayout.Foldout(_showLayers, VRTK_EditorUtilities.BuildGUIContent<VRTK_NavMeshData>("validAreas"));
  14. if (_showLayers)
  15. {
  16. EditorGUI.indentLevel++;
  17. int currentAreas = target.validAreas;
  18. string[] areas = GameObjectUtility.GetNavMeshAreaNames();
  19. for (int i = 0; i < areas.Length; i++)
  20. {
  21. var selected = (currentAreas & (1 << i)) != 0;
  22. if (EditorGUILayout.Toggle(areas[i], selected))
  23. {
  24. target.validAreas |= (1 << i);
  25. }
  26. else
  27. {
  28. target.validAreas &= ~(1 << i);
  29. }
  30. }
  31. EditorGUI.indentLevel--;
  32. }
  33. }
  34. protected virtual void OnEnable()
  35. {
  36. distanceLimit = serializedObject.FindProperty("distanceLimit");
  37. }
  38. }
  39. }