FTriggerBulletEventInspector.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. using UnityEngine;
  2. using UnityEditor;
  3. using Flux;
  4. namespace FluxEditor
  5. {
  6. [CustomEditor(typeof(FTriggerBulletEvent))]
  7. public class FTriggerBulletEventInspector : FEventInspector
  8. {
  9. private FTriggerBulletEvent _bulletEvent = null;
  10. private SerializedProperty _range = null;
  11. private SerializedProperty _moveType = null;
  12. private SerializedProperty _initSpeed = null;
  13. private SerializedProperty _acceleration = null;
  14. private SerializedProperty _moveDistance = null;
  15. private SerializedProperty _triggerBuffId = null;
  16. private SerializedProperty _triggerBuffRate = null;
  17. private SerializedProperty _bulletId = null;
  18. private SerializedProperty _bulletPrefab = null;
  19. private SerializedProperty _bulletLink = null;
  20. private SerializedProperty _bulletFlyDuration = null;
  21. private SerializedProperty _bulletInitVelocity = null;
  22. private SerializedProperty _bulletAcceleration = null;
  23. private SerializedProperty _bulletAccelerationTime = null;
  24. private SerializedProperty _bulletTargetLink = null;
  25. private SerializedProperty _hitEffectId = null;
  26. private SerializedProperty _hitEffectPrefab = null;
  27. private SerializedProperty _hitEffectLink = null;
  28. int[] moveTypes = new int[] { 0, 1, 5 };
  29. string[] moveTypeStrs = new string[] { "无", "击退", "击飞" };
  30. private int bulletLinkIdx = -1;
  31. private int bulletTargetLinkIdx = -1;
  32. private int hitEffectLinkIdx = -1;
  33. protected override void OnEnable()
  34. {
  35. base.OnEnable();
  36. _bulletEvent = (FTriggerBulletEvent)target;
  37. _range = serializedObject.FindProperty("_range");
  38. _moveType = serializedObject.FindProperty("_moveType");
  39. _initSpeed = serializedObject.FindProperty("_initSpeed");
  40. _acceleration = serializedObject.FindProperty("_acceleration");
  41. _moveDistance = serializedObject.FindProperty("_moveDistance");
  42. _triggerBuffId = serializedObject.FindProperty("_triggerBuffId");
  43. _triggerBuffRate = serializedObject.FindProperty("_triggerBuffRate");
  44. _bulletId = serializedObject.FindProperty("_bulletId");
  45. _bulletPrefab = serializedObject.FindProperty("_bulletPrefab");
  46. _bulletLink = serializedObject.FindProperty("_bulletLink");
  47. _bulletFlyDuration = serializedObject.FindProperty("_bulletFlyDuration");
  48. _bulletInitVelocity = serializedObject.FindProperty("_bulletInitVelocity");
  49. _bulletAcceleration = serializedObject.FindProperty("_bulletAcceleration");
  50. _bulletAccelerationTime = serializedObject.FindProperty("_bulletAccelerationTime");
  51. _bulletTargetLink = serializedObject.FindProperty("_bulletTargetLink");
  52. _hitEffectId = serializedObject.FindProperty("_hitEffectId");
  53. _hitEffectPrefab = serializedObject.FindProperty("_hitEffectPrefab");
  54. _hitEffectLink = serializedObject.FindProperty("_hitEffectLink");
  55. for (int idx =0; idx < linkPoints.Length;idx++)
  56. {
  57. if(linkPoints[idx] == _bulletLink.stringValue)
  58. {
  59. bulletLinkIdx = idx;
  60. break;
  61. }
  62. }
  63. for(int idx = 0; idx < linkPoints.Length;idx++)
  64. {
  65. if(linkPoints[idx] == _bulletTargetLink.stringValue)
  66. {
  67. bulletTargetLinkIdx = idx;
  68. break;
  69. }
  70. }
  71. for(int idx = 0; idx < linkPoints.Length;idx++)
  72. {
  73. if(linkPoints[idx] == _hitEffectLink.stringValue)
  74. {
  75. hitEffectLinkIdx = idx;
  76. break;
  77. }
  78. }
  79. }
  80. public override void OnInspectorGUI()
  81. {
  82. base.OnInspectorGUI();
  83. serializedObject.Update();
  84. EditorGUILayout.BeginHorizontal();
  85. GUILayout.Label("子弹ID:", EditorStyles.label, GUILayout.Width(140));
  86. _bulletId.intValue = EditorGUILayout.IntField(_bulletId.intValue, GUILayout.Width(300));
  87. EditorGUILayout.EndHorizontal();
  88. EditorGUILayout.BeginHorizontal();
  89. GUILayout.Label("子弹预制体:", EditorStyles.label, GUILayout.Width(140));
  90. _bulletPrefab.objectReferenceValue = EditorGUILayout.ObjectField(_bulletPrefab.objectReferenceValue,typeof(GameObject),false, GUILayout.Width(300));
  91. EditorGUILayout.EndHorizontal();
  92. EditorGUILayout.BeginHorizontal();
  93. GUILayout.Label("子弹碰撞范围:", EditorStyles.label, GUILayout.Width(140));
  94. _range.vector3Value = EditorGUILayout.Vector3Field("",_range.vector3Value, GUILayout.Width(300));
  95. EditorGUILayout.EndHorizontal();
  96. EditorGUILayout.BeginHorizontal();
  97. GUILayout.Label("子弹挂载点:", EditorStyles.label, GUILayout.Width(140));
  98. bulletLinkIdx = EditorGUILayout.Popup(bulletLinkIdx, linkPoints,GUILayout.Width(300));
  99. if(bulletLinkIdx >= 0)
  100. _bulletLink.stringValue = linkPoints[bulletLinkIdx];
  101. EditorGUILayout.EndHorizontal();
  102. EditorGUILayout.BeginHorizontal();
  103. GUILayout.Label("子弹最长飞行时长:", EditorStyles.label, GUILayout.Width(140));
  104. _bulletFlyDuration.floatValue = EditorGUILayout.FloatField(_bulletFlyDuration.floatValue, GUILayout.Width(300));
  105. EditorGUILayout.EndHorizontal();
  106. EditorGUILayout.BeginHorizontal();
  107. GUILayout.Label("子弹初速度:", EditorStyles.label, GUILayout.Width(140));
  108. _bulletInitVelocity.vector3Value = EditorGUILayout.Vector3Field("", _bulletInitVelocity.vector3Value, GUILayout.Width(300));
  109. EditorGUILayout.EndHorizontal();
  110. EditorGUILayout.BeginHorizontal();
  111. GUILayout.Label("子弹加速度:", EditorStyles.label, GUILayout.Width(140));
  112. _bulletAcceleration.vector3Value = EditorGUILayout.Vector3Field("", _bulletAcceleration.vector3Value, GUILayout.Width(300));
  113. EditorGUILayout.EndHorizontal();
  114. EditorGUILayout.BeginHorizontal();
  115. GUILayout.Label("加速度时间:", EditorStyles.label, GUILayout.Width(140));
  116. _bulletAccelerationTime.floatValue = EditorGUILayout.FloatField(_bulletAccelerationTime.floatValue, GUILayout.Width(300));
  117. EditorGUILayout.EndHorizontal();
  118. EditorGUILayout.BeginHorizontal();
  119. GUILayout.Label("打中目标位置:", EditorStyles.label, GUILayout.Width(140));
  120. bulletTargetLinkIdx = EditorGUILayout.Popup(bulletTargetLinkIdx, linkPoints, GUILayout.Width(300));
  121. if(bulletTargetLinkIdx >= 0)
  122. _bulletTargetLink.stringValue = linkPoints[bulletTargetLinkIdx];
  123. EditorGUILayout.EndHorizontal();
  124. EditorGUILayout.BeginHorizontal();
  125. GUILayout.Label("命中特效id:", EditorStyles.label, GUILayout.Width(140));
  126. _hitEffectId.intValue = EditorGUILayout.IntField(_hitEffectId.intValue,GUILayout.Width(300));
  127. EditorGUILayout.EndHorizontal();
  128. EditorGUILayout.BeginHorizontal();
  129. GUILayout.Label("命中特效预设:", EditorStyles.label, GUILayout.Width(140));
  130. _hitEffectPrefab.objectReferenceValue = EditorGUILayout.ObjectField(_hitEffectPrefab.objectReferenceValue, typeof(GameObject), false, GUILayout.Width(300));
  131. GUILayout.Label("挂载点:", EditorStyles.label, GUILayout.Width(140));
  132. hitEffectLinkIdx = EditorGUILayout.Popup(hitEffectLinkIdx, linkPoints, GUILayout.Width(300));
  133. if (hitEffectLinkIdx >= 0)
  134. _hitEffectLink.stringValue = linkPoints[hitEffectLinkIdx];
  135. EditorGUILayout.EndHorizontal();
  136. EditorGUILayout.BeginHorizontal();
  137. GUILayout.Label("击中目标效果:", EditorStyles.label, GUILayout.Width(140));
  138. _moveType.intValue = EditorGUILayout.IntPopup(_moveType.intValue, moveTypeStrs, moveTypes, GUILayout.Width(300));
  139. EditorGUILayout.EndHorizontal();
  140. if(_moveType.intValue == (int)FighterMoveType.Beat_Back)
  141. {
  142. EditorGUILayout.BeginHorizontal();
  143. GUILayout.Label("击退初速度:", EditorStyles.label, GUILayout.Width(140));
  144. _initSpeed.floatValue = EditorGUILayout.FloatField(_initSpeed.floatValue);
  145. EditorGUILayout.EndHorizontal();
  146. EditorGUILayout.BeginHorizontal();
  147. GUILayout.Label("击退加速度:", EditorStyles.label, GUILayout.Width(140));
  148. _acceleration.floatValue = EditorGUILayout.FloatField(_acceleration.floatValue);
  149. EditorGUILayout.EndHorizontal();
  150. EditorGUILayout.BeginHorizontal();
  151. GUILayout.Label("击退距离:", EditorStyles.label, GUILayout.Width(140));
  152. _moveDistance.floatValue = EditorGUILayout.FloatField(_moveDistance.floatValue);
  153. EditorGUILayout.EndHorizontal();
  154. }else if(_moveType.intValue == (int)FighterMoveType.Beat_Fly)
  155. {
  156. EditorGUILayout.BeginHorizontal();
  157. GUILayout.Label("挑飞初速度:", EditorStyles.label, GUILayout.Width(140));
  158. _initSpeed.floatValue = EditorGUILayout.FloatField(_initSpeed.floatValue);
  159. EditorGUILayout.EndHorizontal();
  160. EditorGUILayout.BeginHorizontal();
  161. GUILayout.Label("挑飞加速度:", EditorStyles.label, GUILayout.Width(140));
  162. _acceleration.floatValue = EditorGUILayout.FloatField(_acceleration.floatValue);
  163. EditorGUILayout.EndHorizontal();
  164. EditorGUILayout.BeginHorizontal();
  165. GUILayout.Label("挑飞高度:", EditorStyles.label, GUILayout.Width(140));
  166. _moveDistance.floatValue = EditorGUILayout.FloatField(_moveDistance.floatValue);
  167. EditorGUILayout.EndHorizontal();
  168. }
  169. EditorGUILayout.BeginHorizontal();
  170. GUILayout.Label("触发buffID:", EditorStyles.label, GUILayout.Width(140));
  171. _triggerBuffId.intValue = EditorGUILayout.IntField(_triggerBuffId.intValue, GUILayout.Width(300));
  172. EditorGUILayout.EndHorizontal();
  173. EditorGUILayout.BeginHorizontal();
  174. GUILayout.Label("触发buff概率:", EditorStyles.label, GUILayout.Width(140));
  175. _triggerBuffRate.intValue = EditorGUILayout.IntField(_triggerBuffRate.intValue, GUILayout.Width(300));
  176. EditorGUILayout.EndHorizontal();
  177. serializedObject.ApplyModifiedProperties();
  178. }
  179. }
  180. }