TowerBattleInfoPointEditor.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using UnityEngine;
  2. using UnityEditor;
  3. [CustomEditor(typeof(TowerBattleInfoPoint))]
  4. public class TowerBattleInfoPointEditor : Editor
  5. {
  6. TowerBattleInfoPoint point;
  7. private void OnEnable()
  8. {
  9. point = target as TowerBattleInfoPoint;
  10. }
  11. public override void OnInspectorGUI()
  12. {
  13. serializedObject.Update();
  14. EditorGUILayout.BeginVertical();
  15. point.spawnDist = EditorGUILayout.FloatField("对手出生距离", point.spawnDist,GUILayout.Width(200));
  16. point.battleDist = EditorGUILayout.FloatField("双方开战距离", point.battleDist,GUILayout.Width(200));
  17. EditorGUILayout.LabelField("相机配置:", GUILayout.Width(300));
  18. if(point.CamCfgList!=null)
  19. {
  20. GameObject camGo = GameObject.Find("camera_target");
  21. for (int idx =0; idx < point.CamCfgList.Count;idx++)
  22. {
  23. MapCameraConfig camCfg = point.CamCfgList[idx];
  24. camCfg.pos = EditorGUILayout.Vector3Field("相机位置:", camCfg.pos, GUILayout.Width(200));
  25. camCfg.rot = EditorGUILayout.Vector3Field("相机旋转:", camCfg.rot, GUILayout.Width(200));
  26. camCfg.fov = EditorGUILayout.FloatField("相机FOV:", camCfg.fov, GUILayout.Width(200));
  27. camCfg.moveSpeed = EditorGUILayout.FloatField("相机移动速度:", camCfg.moveSpeed, GUILayout.Width(200));
  28. camCfg.rotSpeed = EditorGUILayout.FloatField("相机旋转速度:", camCfg.rotSpeed, GUILayout.Width(200));
  29. camCfg.fovSpeed = EditorGUILayout.FloatField("相机FOV速度:", camCfg.fovSpeed, GUILayout.Width(200));
  30. if (GUILayout.Button("查看镜头"))
  31. {
  32. if (camGo != null)
  33. {
  34. camGo.transform.position = camCfg.pos;
  35. camGo.transform.rotation = Quaternion.Euler(camCfg.rot);
  36. Camera cam = camGo.GetComponentInChildren<Camera>();
  37. if (cam != null)
  38. cam.fieldOfView = camCfg.fov;
  39. }
  40. }
  41. else if(GUILayout.Button("删除镜头"))
  42. {
  43. point.CamCfgList.RemoveAt(idx);
  44. return;
  45. }
  46. }
  47. }
  48. if(GUILayout.Button("添加新镜头"))
  49. {
  50. MapCameraConfig newCamCfg = new MapCameraConfig();
  51. if (point.CamCfgList == null)
  52. point.CamCfgList = new System.Collections.Generic.List<MapCameraConfig>();
  53. point.CamCfgList.Add(newCamCfg);
  54. }
  55. GameObject actorBornGo = GameObject.Find("ActorBornPoint");
  56. if (actorBornGo != null)
  57. {
  58. ReadyPoint rp = actorBornGo.GetComponent<ReadyPoint>();
  59. if (rp != null)
  60. {
  61. Vector3 center = point.transform.position + point.transform.forward * point.battleDist;
  62. Vector3 rot = point.transform.rotation.eulerAngles;
  63. rot.y = 180 + rot.y;
  64. rp.CalcNextBattleFieldPoints(center, rot);
  65. }
  66. }
  67. GameObject enemyBornGo = GameObject.Find("EnemyActorBornPoint");
  68. if (enemyBornGo != null)
  69. {
  70. ReadyPoint rp = actorBornGo.GetComponent<ReadyPoint>();
  71. if (rp != null)
  72. {
  73. Vector3 center = point.transform.position - point.transform.forward * point.battleDist;
  74. Vector3 rot = point.transform.rotation.eulerAngles;
  75. rp.CalcNextBattleFieldPoints(center, rot);
  76. }
  77. }
  78. EditorGUILayout.EndVertical();
  79. }
  80. }