multiple xr toolkit package
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.

VRCPlayerModsEditor.cs 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEditor;
  5. using System;
  6. namespace VRCSDK2
  7. {
  8. [CustomEditor(typeof(VRCSDK2.VRC_PlayerMods))]
  9. public class VRCPlayerModsEditor : Editor
  10. {
  11. VRCSDK2.VRC_PlayerMods myTarget;
  12. void OnEnable()
  13. {
  14. if(myTarget == null)
  15. myTarget = (VRCSDK2.VRC_PlayerMods)target;
  16. }
  17. public override void OnInspectorGUI()
  18. {
  19. myTarget.isRoomPlayerMods = EditorGUILayout.Toggle("isRoomPlayerMods", myTarget.isRoomPlayerMods);
  20. List<VRCPlayerMod> playerMods = myTarget.playerMods;
  21. for(int i=0; i<playerMods.Count; ++i)
  22. {
  23. VRCSDK2.VRCPlayerMod mod = playerMods[i];
  24. EditorGUILayout.BeginVertical("box");
  25. EditorGUILayout.LabelField(mod.name, EditorStyles.boldLabel);
  26. if( mod.allowNameEdit )
  27. mod.name = EditorGUILayout.TextField( "Mod Name: ", mod.name );
  28. for(int j=0; j<mod.properties.Count; ++j)
  29. {
  30. VRCSDK2.VRCPlayerModProperty prop = mod.properties[j];
  31. myTarget.playerMods[i].properties[j] = DrawFieldForProp(prop);
  32. }
  33. if(GUILayout.Button ("Remove Mod"))
  34. {
  35. myTarget.RemoveMod(mod);
  36. break;
  37. }
  38. EditorGUILayout.EndVertical();
  39. }
  40. if(GUILayout.Button("Add Mods"))
  41. {
  42. VRCPlayerModEditorWindow.AddModCallback adcb = OnInspectorGUI;
  43. VRCPlayerModEditorWindow.Init(myTarget, adcb);
  44. }
  45. }
  46. VRCSDK2.VRCPlayerModProperty DrawFieldForProp(VRCSDK2.VRCPlayerModProperty property)
  47. {
  48. if(property.type.SystemType == typeof(int))
  49. {
  50. property.intValue = EditorGUILayout.IntField(property.name, property.intValue);
  51. }
  52. else if(property.type.SystemType == typeof(float))
  53. {
  54. property.floatValue = EditorGUILayout.FloatField(property.name, property.floatValue);
  55. }
  56. else if(property.type.SystemType == typeof(string))
  57. {
  58. property.stringValue = EditorGUILayout.TextField(property.name, property.stringValue);
  59. }
  60. else if(property.type.SystemType == typeof(bool))
  61. {
  62. property.boolValue = EditorGUILayout.Toggle(property.name, property.boolValue);
  63. }
  64. else if(property.type.SystemType == typeof(GameObject))
  65. {
  66. EditorGUILayout.BeginHorizontal();
  67. EditorGUILayout.LabelField( property.name );
  68. property.gameObjectValue = (GameObject) EditorGUILayout.ObjectField( property.gameObjectValue, typeof( GameObject ), true );
  69. EditorGUILayout.EndHorizontal();
  70. }
  71. else if(property.type.SystemType == typeof(KeyCode))
  72. {
  73. EditorGUILayout.BeginHorizontal();
  74. EditorGUILayout.LabelField( property.name );
  75. property.keyCodeValue = (KeyCode) EditorGUILayout.EnumPopup( property.keyCodeValue );
  76. EditorGUILayout.EndHorizontal();
  77. }
  78. else if(property.type.SystemType == typeof(VRCSDK2.VRC_EventHandler.VrcBroadcastType))
  79. {
  80. EditorGUILayout.BeginHorizontal();
  81. EditorGUILayout.LabelField( property.name );
  82. property.broadcastValue = (VRCSDK2.VRC_EventHandler.VrcBroadcastType) EditorGUILayout.EnumPopup( property.broadcastValue );
  83. EditorGUILayout.EndHorizontal();
  84. }
  85. else if(property.type.SystemType == typeof(VRCSDK2.VRCPlayerModFactory.HealthOnDeathAction))
  86. {
  87. EditorGUILayout.BeginHorizontal();
  88. EditorGUILayout.LabelField( property.name );
  89. property.onDeathActionValue = (VRCSDK2.VRCPlayerModFactory.HealthOnDeathAction) EditorGUILayout.EnumPopup( property.onDeathActionValue);
  90. EditorGUILayout.EndHorizontal();
  91. }
  92. else if(property.type.SystemType == typeof(RuntimeAnimatorController))
  93. {
  94. EditorGUILayout.BeginHorizontal();
  95. EditorGUILayout.LabelField( property.name );
  96. property.animationController = (RuntimeAnimatorController) EditorGUILayout.ObjectField( property.animationController, typeof( RuntimeAnimatorController ), false );
  97. EditorGUILayout.EndHorizontal();
  98. }
  99. return property;
  100. }
  101. }
  102. }