Net3DViewManager.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class Net3DViewManager : MonoBehaviour
  5. {
  6. [SerializeField]
  7. private Transform WorldParent;
  8. void Start()
  9. {
  10. MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//进入房间
  11. MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, ExitCourse);//关闭房间
  12. MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_COURSE, ShowCourse);//显示房间
  13. MessageCenterController.Instance.Register(GameEnum.MESSAGE_HIDE_COURSE, HideCourse);//隐藏房间
  14. }
  15. private void OnDestroy()
  16. {
  17. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//进入房间
  18. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, ExitCourse);//关闭房间
  19. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_COURSE, ShowCourse);//显示房间
  20. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_HIDE_COURSE, HideCourse);//隐藏房间
  21. }
  22. private GameObject curObj;
  23. private void EnterCourse(System.Object datas = null)
  24. {
  25. return;
  26. string obj_path = "Prefabs/PointCloud/PointCloud";
  27. Object res_obj = Resources.Load(obj_path);
  28. curObj = GameObject.Instantiate(res_obj) as GameObject;
  29. curObj.transform.parent = WorldParent;
  30. curObj.transform.localPosition = Vector3.zero;//不允许有默认的位置
  31. curObj.gameObject.SetActive(true);
  32. }
  33. private void ShowCourse(System.Object datas = null)
  34. {
  35. if(curObj != null)
  36. {
  37. curObj.gameObject.SetActive(true);
  38. }
  39. }
  40. private void HideCourse(System.Object datas = null)
  41. {
  42. if (curObj != null)
  43. {
  44. curObj.gameObject.SetActive(true);
  45. }
  46. }
  47. private void ExitCourse(System.Object datas = null)
  48. {
  49. GameObject.Destroy(curObj);
  50. }
  51. }