1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Net3DViewManager : MonoBehaviour
- {
- [SerializeField]
- private Transform WorldParent;
- void Start()
- {
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//进入房间
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, ExitCourse);//关闭房间
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_COURSE, ShowCourse);//显示房间
- MessageCenterController.Instance.Register(GameEnum.MESSAGE_HIDE_COURSE, HideCourse);//隐藏房间
- }
- private void OnDestroy()
- {
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, EnterCourse);//进入房间
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, ExitCourse);//关闭房间
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_SHOW_COURSE, ShowCourse);//显示房间
- MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_HIDE_COURSE, HideCourse);//隐藏房间
- }
- private GameObject curObj;
- private void EnterCourse(System.Object datas = null)
- {
- return;
- string obj_path = "Prefabs/PointCloud/PointCloud";
- Object res_obj = Resources.Load(obj_path);
- curObj = GameObject.Instantiate(res_obj) as GameObject;
- curObj.transform.parent = WorldParent;
- curObj.transform.localPosition = Vector3.zero;//不允许有默认的位置
- curObj.gameObject.SetActive(true);
- }
- private void ShowCourse(System.Object datas = null)
- {
- if(curObj != null)
- {
- curObj.gameObject.SetActive(true);
- }
- }
- private void HideCourse(System.Object datas = null)
- {
- if (curObj != null)
- {
- curObj.gameObject.SetActive(true);
- }
- }
- private void ExitCourse(System.Object datas = null)
- {
- GameObject.Destroy(curObj);
- }
- }
|