using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIManager : MonoBehaviour { public RectTransform pos_Panel; public RectTransform rot_Panel; public RectTransform scale_Panel; public Transform targetObj; public Dictionary> dicStep; private void Start() { // targetObj = null; dicStep = new Dictionary>(); dicStep.Add("PosStep", new List()); dicStep.Add("RotStep", new List()); dicStep.Add("ScaleStep", new List()); } /// /// 切换显示景点 /// public void CustTargetObj() { targetObj = null; dicStep.Clear(); } /// /// 选择显示景点 /// /// public void SelectTargetObj(Transform obj) { targetObj = obj; dicStep.Clear(); dicStep = new Dictionary>(); dicStep.Add("PosStep", new List()); dicStep.Add("RotStep", new List()); dicStep.Add("ScaleStep", new List()); } /// /// 根据传进来的Json数据,生成场景列表和每个场景对应的显示物体列表 /// 默认是在扫图模式下修改 /// 点云模式下直接加载点云模型修改点云模型内物体的位置信息 /// public void Initiative() { } public void SelectPanel(string togName) { switch (togName) { case "pos_tog": pos_Panel.gameObject.SetActive(true); rot_Panel.gameObject.SetActive(false); scale_Panel.gameObject.SetActive(false); break; case "rot_tog": pos_Panel.gameObject.SetActive(false); rot_Panel.gameObject.SetActive(true); scale_Panel.gameObject.SetActive(false); break; case "scale_tog": pos_Panel.gameObject.SetActive(false); rot_Panel.gameObject.SetActive(false); scale_Panel.gameObject.SetActive(true); break; default: break; } } public void SettingPos(string setName) { Debug.Log("1"); if (targetObj == null) return; Debug.Log(setName+"11"); Vector3 pos = Vector3.zero; switch (setName) { case "addX": pos.x = 0.2f; break; case "subX": pos.x = -0.2f; break; case "addY": pos.y = 0.1f; break; case "subY": pos.y = -0.1f; break; case "addZ": pos.z = 0.1f; break; case "subZ": pos.z = -0.1f; break; default: break; } dicStep["PosStep"].Add(targetObj.localPosition); Debug.Log(targetObj.localPosition); targetObj.localPosition += pos; Debug.Log(targetObj.localPosition); Debug.Log("3"); } public void SettingRot(string setName) { if (targetObj == null) return; Vector3 rot = Vector3.zero; switch (setName) { case "addX": rot.x = 5f; break; case "subX": rot.x = -5f; break; case "addY": rot.y = 5f; break; case "subY": rot.y = -5f; break; case "addZ": rot.z = 5f; break; case "subZ": rot.z = -5f; break; default: break; } dicStep["RotStep"].Add(targetObj.localEulerAngles); targetObj.localEulerAngles += rot; } public void SettingScale(string setName) { if (targetObj == null) return; Vector3 scale = Vector3.zero; switch (setName) { case "ADD": scale = new Vector3(0.1f, 0.1f, 0.1f); break; case "Sub": scale = new Vector3(-0.1f, -0.1f, -0.1f); break; default: break; } dicStep["ScaleStep"].Add(targetObj.localScale); targetObj.localScale += scale; } public void Revocation(string TName) { Debug.Log("Revocation:"+ TName); switch (TName) { case "pos": if (dicStep["PosStep"].Count < 1) return; targetObj.localPosition = dicStep["PosStep"][dicStep["PosStep"].Count - 1]; dicStep["PosStep"].RemoveAt(dicStep["PosStep"].Count - 1); break; case "rot": if (dicStep["RotStep"].Count < 1) return; targetObj.localEulerAngles = dicStep["RotStep"][dicStep["RotStep"].Count - 1]; dicStep["RotStep"].RemoveAt(dicStep["RotStep"].Count - 1); break; case "scale": if (dicStep["ScaleStep"].Count < 1) return; targetObj.localScale = dicStep["ScaleStep"][dicStep["ScaleStep"].Count - 1]; dicStep["ScaleStep"].RemoveAt(dicStep["ScaleStep"].Count - 1); break; default: break; } } public void InitDicStep(string TName) { Debug.Log("Revocation:" + TName); switch (TName) { case "pos": if (dicStep["PosStep"].Count < 1) return; targetObj.localPosition = dicStep["PosStep"][0]; dicStep["PosStep"].Clear(); dicStep["PosStep"] = new List(); break; case "rot": if (dicStep["RotStep"].Count < 1) return; targetObj.localEulerAngles = dicStep["RotStep"][0]; dicStep["RotStep"].Clear(); dicStep["RotStep"] = new List(); break; case "scale": if (dicStep["ScaleStep"].Count < 1) return; targetObj.localScale = dicStep["ScaleStep"][0]; dicStep["ScaleStep"].Clear(); dicStep["ScaleStep"] = new List(); break; default: break; } } }