using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using CommonScript; public class LoaclInterObjectWatch : MonoBehaviour { private Transform Localwatch; private GameObject clone; public bool 是否旋转 = true; /// <summary> /// 单独显示初始位置和坐标 /// </summary> public Vector3 showPosition; public Vector3 showRot; public Vector3 localscale=new Vector3 (1,1,1); /// <summary> /// 单独观察的UI界面 /// </summary> private GameObject 单独观察; Button 关闭按钮; Transform MAINui; GameObject PlayerCamera; // Start is called before the first frame update void Start() { Localwatch = GameObject.Find("Localwatch").transform; EventTriggerListener.Get(gameObject).onClick += g => { onClick(); }; //onClick(); } // Update is called once per frame void Update() { } public void onClick() { ///生成UI MAINui = GameObject.Find("MainUI").transform; var load = Resources.Load("Prefab/单独观察"); 单独观察 = Instantiate(load) as GameObject; 单独观察.transform.SetParent(MAINui); 单独观察.transform.localPosition = new Vector3(0, 0, 0); 单独观察.GetComponent<RectTransform>().offsetMax = new Vector2(0, 0); 单独观察.GetComponent<RectTransform>().offsetMin = new Vector2(0, 0); 单独观察.transform.localEulerAngles = new Vector3(0, 0, 0); 单独观察.transform.localScale = new Vector3(1, 1, 1); 关闭按钮 = GameObject.Find("LocalDestory").GetComponent<Button>(); ///打开摄像机滤镜 PlayerCamera = GameObject.Find("PlayerCamera"); PlayerCamera.GetComponent<CameraFilterPack_Blur_GaussianBlur>().enabled = true; ///生成物体 clone = Instantiate(gameObject); ; Destroy(clone.GetComponent<LoaclInterObjectWatch>()); if (clone.GetComponent<HighlightingSystem.Highlighter>()) { Destroy(clone.GetComponent<HighlightingSystem.Highlighter>()); } clone.transform.SetParent(Localwatch); clone.transform.localPosition = showPosition; clone.transform.localEulerAngles = showRot; clone.transform.localScale = localscale; if (是否旋转 == true) { clone.AddComponent<KXScanOperator>(); } clone.layer = 13; 关闭按钮.onClick.AddListener(desbutton); } /// <summary> /// 销毁物体并重置滤镜 /// </summary> public void desbutton() { PlayerCamera.GetComponent<CameraFilterPack_Blur_GaussianBlur>().enabled = false; Destroy(clone.gameObject); Destroy(单独观察); } }