PopulationSystemManagerEditor.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEditor;
  4. [CustomEditor(typeof(PopulationSystemManager))]
  5. public class PopulationSystemManagerEditor : Editor {
  6. public override void OnInspectorGUI()
  7. {
  8. PopulationSystemManager _PSM = target as PopulationSystemManager;
  9. if(_PSM.isConcert || _PSM.isStreet)
  10. {
  11. EditorGUILayout.HelpBox("Click left mouse button in point", MessageType.Info);
  12. }
  13. else
  14. DrawDefaultInspector();
  15. }
  16. public void OnSceneGUI()
  17. {
  18. PopulationSystemManager _PSM = target as PopulationSystemManager;
  19. if(Event.current.type == EventType.MouseMove) SceneView.RepaintAll();
  20. if(_PSM.isConcert || _PSM.isStreet)
  21. {
  22. EditorGUILayout.HelpBox("Click left mouse button in point", MessageType.Info);
  23. RaycastHit hit;
  24. Vector2 mPos = Event.current.mousePosition;
  25. mPos.y = Screen.height - mPos.y - 40;
  26. Ray ray = Camera.current.ScreenPointToRay(mPos);
  27. if (Physics.Raycast(ray, out hit, 3000))
  28. {
  29. _PSM.mousePos = hit.point;
  30. if((Event.current.type == EventType.MouseDown && Event.current.button == 0))
  31. {
  32. if(_PSM.isConcert)
  33. {
  34. _PSM.Concert(_PSM.mousePos);
  35. _PSM.isConcert = false;
  36. }
  37. else if(_PSM.isStreet)
  38. {
  39. _PSM.Street(_PSM.mousePos);
  40. _PSM.isStreet = false;
  41. }
  42. }
  43. }
  44. }
  45. }
  46. }