浮标点和相机停靠点外置,用resources加载图片,删除脚本文件夹分类
This commit is contained in:
@@ -9,25 +9,37 @@ using UnityEngine.UI;
|
||||
|
||||
struct RequiredInformation
|
||||
{
|
||||
|
||||
public string SNWithdeviceName;
|
||||
public Vector3 localPosition;
|
||||
public string customName;//这个是浮标上面的文本,自己命的名
|
||||
public string pictureSerialNumber;//MT开头的图片
|
||||
public RequiredInformation(string sn, Vector3 pos, string name, string picSn)
|
||||
public string tag;//用tag来显示sorting Icons
|
||||
public RequiredInformation(string sn, Vector3 pos, string name, string picSn,string tag)
|
||||
{
|
||||
SNWithdeviceName = sn;
|
||||
localPosition = pos;
|
||||
customName = name;
|
||||
pictureSerialNumber = picSn;
|
||||
this.tag = tag;
|
||||
}
|
||||
public RequiredInformation(string sn, string name, string picSn, string tag)
|
||||
{
|
||||
SNWithdeviceName = sn;
|
||||
localPosition = Vector3.zero;
|
||||
customName = name;
|
||||
pictureSerialNumber = picSn;
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
public class AskForWEBInfomation : MonoBehaviour
|
||||
{
|
||||
public GameObject ICONSPosition;//把ICONSPosition拖进来提供我的这些浮标的位置
|
||||
public Camera cam;
|
||||
|
||||
public GameObject buoy;//把BUoy预制体拖进来,使用代码自动生成ICON的子物体
|
||||
|
||||
public List<Sprite> pictures = new List<Sprite>();//把图片预制体都拖过来
|
||||
// public List<Sprite> pictures = new List<Sprite>();//把图片预制体都拖过来
|
||||
[Serializable]
|
||||
public class IdentifierTextBinding
|
||||
{
|
||||
@@ -48,25 +60,25 @@ public class AskForWEBInfomation : MonoBehaviour
|
||||
|
||||
"ys_2026020420","ys_2026020419","ys_2026020418","ys_2026020417","ys_2026020416","ys_2026020415"
|
||||
};
|
||||
List<RequiredInformation> info = new List<RequiredInformation>()
|
||||
{
|
||||
new RequiredInformation("ys_2026020415_sb_gnss001",new Vector3(10.9530001f,-10.7779989f,-1.75300026f),"GNSS","MT014") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji001",new Vector3(-0.25177002f,-0.00340000005f,3.51672745f),"无线倾角计1","倾角图标") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji002",new Vector3(-3.22239995f,-0.0055999998f,1.67970002f),"无线倾角计2","倾角图标") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji003",new Vector3(-0.254400015f,-0.00449999981f,-0.108400002f),"无线倾角计3","倾角图标") ,
|
||||
new RequiredInformation("ys_2026020417_sb_fengjizhendong001",new Vector3(1.14961243f,55.1254196f,2.07600784f),"振动加速度1","MT019") ,
|
||||
new RequiredInformation("ys_2026020417_sb_fengjizhendong002",new Vector3(1.14961243f,55.1785011f,1.38459396f),"振动加速度2","MT019") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji001",new Vector3(-1.90900004f,10.3079996f,3.55800009f),"应变计1","MT013") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji002",new Vector3(-3.17600012f,10.2980003f,1.66199994f),"应变计2","MT013") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji003",new Vector3(-1.87399995f,10.2880001f,-0.150199994f),"应变计3","MT013") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji004",new Vector3(0.349900007f,10.2938004f,0.450199991f),"应变计4","MT013") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji005",new Vector3(0.400999993f,10.2967997f,2.88899994f),"应变计5","MT013") ,
|
||||
new RequiredInformation("ys_2026020419_sb_wenshiya001",new Vector3(-69.6037674f,-33.9762917f,141.763977f),"温湿压1","温湿图标") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi001",new Vector3(10.7563248f,-12.5099993f,-1.32729721f),"静力水准仪1","MT014") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi002",new Vector3(-1.17034912f,-12.5128984f,4.73325729f),"静力水准仪2","MT014") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi003",new Vector3(-1.17050004f,-12.5162926f,-1.3204f),"静力水准仪3","MT014") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi004",new Vector3(1.83947754f,-12.5169001f,1.70901871f),"静力水准仪4","MT014") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi005",new Vector3(-4.20899963f,-12.5176001f,1.70901871f),"静力水准仪5","MT014") ,
|
||||
List<RequiredInformation> infos = new List<RequiredInformation>()
|
||||
{ //构造函数现在可以直接加3个,我现在已经通过读取场景中的位置来调节位置了,这里也不想再删它了,后面读取的时候再覆盖一下这里也不影响.
|
||||
new RequiredInformation("ys_2026020415_sb_gnss001",new Vector3(10.9530001f,-10.7779989f,-1.75300026f),"GNSS","MT014","沉降监测") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji001",new Vector3(-0.25177002f,-0.00340000005f,3.51672745f),"无线倾角计1","倾角图标","倾角监测") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji002",new Vector3(-3.22239995f,-0.0055999998f,1.67970002f),"无线倾角计2","倾角图标","倾角监测") ,
|
||||
new RequiredInformation("ys_2026020416_sb_wuxianqingjiaoji003",new Vector3(-0.254400015f,-0.00449999981f,-0.108400002f),"无线倾角计3","倾角图标","倾角监测") ,
|
||||
new RequiredInformation("ys_2026020417_sb_fengjizhendong001",new Vector3(1.14961243f,55.1254196f,2.07600784f),"振动加速度1","MT019","振动加速度") ,
|
||||
new RequiredInformation("ys_2026020417_sb_fengjizhendong002",new Vector3(1.14961243f,55.1785011f,1.38459396f),"振动加速度2","MT019","振动加速度") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji001",new Vector3(-1.90900004f,10.3079996f,3.55800009f),"应变计1","MT013","应变监测") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji002",new Vector3(-3.17600012f,10.2980003f,1.66199994f),"应变计2","MT013","应变监测") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji003",new Vector3(-1.87399995f,10.2880001f,-0.150199994f),"应变计3","MT013","应变监测") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji004",new Vector3(0.349900007f,10.2938004f,0.450199991f),"应变计4","MT013","应变监测") ,
|
||||
new RequiredInformation("ys_2026020418_sb_yingbianji005",new Vector3(0.400999993f,10.2967997f,2.88899994f),"应变计5","MT013","应变监测") ,
|
||||
new RequiredInformation("ys_2026020419_sb_wenshiya001",new Vector3(-69.6037674f,-33.9762917f,141.763977f),"温湿压1","温湿图标","气象监测") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi001",new Vector3(10.7563248f,-12.5099993f,-1.32729721f),"静力水准仪1","MT014","沉降监测") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi002",new Vector3(-1.17034912f,-12.5128984f,4.73325729f),"静力水准仪2","MT014","沉降监测") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi003",new Vector3(-1.17050004f,-12.5162926f,-1.3204f),"静力水准仪3","MT014","沉降监测") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi004",new Vector3(1.83947754f,-12.5169001f,1.70901871f),"静力水准仪4","MT014","沉降监测") ,
|
||||
new RequiredInformation("ys_2026020420_sb_yachashi005",new Vector3(-4.20899963f,-12.5176001f,1.70901871f),"静力水准仪5","MT014","沉降监测") ,
|
||||
|
||||
};
|
||||
|
||||
@@ -129,13 +141,23 @@ public class AskForWEBInfomation : MonoBehaviour
|
||||
}
|
||||
private void InitiateICONS()
|
||||
{
|
||||
foreach (RequiredInformation info in info)
|
||||
//使用 info 之前要先用 ICONPosition 来调整一下里面的位置,用 foreach 还不能改,只能用 for 循环慢慢改回去
|
||||
for (int i = 0; i < infos.Count; i++)
|
||||
{
|
||||
RequiredInformation info = infos[i];
|
||||
info.localPosition = ICONSPosition.transform.Find(info.SNWithdeviceName).localPosition;
|
||||
infos[i] = info;
|
||||
}
|
||||
|
||||
//开始用修改好的infos来工作
|
||||
foreach (RequiredInformation info in infos)
|
||||
{
|
||||
//生成一个预制体
|
||||
GameObject obj = Instantiate(buoy);
|
||||
obj.name = info.SNWithdeviceName;
|
||||
obj.transform.SetParent(transform);
|
||||
obj.transform.localPosition = info.localPosition;
|
||||
obj.tag = info.tag;//添加标签
|
||||
|
||||
//开始修理预制体下面的响应函数和text
|
||||
int first = obj.name.IndexOf("_");
|
||||
@@ -156,14 +178,15 @@ public class AskForWEBInfomation : MonoBehaviour
|
||||
ManuallyLoadOneDevice(obj.name);
|
||||
}
|
||||
);
|
||||
foreach (Sprite img in pictures)//遍历图片数组,如果找到就结束
|
||||
{
|
||||
if (img.name == info.pictureSerialNumber)
|
||||
{
|
||||
obj.transform.GetChild(0).GetComponent<Image>().sprite = img;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* foreach (Sprite img in pictures)//遍历图片数组,如果找到就结束,现在改成用 Resources 直接加载
|
||||
{
|
||||
if (img.name == info.pictureSerialNumber)
|
||||
{
|
||||
obj.transform.GetChild(0).GetComponent<Image>().sprite = img;
|
||||
break;
|
||||
}
|
||||
}*/
|
||||
obj.transform.GetChild(0).GetComponent<Image>().sprite = Resources.Load<Sprite>("Icons/"+info.pictureSerialNumber);
|
||||
|
||||
//第二个子物体负责浮标上面的文字描述
|
||||
obj.transform.GetChild(1).name = deviceName + "Text";
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 500eaa2b56c2c074ab576689486fd19f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4986223817693bc41adb331833d466b5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,29 +3,29 @@ using System.Collections.Generic;
|
||||
//using System.Diagnostics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
//这个脚本的名字是双击跳转,按照庄公的需求全部改成单击,名字的问题就先不考虑了,这里给他修改成单击,但是保留了双击的逻辑,以便以后方便切换回来
|
||||
//把脚本复制一份上面是单击版本,下面是双击版本
|
||||
//单击双击问题最终确定,图标单击,传感器和房子双击,这样唯一问题就是双击图标怎么办,算了,妥协吧,设置为blocking objects为3d,这样不能跨越穿越,妥协了
|
||||
//这个脚本的名字是双击跳转,按照庄公的需求全部改成单击,名字的问题就先不考虑了,这里给他修改成单击,但是保留了双击的逻辑,以便以后方便切换回来
|
||||
//把脚本复制一份上面是单击版本,下面是双击版本
|
||||
//单击双击问题最终确定,图标单击,传感器和房子双击,这样唯一问题就是双击图标怎么办,算了,妥协吧,设置为blocking objects为3d,这样不能跨越穿越,妥协了
|
||||
//public class DoubleClickToFocus : MonoBehaviour
|
||||
//{
|
||||
// private Dictionary<string, Vector3> targetObjectAndPosition = new Dictionary<string, Vector3>();//使用字典数据类型来定义每一个物体自己对应的观察点位置
|
||||
// private Dictionary<string, Vector3> targetObjectAndPosition = new Dictionary<string, Vector3>();//使用字典数据类型来定义每一个物体自己对应的观察点位置
|
||||
|
||||
// [Tooltip("平滑过渡所用时间(秒)")] public float transitionDuration = 1.0f;
|
||||
// [Header("双击设置")]
|
||||
// [Tooltip("双击间隔时间阈值(秒)")] public float doubleClickInterval = 0.3f;
|
||||
// [Tooltip("平滑过渡所用时间(秒)")] public float transitionDuration = 1.0f;
|
||||
// [Header("双击设置")]
|
||||
// [Tooltip("双击间隔时间阈值(秒)")] public float doubleClickInterval = 0.3f;
|
||||
// //private float lastClickTime = 0f;
|
||||
// //private bool waitingSecondClick = false;
|
||||
// bool flying = false;//双击不需要用这种方式来确定,单击的话还是要的。
|
||||
// bool flying = false;//双击不需要用这种方式来确定,单击的话还是要的。
|
||||
// private Camera mainCamera;
|
||||
// public Vector3 core;
|
||||
|
||||
// private void Awake()
|
||||
// {
|
||||
// core = new Vector3(-50f, 20f, -30f);//初始旋转中心
|
||||
// core = new Vector3(-50f, 20f, -30f);//初始旋转中心
|
||||
// }
|
||||
// void Start()
|
||||
// {
|
||||
// mainCamera = Camera.main;//主相机的那个Camera组件跳转到的观测点
|
||||
// mainCamera = Camera.main;//主相机的那个Camera组件跳转到的观测点
|
||||
|
||||
// //targetObjectAndPosition.Add("tt_zhuta", new Vector3(53f, 16.3f, 27.62f));
|
||||
// //targetObjectAndPosition.Add("sb_fengsufengxiang400", new Vector3(12.23f, 11.38f, 27.62f));
|
||||
@@ -102,12 +102,12 @@ using UnityEngine.EventSystems;
|
||||
// public void HandleClick()
|
||||
// {
|
||||
// Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||
// if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity) && hit.collider.CompareTag("Target"))//应该给被打中的物体加一个标签,不然正常物体也会影响core,判断是否打中浮标或者是传感器本体,2者都要加上Target标签
|
||||
// if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity) && hit.collider.CompareTag("Target"))//应该给被打中的物体加一个标签,不然正常物体也会影响core,判断是否打中浮标或者是传感器本体,2者都要加上Target标签
|
||||
// {
|
||||
// Transform finalObject = hit.transform;//用浮标嫁祸给真实物体,浮标用ICON结尾,去除这个后缀就得到了真实物体的名字,不然浮标得单独打点,打点跳转也不好
|
||||
// Transform finalObject = hit.transform;//用浮标嫁祸给真实物体,浮标用ICON结尾,去除这个后缀就得到了真实物体的名字,不然浮标得单独打点,打点跳转也不好
|
||||
// if (finalObject.gameObject.name.EndsWith("ICON"))
|
||||
// {
|
||||
// string realObjName = finalObject.gameObject.name.Substring(0, finalObject.gameObject.name.Length - 4);//去尾法得到传感器名字,浮标名字只是在传感器名字后面加ICON,其他的不能动
|
||||
// string realObjName = finalObject.gameObject.name.Substring(0, finalObject.gameObject.name.Length - 4);//去尾法得到传感器名字,浮标名字只是在传感器名字后面加ICON,其他的不能动
|
||||
// finalObject = GameObject.Find(realObjName).transform;
|
||||
// }
|
||||
// foreach (KeyValuePair<string, Vector3> pair in targetObjectAndPosition)
|
||||
@@ -118,7 +118,7 @@ using UnityEngine.EventSystems;
|
||||
// StartCoroutine(MoveCamera(mainCamera, targetPos, transitionDuration, finalObject));
|
||||
// }
|
||||
// }
|
||||
// core = finalObject.position;//这里只要有 Target 被打中的话,你的旋转中心就会变,所以要确保被打中的物体一定是可以跳转的
|
||||
// core = finalObject.position;//这里只要有 Target 被打中的话,你的旋转中心就会变,所以要确保被打中的物体一定是可以跳转的
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -140,28 +140,29 @@ using UnityEngine.EventSystems;
|
||||
// cam.transform.position = targetPos;
|
||||
// cam.transform.LookAt(focusTarget);
|
||||
// flying = false;
|
||||
// if (cam.transform.position.y < 0.01f) //这个是为了防止部分设备太贴近地面,导致穿透地面里面出不来。让你的相机永远都在地面0.1米以上
|
||||
// if (cam.transform.position.y < 0.01f) //这个是为了防止部分设备太贴近地面,导致穿透地面里面出不来。让你的相机永远都在地面0.1米以上
|
||||
// {
|
||||
// Vector3 newPos = cam.transform.position;
|
||||
// // 2. 修改y轴值(x、z保持不变)
|
||||
// // 2. 修改y轴值(x、z保持不变)
|
||||
// newPos.y = 0.1f;
|
||||
// // 3. 重新赋值给position
|
||||
// // 3. 重新赋值给position
|
||||
// cam.transform.position = newPos;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------单击双击分界线
|
||||
//-------------------------------------------------------------------------------------------单击双击分界线
|
||||
|
||||
|
||||
public class DoubleClickToFocus : MonoBehaviour
|
||||
{
|
||||
private Dictionary<string, Vector3> targetObjectAndPosition = new Dictionary<string, Vector3>();//使用字典数据类型来定义每一个物体自己对应的观察点位置
|
||||
public GameObject CameraParkingPosition; //把这个东西拖进来,用它这里面在空间中的实际位置来给相机停靠点定位,下面一项加后面已经没有必要了。
|
||||
private Dictionary<string, Vector3> targetObjectAndPosition = new Dictionary<string, Vector3>();//使用字典数据类型来定义每一个物体自己对应的观察点位置
|
||||
|
||||
[Tooltip("平滑过渡所用时间(秒)")] public float transitionDuration = 1.5f;
|
||||
[Header("双击设置")]
|
||||
[Tooltip("双击间隔时间阈值(秒)")] public float doubleClickInterval = 0.3f;
|
||||
[Tooltip("平滑过渡所用时间(秒)")] public float transitionDuration = 1.5f;
|
||||
[Header("双击设置")]
|
||||
[Tooltip("双击间隔时间阈值(秒)")] public float doubleClickInterval = 0.3f;
|
||||
private float lastClickTime = 0f;
|
||||
private bool waitingSecondClick = false;
|
||||
|
||||
@@ -171,28 +172,20 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
bool flying = false;
|
||||
private void Awake()
|
||||
{
|
||||
core = new Vector3(-50f, 20f, -30f);//初始旋转中心
|
||||
core = new Vector3(-50f, 20f, -30f);//初始旋转中心
|
||||
}
|
||||
void Start()
|
||||
{
|
||||
mainCamera = Camera.main;//主相机的那个Camera组件跳转到的观测点
|
||||
mainCamera = Camera.main;//主相机的那个Camera组件跳转到的观测点
|
||||
|
||||
|
||||
foreach (Transform child in CameraParkingPosition.transform)
|
||||
{
|
||||
targetObjectAndPosition.Add(child.name, child.position);
|
||||
}
|
||||
|
||||
targetObjectAndPosition.Add("bx_talou", new Vector3(-82f, 37f, -100f));
|
||||
targetObjectAndPosition.Add("bx_langqiao", new Vector3(-35f, 30f, -59f));
|
||||
targetObjectAndPosition.Add("bx_qiaozha", new Vector3(-26f, 35f, -74f));
|
||||
targetObjectAndPosition.Add("bx_zhafang1", new Vector3(-64f, 21f, -102f));
|
||||
targetObjectAndPosition.Add("bx_zhafang2", new Vector3(-8f, 26f, -173f));
|
||||
targetObjectAndPosition.Add("bx_zhafang3", new Vector3(12f, 23f, -37f));
|
||||
targetObjectAndPosition.Add("bx_diaosu", new Vector3(-18f, 18f, 13f));
|
||||
targetObjectAndPosition.Add("sb_shujucaijiyi", new Vector3(-28f, 20.7f, 4.5f));
|
||||
targetObjectAndPosition.Add("sb_shujucaijiyi (1)", new Vector3(31.3f, 19.7f, -66.3f));
|
||||
targetObjectAndPosition.Add("bx_zhafang5", new Vector3(53f, 26f, -23f));
|
||||
targetObjectAndPosition.Add("pj_tingzi", new Vector3(67f, 20f, -97f));
|
||||
targetObjectAndPosition.Add("sb_qixiangzu001", new Vector3(14.2f, 24.8f, 11.5f));
|
||||
|
||||
|
||||
targetObjectAndPosition.Add("sb_wuxianqingjiaoji001", new Vector3(-35.69f, 62.82f, -12.18f));
|
||||
/* targetObjectAndPosition.Add("sb_wuxianqingjiaoji001", new Vector3(-35.69f, 62.82f, -12.18f));
|
||||
targetObjectAndPosition.Add("sb_wuxianqingjiaoji002", new Vector3(-39.52f, 62.94f, -14.66f));
|
||||
targetObjectAndPosition.Add("sb_wuxianqingjiaoji003", new Vector3(-35.82f, 63f, -16.84f));
|
||||
targetObjectAndPosition.Add("sb_wuxianqingjiaoji004", new Vector3(-121.8f, 18f, -74.3f));
|
||||
@@ -227,21 +220,23 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
targetObjectAndPosition.Add("sb_qixiangfengxiang001", new Vector3(-105.29f, 29.16f, 127.22f));
|
||||
targetObjectAndPosition.Add("sb_qixiangfengsu001", new Vector3(-104.87f, 29.06f, 123.55f));
|
||||
|
||||
targetObjectAndPosition.Add("全部ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("沉降监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("振动加速度ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("应变监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("裂缝监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("倾角监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("气象监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("流量监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("全部ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("沉降监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("振动加速度ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("应变监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("裂缝监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("倾角监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("气象监测ViewPort", new Vector3(16f, 113f, -167f));
|
||||
targetObjectAndPosition.Add("流量监测ViewPort", new Vector3(16f, 113f, -167f));*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (EventSystem.current != null && EventSystem.current.IsPointerOverGameObject())
|
||||
{
|
||||
return; // 直接 return,你下面所有相机逻辑都不执行
|
||||
return; // 直接 return,你下面所有相机逻辑都不执行
|
||||
}
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
@@ -262,10 +257,10 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
private void HandleClick()
|
||||
{
|
||||
Ray ray = mainCamera.ScreenPointToRay(Input.mousePosition);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity) && hit.collider.CompareTag("Target"))//这里有点小问题,应该给被打中的物体加一个标签,不然正常物体也会影响core
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, Mathf.Infinity) && hit.collider.CompareTag("Target"))//这里有点小问题,应该给被打中的物体加一个标签,不然正常物体也会影响core
|
||||
{
|
||||
Transform finalObject = hit.transform;//用浮标嫁祸给真实物体,浮标用ICON结尾,去除这个后缀就得到了真实物体的名字,
|
||||
//这些是之前图片直接在世界空间用spriteRender的,现在没用了,图片做成UI了,也没这个物理检测效果了。
|
||||
Transform finalObject = hit.transform;//用浮标嫁祸给真实物体,浮标用ICON结尾,去除这个后缀就得到了真实物体的名字,
|
||||
//这些是之前图片直接在世界空间用spriteRender的,现在没用了,图片做成UI了,也没这个物理检测效果了。
|
||||
if (finalObject.gameObject.name.EndsWith("ICON"))
|
||||
{
|
||||
string realObjName = hit.transform.gameObject.name.Substring(0, finalObject.gameObject.name.Length - 4);
|
||||
@@ -276,7 +271,7 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
if (finalObject.gameObject.name == pair.Key)
|
||||
{
|
||||
Vector3 targetPos = pair.Value;
|
||||
//float realTransitionDuration = Vector3.Distance(mainCamera.transform.position, targetPos) / 50f;50m每秒的飞行速度
|
||||
//float realTransitionDuration = Vector3.Distance(mainCamera.transform.position, targetPos) / 50f;50m每秒的飞行速度
|
||||
//realTransitionDuration = Mathf.Clamp(realTransitionDuration, 0.8f, 1.5f);
|
||||
transitionDuration= Mathf.Clamp(Vector3.Distance(mainCamera.transform.position, targetPos) / 50f, 0.5f, 1.5f);
|
||||
StartCoroutine(MoveCamera(mainCamera, targetPos, transitionDuration, finalObject));
|
||||
@@ -302,11 +297,11 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
if (focusTarget != null)
|
||||
cam.transform.LookAt(focusTarget);
|
||||
elapsed += Time.deltaTime;
|
||||
waitingSecondClick = false;//这一步是你在每一帧我都让你不等下一次点击,
|
||||
//防止你再飞的过程中手速快双击的话还能飞到其他地方,
|
||||
//这样我一直给你设成 false,你怎么样都不能再飞第二次
|
||||
//还有一个作用就是我单击跳转的时候也会持续触发,所以即使 UI 和实物重合,
|
||||
//我也是 UI 先出发,本身 UI 的优先级就比物理碰撞的优先级要高
|
||||
waitingSecondClick = false;//这一步是你在每一帧我都让你不等下一次点击,
|
||||
//防止你再飞的过程中手速快双击的话还能飞到其他地方,
|
||||
//这样我一直给你设成 false,你怎么样都不能再飞第二次
|
||||
//还有一个作用就是我单击跳转的时候也会持续触发,所以即使 UI 和实物重合,
|
||||
//我也是 UI 先出发,本身 UI 的优先级就比物理碰撞的优先级要高
|
||||
flying = true;
|
||||
yield return null;
|
||||
}
|
||||
@@ -316,24 +311,24 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
if (cam.transform.position.y < 0.01f)
|
||||
{
|
||||
Vector3 newPos = cam.transform.position;
|
||||
// 2. 修改y轴值(x、z保持不变)
|
||||
// 2. 修改y轴值(x、z保持不变)
|
||||
newPos.y = 0.1f;
|
||||
// 3. 重新赋值给position
|
||||
cam.transform.position = newPos;//这里埋坑了,如果以后设备真的在地下怎么办,
|
||||
//有经纬度的高程就是y,北溪没有地下的
|
||||
// 3. 重新赋值给position
|
||||
cam.transform.position = newPos;//这里埋坑了,如果以后设备真的在地下怎么办,
|
||||
//有经纬度的高程就是y,北溪没有地下的
|
||||
|
||||
}
|
||||
flying = false;
|
||||
|
||||
}
|
||||
|
||||
public void FlyToIconAndConvertCore(string IconName)//给点击图标使用
|
||||
public void FlyToIconAndConvertCore(string IconName)//给点击图标使用
|
||||
{
|
||||
if (flying)
|
||||
return;
|
||||
Transform finalObject = GameObject.Find(IconName.Substring(0, IconName.Length - 4)).transform;
|
||||
//Unity 的 button 按钮通过 Inspector 没有办法灵活指定参数,
|
||||
//我在里面把参数写死,然后来一一匹配,传的参数就是gameobject的名字
|
||||
//Unity 的 button 按钮通过 Inspector 没有办法灵活指定参数,
|
||||
//我在里面把参数写死,然后来一一匹配,传的参数就是gameobject的名字
|
||||
foreach (KeyValuePair<string, Vector3> pair in targetObjectAndPosition)
|
||||
{
|
||||
if (IconName.Substring(0, IconName.Length - 4) == pair.Key)
|
||||
@@ -347,12 +342,12 @@ public class DoubleClickToFocus : MonoBehaviour
|
||||
core = finalObject.position;
|
||||
}
|
||||
|
||||
//给仅显示部分图标使用,name是SortingIcons的名字,飞行的过程和上面差不多
|
||||
//给仅显示部分图标使用,name是SortingIcons的名字,飞行的过程和上面差不多
|
||||
public void FlyToOverlookAndConvertCore(string name)
|
||||
{
|
||||
if (flying)
|
||||
return;
|
||||
Transform finalObject = GameObject.Find(name + "ViewPort").transform; //在场景里加对应名的空物体作为伪终点。
|
||||
Transform finalObject = GameObject.Find(name + "ViewPort").transform; //在场景里加对应名的空物体作为伪终点。
|
||||
foreach (KeyValuePair<string, Vector3> pair in targetObjectAndPosition)
|
||||
{
|
||||
if (finalObject.gameObject.name == pair.Key)
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 928c1a340fd1ab846a4ce724e1dca34a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bf67224f56146549938b02b5083f217
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ecb74b5777741e41a17f224352daba9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ff3b04630a566da47910993dfba8e638
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f9f32f70dec08a488a75d5ad2d3601b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db8f02e226eb91748ac6a3469878a8a4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 410b270eca23bfe4aadcc4d64d3f0d1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ConnectToRealSluicesHeight : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public class SluicesSliderBinding
|
||||
{
|
||||
public GameObject sluice;
|
||||
public GameObject slider;
|
||||
}
|
||||
|
||||
public List<SluicesSliderBinding> bindings = new List<SluicesSliderBinding>();
|
||||
|
||||
private Dictionary<GameObject, Vector3> sluiceInitialLocalPosition = new Dictionary<GameObject, Vector3>();
|
||||
|
||||
void Start()
|
||||
{
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
sluiceInitialLocalPosition[binding.sluice] = binding.sluice.transform.localPosition;
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
foreach (var binding in bindings)
|
||||
{
|
||||
Slider sliderComp = binding.slider.GetComponent<Slider>();
|
||||
Vector3 initLocalPos = sluiceInitialLocalPosition[binding.sluice];
|
||||
|
||||
binding.sluice.transform.localPosition = new Vector3(
|
||||
initLocalPos.x,
|
||||
initLocalPos.y + sliderComp.value,
|
||||
initLocalPos.z
|
||||
);
|
||||
|
||||
binding.slider.transform.Find("Text (TMP)").GetComponent<TextMeshProUGUI>().text =
|
||||
binding.slider.name.Substring(6) + "#" + ": " + sliderComp.value.ToString("F1");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 435a1377c29de3e48a8aff544627f80f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,31 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ModifySluiceHeightManually : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//setHeight("sluice1", 1.5f);
|
||||
//setHeight("sluice2,1.5");
|
||||
//setHeight("sluice1,1.5");
|
||||
//Debug.Log("aaaa");
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
//public void setHeight(string sluiceName,float height)
|
||||
//{
|
||||
// transform.Find("Sliders/" + sluiceName).GetComponent<Slider>().value = height;
|
||||
//}
|
||||
public void setHeight(string sluiceNameAndHeight)
|
||||
{
|
||||
string[] parts = sluiceNameAndHeight.Split(',');
|
||||
transform.Find("Sliders/" + parts[0]).GetComponent<Slider>().value = float.Parse(parts[1]);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 82f187734168bad498845ae9a9967cc6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,63 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class OneKeyOperation : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
public void AllOpen()
|
||||
{
|
||||
foreach(Transform child in transform.Find("Sliders").transform)
|
||||
{
|
||||
StartCoroutine(SmoothIncreaseToTwo(0.3f, child));
|
||||
}
|
||||
|
||||
}
|
||||
public void AllClose()
|
||||
{
|
||||
foreach (Transform child in transform.Find("Sliders").transform)
|
||||
{
|
||||
StartCoroutine(SmoothDecreaseToZero(0.3f, child));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
IEnumerator SmoothDecreaseToZero(float duration,Transform child )
|
||||
{
|
||||
float startValue = child.GetComponent<Slider>().value;
|
||||
float time = 0f;
|
||||
while (time < duration)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
startValue = Mathf.Lerp(startValue, 0f, time / duration);
|
||||
child.GetComponent<Slider>().value = startValue;
|
||||
yield return null;
|
||||
}
|
||||
child.GetComponent<Slider>().value = 0f;
|
||||
}
|
||||
|
||||
IEnumerator SmoothIncreaseToTwo(float duration, Transform child)
|
||||
{
|
||||
float startValue = child.GetComponent<Slider>().value;
|
||||
float time = 0f;
|
||||
while (time < duration)
|
||||
{
|
||||
time += Time.deltaTime;
|
||||
startValue = Mathf.Lerp(startValue, 2f, time / duration);
|
||||
child.GetComponent<Slider>().value = startValue;
|
||||
yield return null;
|
||||
}
|
||||
child.GetComponent<Slider>().value = 2f;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ab7398f0cf55e44982d5db77cffb184
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c4e033165d6b0b438d356d601068c21
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 124100b5f0b252a419ba900d91ff1d3f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edf26518729fa024ca108689392dd1c3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64a10dae871f32c4e8d9a163a4b99dff
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user