load deviceANDIcon by codes automatically

This commit is contained in:
XuGaoFeng
2026-07-10 15:01:12 +08:00
parent 9579356ed1
commit d5aeb63276
17 changed files with 4670 additions and 4172 deletions

BIN
.vs/3d-fengji/v17/.suo Normal file

Binary file not shown.

View File

@@ -0,0 +1,58 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\unityData\\Git\u7248\u672C\\3d-fengji\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}|Assembly-CSharp.csproj|d:\\unitydata\\git\u7248\u672C\\3d-fengji\\assets\\scripts\\icons\\askforwebinfomation.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}|Assembly-CSharp.csproj|solutionrelative:assets\\scripts\\icons\\askforwebinfomation.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}|Assembly-CSharp.csproj|d:\\unitydata\\git\u7248\u672C\\3d-fengji\\assets\\scripts\\icons\\fastslowanimationandzoomin.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}|Assembly-CSharp.csproj|solutionrelative:assets\\scripts\\icons\\fastslowanimationandzoomin.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:0:0:{aa2115a1-9712-457b-9047-dbb71ca2cdd2}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "AskForWEBInfomation.cs",
"DocumentMoniker": "D:\\unityData\\Git\u7248\u672C\\3d-fengji\\Assets\\Scripts\\ICONS\\AskForWEBInfomation.cs",
"RelativeDocumentMoniker": "Assets\\Scripts\\ICONS\\AskForWEBInfomation.cs",
"ToolTip": "D:\\unityData\\Git\u7248\u672C\\3d-fengji\\Assets\\Scripts\\ICONS\\AskForWEBInfomation.cs",
"RelativeToolTip": "Assets\\Scripts\\ICONS\\AskForWEBInfomation.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAANgBAAABAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-07-10T06:56:30.878Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "FastSlowAnimationANDZoomIN.cs",
"DocumentMoniker": "D:\\unityData\\Git\u7248\u672C\\3d-fengji\\Assets\\Scripts\\ICONS\\FastSlowAnimationANDZoomIN.cs",
"RelativeDocumentMoniker": "Assets\\Scripts\\ICONS\\FastSlowAnimationANDZoomIN.cs",
"ToolTip": "D:\\unityData\\Git\u7248\u672C\\3d-fengji\\Assets\\Scripts\\ICONS\\FastSlowAnimationANDZoomIN.cs",
"RelativeToolTip": "Assets\\Scripts\\ICONS\\FastSlowAnimationANDZoomIN.cs",
"ViewState": "AgIAABEAAAAAAAAAAADwvx4AAAAVAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2026-07-10T06:54:03.181Z",
"EditorCaption": ""
}
]
}
]
}
]
}

6
.vsconfig Normal file
View File

@@ -0,0 +1,6 @@
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedGame"
]
}

38
3d-fengji.sln Normal file
View File

@@ -0,0 +1,38 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enviro3.Editor", "Enviro3.Editor.csproj", "{73D96162-AA87-E3EB-67D0-CFA8AA2A2806}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp", "Assembly-CSharp.csproj", "{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Enviro3.Runtime", "Enviro3.Runtime.csproj", "{7C998988-61F2-7AF1-0A5D-CFA20D6661AE}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{F9B788D1-9D9E-3556-0807-B70711B56A75}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73D96162-AA87-E3EB-67D0-CFA8AA2A2806}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73D96162-AA87-E3EB-67D0-CFA8AA2A2806}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73D96162-AA87-E3EB-67D0-CFA8AA2A2806}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73D96162-AA87-E3EB-67D0-CFA8AA2A2806}.Release|Any CPU.Build.0 = Release|Any CPU
{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E01BD8B3-55E8-74DB-B103-CC292D26A5E4}.Release|Any CPU.Build.0 = Release|Any CPU
{7C998988-61F2-7AF1-0A5D-CFA20D6661AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C998988-61F2-7AF1-0A5D-CFA20D6661AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C998988-61F2-7AF1-0A5D-CFA20D6661AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C998988-61F2-7AF1-0A5D-CFA20D6661AE}.Release|Any CPU.Build.0 = Release|Any CPU
{F9B788D1-9D9E-3556-0807-B70711B56A75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9B788D1-9D9E-3556-0807-B70711B56A75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9B788D1-9D9E-3556-0807-B70711B56A75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9B788D1-9D9E-3556-0807-B70711B56A75}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load Diff

1166
Assembly-CSharp.csproj Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,33 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking; using UnityEngine.Networking;
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)
{
SNWithdeviceName = sn;
localPosition = pos;
customName = name;
pictureSerialNumber = picSn;
}
}
public class AskForWEBInfomation : MonoBehaviour public class AskForWEBInfomation : MonoBehaviour
{ {
public Camera cam;
public GameObject buoy;//把BUoy预制体拖进来使用代码自动生成ICON的子物体
public List<Sprite> pictures = new List<Sprite>();//把图片预制体都拖过来
[Serializable] [Serializable]
public class IdentifierTextBinding public class IdentifierTextBinding
{ {
@@ -28,6 +48,67 @@ public class AskForWEBInfomation : MonoBehaviour
"ys_2026020420","ys_2026020419","ys_2026020418","ys_2026020417","ys_2026020416","ys_2026020415" "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") ,
};
/* Dictionary<string, Vector3> deviceName = new Dictionary<string, Vector3>//这个是ICONS下面所有的设备用系统自动实例化
{
{ "ys_2026020415_sb_gnss001",new Vector3(10.9530001f,-10.7779989f,-1.75300026f)} ,
{"ys_2026020416_sb_wuxianqingjiaoji001", new Vector3(-0.25177002f,-0.00340000005f,3.51672745f)},
{"ys_2026020416_sb_wuxianqingjiaoji002",new Vector3(-3.22239995f,-0.0055999998f,1.67970002f)},
{"ys_2026020416_sb_wuxianqingjiaoji003",new Vector3(-0.254400015f,-0.00449999981f,-0.108400002f) },
{"ys_2026020417_sb_fengjizhendong001",new Vector3(1.14961243f,55.1254196f,2.07600784f)},
{"ys_2026020417_sb_fengjizhendong002",new Vector3(1.14961243f,55.1785011f,1.38459396f) },
{"ys_2026020418_sb_yingbianji001" ,new Vector3(-1.90900004f,10.3079996f,3.55800009f)},
{"ys_2026020418_sb_yingbianji002" ,new Vector3(-3.17600012f,10.2980003f,1.66199994f)},
{"ys_2026020418_sb_yingbianji003" ,new Vector3(-1.87399995f,10.2880001f,-0.150199994f)},
{"ys_2026020418_sb_yingbianji004" ,new Vector3(0.349900007f,10.2938004f,0.450199991f)},
{"ys_2026020418_sb_yingbianji005" ,new Vector3(0.400999993f,10.2967997f,2.88899994f)},
{"ys_2026020419_sb_wenshiya001",new Vector3(-69.6037674f,-33.9762917f,141.763977f)},
{"ys_2026020420_sb_yachashi002",new Vector3(-1.17034912f,-12.5128984f,4.73325729f)},
{"ys_2026020420_sb_yachashi003",new Vector3(-1.17050004f,-12.5162926f,-1.3204f)},
{"ys_2026020420_sb_yachashi004",new Vector3(1.83947754f,-12.5169001f,1.70901871f)},
{"ys_2026020420_sb_yachashi005",new Vector3(-4.20899963f,-12.5176001f,1.70901871f)},
};
Dictionary<string, string> customName = new Dictionary<string, string>//这个是浮标上面的文本,自己命的名
{
{ "ys_2026020415_sb_gnss001","GNSS"} ,
{"ys_2026020416_sb_wuxianqingjiaoji001", "无线倾角计1"},
{"ys_2026020416_sb_wuxianqingjiaoji002","无线倾角计2"},
{"ys_2026020416_sb_wuxianqingjiaoji003","无线倾角计3" },
{"ys_2026020417_sb_fengjizhendong001","振动加速度1"},
{"ys_2026020417_sb_fengjizhendong002","振动加速度2" },
{"ys_2026020418_sb_yingbianji001" ,"应变计1"},
{"ys_2026020418_sb_yingbianji002" ,"应变计2"},
{"ys_2026020418_sb_yingbianji003" ,"应变计3"},
{"ys_2026020418_sb_yingbianji004" ,"应变计4"},
{"ys_2026020418_sb_yingbianji005" ,"应变计5"},
{"ys_2026020419_sb_wenshiya001","温湿压1"},
{"ys_2026020420_sb_yachashi002","温湿压2"},
{"ys_2026020420_sb_yachashi003","温湿压3"},
{"ys_2026020420_sb_yachashi004","温湿压4"},
{"ys_2026020420_sb_yachashi005","温湿压5"},
};*/
[Header("手动拖拽绑定identifier -> TMP_Text")] [Header("手动拖拽绑定identifier -> TMP_Text")]
public List<IdentifierTextBinding> bindings = new List<IdentifierTextBinding>(); public List<IdentifierTextBinding> bindings = new List<IdentifierTextBinding>();
@@ -42,8 +123,53 @@ public class AskForWEBInfomation : MonoBehaviour
public bool _isRunning = false;//这个东西只是用来防止手动连点 public bool _isRunning = false;//这个东西只是用来防止手动连点
private void Awake() private void Awake()
{ {
cam = Camera.main;
InitiateICONS();
BuildBindingMap(); BuildBindingMap();
} }
private void InitiateICONS()
{
foreach (RequiredInformation info in info)
{
//生成一个预制体
GameObject obj = Instantiate(buoy);
obj.name = info.SNWithdeviceName;
obj.transform.SetParent(transform);
obj.transform.localPosition = info.localPosition;
//开始修理预制体下面的响应函数和text
int first = obj.name.IndexOf("_");
int second = obj.name.IndexOf('_', first + 1);//second 是第二个下划线的索引索引是从0开始的
string deviceSn = obj.name.Substring(0, second);//前半部分比如ys_2026030415,末尾没有下划线,但是这部分不重要,重要的是后半部分。
//这里second表示长度第二个下划线索引是9也就是第10位但是索引做长度正好把第十位丢掉了
string deviceName = obj.name.Substring(second + 1); //设备名,也就是后半部分,从指定索引开始到结尾
//第一个子物体主要负责浮标的响应函数
obj.transform.GetChild(0).name = deviceName + "ICON";
obj.transform.GetChild(0).GetComponent<Button>().onClick.RemoveAllListeners();
obj.transform.GetChild(0).GetComponent<Button>().onClick.AddListener(
() => {
cam.GetComponent<DoubleClickToFocus>().FlyToIconAndConvertCore(obj.transform.GetChild(0).name);
}
);
obj.transform.GetChild(0).GetComponent<Button>().onClick.AddListener(
() => {
ManuallyLoadOneDevice(obj.name);
}
);
foreach (Sprite img in pictures)//遍历图片数组,如果找到就结束
{
if (img.name == info.pictureSerialNumber)
{
obj.transform.GetChild(0).GetComponent<Image>().sprite = img;
break;
}
}
//第二个子物体负责浮标上面的文字描述
obj.transform.GetChild(1).name = deviceName + "Text";
obj.transform.GetChild(1).GetComponent<TextMeshProUGUI>().text = info.customName;
}
}
private void BuildBindingMap() private void BuildBindingMap()
{ {
textMap.Clear(); textMap.Clear();
@@ -165,7 +291,7 @@ public class AskForWEBInfomation : MonoBehaviour
_isRunning = true; _isRunning = true;
yield return null; yield return null;
float transitionDuration = Camera.main.transform.GetComponent<DoubleClickToFocus>().transitionDuration; float transitionDuration = Camera.main.transform.GetComponent<DoubleClickToFocus>().transitionDuration;
yield return new WaitForSeconds(transitionDuration+0.01f); // 等待2秒 yield return new WaitForSeconds(transitionDuration + 0.01f); // 等待2秒
// 这里写延迟执行的代码 // 这里写延迟执行的代码
Debug.Log("2秒后执行"); Debug.Log("2秒后执行");
@@ -219,7 +345,7 @@ public class AskForWEBInfomation : MonoBehaviour
SendData sendData = new SendData(); SendData sendData = new SendData();
sendData.result = resp.result; sendData.result = resp.result;
sendData.iconName = iconName; sendData.iconName = iconName;
string CoutJsonData = JsonUtility.ToJson(sendData,true); string CoutJsonData = JsonUtility.ToJson(sendData, true);
Application.ExternalCall("sendDataToVue", CoutJsonData); Application.ExternalCall("sendDataToVue", CoutJsonData);
//Debug.Log(CoutJsonData); //Debug.Log(CoutJsonData);
@@ -270,7 +396,7 @@ public class AskForWEBInfomation : MonoBehaviour
finalText = itemName + ": " + finalText; finalText = itemName + ": " + finalText;
} }
target.text = finalText; target.text = finalText;
} }
private string GetRequestUrl() private string GetRequestUrl()

View File

@@ -9,16 +9,16 @@ public class FastSlowAnimationANDZoomIN : MonoBehaviour
public Camera workerCamera; public Camera workerCamera;
//Animator anim; //Animator anim;
public float maxHeight = 2f; // 最大上升高度(米) public float maxHeight = 2f; // 最大上升高度(米)
float scaleRation = 0.5f;//默认缩放系数 float scaleRation = 0.5f;//默认缩放系数
public float upTime = 1.5f;// 上升到最高点所需时间(秒) public float upTime = 1.5f;// 上升到最高点所需时间(秒)
private Dictionary<Transform, Vector3> childrenStartPos = new Dictionary<Transform, Vector3>(); private Dictionary<Transform, Vector3> childrenStartPos = new Dictionary<Transform, Vector3>();
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
cam = Camera.main; cam = Camera.main;
// workerCamera = GameObject.Find("WorkerCamera").GetComponent<Camera>();zhe行代码为什么会引起 bug目前还不清楚 // workerCamera = GameObject.Find("WorkerCamera").GetComponent<Camera>();zhe行代码为什么会引起 bug目前还不清楚
foreach (Transform child in transform) foreach (Transform child in transform)
{ {
@@ -28,14 +28,14 @@ public class FastSlowAnimationANDZoomIN : MonoBehaviour
} }
// Update is called once per frame // Update is called once per frame
void Update() void LateUpdate()
{ {
if (cam.gameObject.activeInHierarchy == true) if (cam.gameObject.activeInHierarchy == true)
{ {
//自由视角下的动画逻辑 //自由视角下的动画逻辑
foreach (Transform child in transform)//每个孩子就是一个世界空间的大画布 foreach (Transform child in transform)//每个孩子就是一个世界空间的大画布
{ {
//通过遍历每个子物体,每个物体的大小是独立计算的,不能取最小值 //通过遍历每个子物体,每个物体的大小是独立计算的,不能取最小值
float dist = Vector3.Distance(child.position, cam.transform.position); float dist = Vector3.Distance(child.position, cam.transform.position);
float scale = scaleRation * dist / 30f; float scale = scaleRation * dist / 30f;
scale = Mathf.Clamp(scale, 0.0333f, 10f); scale = Mathf.Clamp(scale, 0.0333f, 10f);
@@ -47,14 +47,14 @@ public class FastSlowAnimationANDZoomIN : MonoBehaviour
child.position = childrenStartPos[child] + new Vector3(0, yOffset, 0); child.position = childrenStartPos[child] + new Vector3(0, yOffset, 0);
child.localScale = Vector3.one * scale; child.localScale = Vector3.one * scale;
child.LookAt(child.position + cam.transform.forward);//看相机 child.LookAt(child.position + cam.transform.forward);//看相机
//transform.LookAt(transform.position + target.forward); //transform.LookAt(transform.position + target.forward);
} }
} }
else else
{ {
//切换到工人视角下所放和浮动在这里 //切换到工人视角下所放和浮动在这里
foreach (Transform child in transform)//每个孩子就是一个世界空间的大画布 foreach (Transform child in transform)//每个孩子就是一个世界空间的大画布
{ {
@@ -62,7 +62,7 @@ public class FastSlowAnimationANDZoomIN : MonoBehaviour
child.position = childrenStartPos[child] + new Vector3(0, yOffset, 0); child.position = childrenStartPos[child] + new Vector3(0, yOffset, 0);
child.localScale = Vector3.one * 0.3f; child.localScale = Vector3.one * 0.3f;
child.LookAt(child.position + workerCamera.transform.forward);//看相机 child.LookAt(child.position + workerCamera.transform.forward);//看相机
//transform.LookAt(transform.position + target.forward); //transform.LookAt(transform.position + target.forward);
} }
} }

1027
Enviro3.Editor.csproj Normal file

File diff suppressed because it is too large Load Diff

1008
Enviro3.Runtime.csproj Normal file

File diff suppressed because it is too large Load Diff