using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 场景的设置 /// public class ProjectConfiguration : MonoBehaviour { public int cubeLength; public CubeItem item; public Transform trackingTarget; public Camera camera; private TestData data; void Start() { data = new TestData(); data.Length = 40; data.UIInterval = 1; //data.EulerAngleX = false; //data.EulerAngleY = true; //data.EulerAngleZ = false; data.EulerAxle = 2; data.CameraFar = 2; data.isShowMeasure = false; data.FadeDis = 1; data.ShowDis = 0.4f; } private void Init() { //camera.farClipPlane = data.CameraFar; BladeServerManager.Instance.showDis = data.ShowDis; BladeServerManager.Instance.fadeDis = data.FadeDis; if (!data.isShowMeasure) return; for (float i = 0; i < data.Length+1; i+=data.UIInterval) { GameObject obj = GameObject.Instantiate(item.gameObject, transform); obj.name = i.ToString(); obj.transform.localPosition = new Vector3(0, 0.1f, -i); obj.GetComponent().text.text = i.ToString() + " M"; obj.SetActive(true); } } // Update is called once per frame void Update() { if(trackingTarget!=null) { switch (data.EulerAxle) { case 1: transform.eulerAngles = new Vector3(0, trackingTarget.eulerAngles.x, 0); break; case 2: transform.eulerAngles = new Vector3(0, trackingTarget.eulerAngles.y, 0); break; case 3: transform.eulerAngles = new Vector3(0, trackingTarget.eulerAngles.z, 0); break; default: break; } transform.position = trackingTarget.position; } } public void Test() { } } public class TestData { public int Length { get; set; }// 需要显示的长度 public float CameraFar { get; set; } // Camera的可见距离 public float UIInterval { get; set; } // 间隔多少米显示距离UI 0.5m/1m/.... //public bool EulerAngleX { get; set; } // 是否同步Tag X轴旋转 //public bool EulerAngleY { get; set; } // 是否同步Tag Y轴旋转 //public bool EulerAngleZ { get; set; } // 是否同步Tag Z轴旋转 public int EulerAxle { get; set; } // 跟随哪个轴旋转 1 X轴 2 Y轴 3 Z轴 public float ShowDis { get; set; } // 机柜详细信息 显示的距离 public float FadeDis { get; set; } // 机柜详细信息 消失的距离 public bool isShowMeasure { get; set; } // 是否显示测量长度的Demo }