This commit is contained in:
XgC2961 2025-08-29 09:23:02 +08:00
parent 106bbbabbb
commit 1ad0305773
2 changed files with 49 additions and 29 deletions

View File

@ -12,8 +12,9 @@ public class DisplayServer : MonoBehaviour
private bool isRunning = true; private bool isRunning = true;
public Transform background; public Transform background;
private string latestMsg = ""; private string latestMsg = "";//最新信息
public Animator modelAnimator;//模型动画
void Start() void Start()
{ {
@ -30,7 +31,7 @@ public class DisplayServer : MonoBehaviour
ShowPage("Ê×Ò³"); ShowPage("Ê×Ò³");
} }
private void ListenForClients() private void ListenForClients()//连接触摸控制端
{ {
while (isRunning) while (isRunning)
{ {
@ -42,7 +43,7 @@ public class DisplayServer : MonoBehaviour
} }
} }
private void HandleClientComm(object clientObj) private void HandleClientComm(object clientObj)//处理触摸端发送的信息
{ {
TcpClient tcpClient = (TcpClient)clientObj; TcpClient tcpClient = (TcpClient)clientObj;
NetworkStream clientStream = tcpClient.GetStream(); NetworkStream clientStream = tcpClient.GetStream();
@ -74,15 +75,22 @@ public class DisplayServer : MonoBehaviour
{ {
if (!string.IsNullOrEmpty(latestMsg)) if (!string.IsNullOrEmpty(latestMsg))
{ {
if (!string.IsNullOrEmpty(latestMsg)) if (latestMsg.StartsWith("Page:"))
{ {
ShowPage(latestMsg); string pageName = latestMsg.Replace("Page:", "");
latestMsg = ""; ShowPage(pageName);
} }
else if (latestMsg.StartsWith("Anim:"))
{
string animName = latestMsg.Replace("Anim:", "");
PlayAnimation(animName);
}
latestMsg = "";
} }
} }
private void ShowPage(string pageName) private void ShowPage(string pageName)//
{ {
if (background == null) if (background == null)
{ {
@ -97,6 +105,18 @@ public class DisplayServer : MonoBehaviour
Debug.Log($"ÏÔʾ¶ËÇл»Ò³Ã棺{pageName}"); Debug.Log($"ÏÔʾ¶ËÇл»Ò³Ã棺{pageName}");
} }
private void PlayAnimation(string animName)
{
if (modelAnimator == null)
{
Debug.LogError("未绑定 Animator");
return;
}
modelAnimator.Play(animName); // 播放指定动画
Debug.Log($"显示端播放动画:{animName}");
}
private void OnApplicationQuit() private void OnApplicationQuit()
{ {
isRunning = false; isRunning = false;

View File

@ -19,7 +19,7 @@ MonoBehaviour:
width: 1536 width: 1536
height: 772.8 height: 772.8
m_ShowMode: 4 m_ShowMode: 4
m_Title: Hierarchy m_Title: Project
m_RootView: {fileID: 2} m_RootView: {fileID: 2}
m_MinSize: {x: 875, y: 300} m_MinSize: {x: 875, y: 300}
m_MaxSize: {x: 10000, y: 10000} m_MaxSize: {x: 10000, y: 10000}
@ -99,7 +99,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 200} m_MinSize: {x: 300, y: 200}
m_MaxSize: {x: 24288, y: 16192} m_MaxSize: {x: 24288, y: 16192}
vertical: 0 vertical: 0
controlID: 80 controlID: 52
--- !u!114 &5 --- !u!114 &5
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -140,8 +140,8 @@ MonoBehaviour:
y: 0 y: 0
width: 854.4 width: 854.4
height: 722.8 height: 722.8
m_MinSize: {x: 201, y: 221} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 15} m_ActualView: {fileID: 15}
m_Panes: m_Panes:
- {fileID: 13} - {fileID: 13}
@ -172,7 +172,7 @@ MonoBehaviour:
m_MinSize: {x: 100, y: 200} m_MinSize: {x: 100, y: 200}
m_MaxSize: {x: 8096, y: 16192} m_MaxSize: {x: 8096, y: 16192}
vertical: 1 vertical: 1
controlID: 16 controlID: 58
--- !u!114 &8 --- !u!114 &8
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 52 m_ObjectHideFlags: 52
@ -192,8 +192,8 @@ MonoBehaviour:
y: 0 y: 0
width: 354.40002 width: 354.40002
height: 722.8 height: 722.8
m_MinSize: {x: 276, y: 71} m_MinSize: {x: 275, y: 50}
m_MaxSize: {x: 4001, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 11} m_ActualView: {fileID: 11}
m_Panes: m_Panes:
- {fileID: 11} - {fileID: 11}
@ -218,8 +218,8 @@ MonoBehaviour:
y: 0 y: 0
width: 327.19995 width: 327.19995
height: 318.4 height: 318.4
m_MinSize: {x: 202, y: 221} m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4002, y: 4021} m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 14} m_ActualView: {fileID: 14}
m_Panes: m_Panes:
- {fileID: 14} - {fileID: 14}
@ -333,7 +333,7 @@ MonoBehaviour:
m_SkipHidden: 0 m_SkipHidden: 0
m_SearchArea: 1 m_SearchArea: 1
m_Folders: m_Folders:
- Assets/Prefab - Assets/Scripts
m_Globs: [] m_Globs: []
m_OriginalText: m_OriginalText:
m_FilterByTypeIntersection: 0 m_FilterByTypeIntersection: 0
@ -348,7 +348,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: 7c780000 m_SelectedIDs: 7c780000
m_LastClickedID: 30844 m_LastClickedID: 30844
m_ExpandedIDs: 0000000030d5000032d5000034d5000036d5000038d500003ad50000 m_ExpandedIDs: 00000000da460100dc460100de460100e0460100e2460100e4460100
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name:
@ -373,24 +373,24 @@ MonoBehaviour:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_ResourceFile: m_ResourceFile:
m_AssetTreeState: m_AssetTreeState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 58.600006}
m_SelectedIDs: m_SelectedIDs:
m_LastClickedID: 0 m_LastClickedID: 0
m_ExpandedIDs: ffffffff0000000030d5000032d5000034d5000036d5000038d500003ad50000 m_ExpandedIDs: ffffffff00000000da460100dc460100de460100e0460100e2460100e4460100
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: "\u6574\u4F53\u7ED3\u6784\u5C55\u793A" m_Name:
m_OriginalName: "\u6574\u4F53\u7ED3\u6784\u5C55\u793A" m_OriginalName:
m_EditFieldRect: m_EditFieldRect:
serializedVersion: 2 serializedVersion: 2
x: 0 x: 0
y: 0 y: 0
width: 0 width: 0
height: 0 height: 0
m_UserData: 22588 m_UserData: 0
m_IsWaitingForDelay: 0 m_IsWaitingForDelay: 0
m_IsRenaming: 0 m_IsRenaming: 0
m_OriginalEventType: 0 m_OriginalEventType: 11
m_IsRenamingFilename: 1 m_IsRenamingFilename: 1
m_ClientGUIView: {fileID: 10} m_ClientGUIView: {fileID: 10}
m_SearchString: m_SearchString:
@ -753,11 +753,11 @@ MonoBehaviour:
m_Rotation: m_Rotation:
m_Target: {x: 0.33473206, y: 0.41149613, z: -0.16586047, w: 0.8314923} m_Target: {x: 0.33473206, y: 0.41149613, z: -0.16586047, w: 0.8314923}
speed: 2 speed: 2
m_Value: {x: 0.33766133, y: 0.41561192, z: -0.16984147, w: 0.82728803} m_Value: {x: 0.33468792, y: 0.4114419, z: -0.16583861, w: 0.8313827}
m_Size: m_Size:
m_Target: 65.2069 m_Target: 65.2069
speed: 2 speed: 2
m_Value: 62.398952 m_Value: 65.2069
m_Ortho: m_Ortho:
m_Target: 1 m_Target: 1
speed: 2 speed: 2
@ -814,9 +814,9 @@ MonoBehaviour:
m_SceneHierarchy: m_SceneHierarchy:
m_TreeViewState: m_TreeViewState:
scrollPos: {x: 0, y: 0} scrollPos: {x: 0, y: 0}
m_SelectedIDs: e8570000 m_SelectedIDs: ae490000
m_LastClickedID: 22504 m_LastClickedID: 0
m_ExpandedIDs: a2b8f8ffa21cf9ffa280f9ffa2e4f9ffa248faff34fbfffff05700001a58000032580000 m_ExpandedIDs: 34fbfffff257000024580000
m_RenameOverlay: m_RenameOverlay:
m_UserAcceptedRename: 0 m_UserAcceptedRename: 0
m_Name: m_Name: