123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230 |
- 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<string, List<Vector3>> dicStep;
- private void Start()
- {
- // targetObj = null;
- dicStep = new Dictionary<string, List<Vector3>>();
- dicStep.Add("PosStep", new List<Vector3>());
- dicStep.Add("RotStep", new List<Vector3>());
- dicStep.Add("ScaleStep", new List<Vector3>());
- }
- /// <summary>
- /// 切换显示景点
- /// </summary>
- public void CustTargetObj()
- {
- targetObj = null;
- dicStep.Clear();
- }
- /// <summary>
- /// 选择显示景点
- /// </summary>
- /// <param name="obj"></param>
- public void SelectTargetObj(Transform obj)
- {
- targetObj = obj;
- dicStep.Clear();
- dicStep = new Dictionary<string, List<Vector3>>();
- dicStep.Add("PosStep", new List<Vector3>());
- dicStep.Add("RotStep", new List<Vector3>());
- dicStep.Add("ScaleStep", new List<Vector3>());
- }
- /// <summary>
- /// 根据传进来的Json数据,生成场景列表和每个场景对应的显示物体列表
- /// 默认是在扫图模式下修改
- /// 点云模式下直接加载点云模型修改点云模型内物体的位置信息
- /// </summary>
- 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<Vector3>();
- break;
- case "rot":
- if (dicStep["RotStep"].Count < 1)
- return;
- targetObj.localEulerAngles = dicStep["RotStep"][0];
- dicStep["RotStep"].Clear();
- dicStep["RotStep"] = new List<Vector3>();
- break;
- case "scale":
- if (dicStep["ScaleStep"].Count < 1)
- return;
- targetObj.localScale = dicStep["ScaleStep"][0];
- dicStep["ScaleStep"].Clear();
- dicStep["ScaleStep"] = new List<Vector3>();
- break;
- default:
- break;
- }
- }
- }
|