Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
山
山西检定流水线数字孪生项目
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨泽宇
山西检定流水线数字孪生项目
Commits
c123ec5a
Commit
c123ec5a
authored
May 18, 2024
by
杨泽宇
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
c1c32f74
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
119 additions
and
0 deletions
+119
-0
LoginManager.cs
Assets/Scripts/Components/AGV/LoginManager.cs
+86
-0
LoginManager.cs.meta
Assets/Scripts/Components/AGV/LoginManager.cs.meta
+11
-0
ReceiveMsgEvent.cs
Assets/Scripts/Components/AGV/ReceiveMsgEvent.cs
+6
-0
ReceiveMsgEvent.cs.meta
Assets/Scripts/Components/AGV/ReceiveMsgEvent.cs.meta
+11
-0
1_Main.unity
Assets/_Scenes/1_Main.unity
+5
-0
No files found.
Assets/Scripts/Components/AGV/LoginManager.cs
0 → 100644
View file @
c123ec5a
using
System.Collections
;
using
UnityEngine.Networking
;
using
UnityEngine
;
public
class
LoginManager
:
MonoBehaviour
{
public
string
ProductionlineID
;
private
RobotPositionData
positionData
;
[
Header
(
"收到服务器信息事件"
)]
public
ReceiveMsgEvent
<
object
,
string
>
OnReceiveMsg
=
new
ReceiveMsgEvent
<
object
,
string
>();
[
Space
]
[
Header
(
"获取的信息"
)]
public
Vector3
position
;
private
void
Awake
()
{
OnReceiveMsg
.
AddListener
(
_getData
);
}
private
void
Start
()
{
StartCoroutine
(
GetPositionData
());
}
protected
void
_getData
(
object
data
,
string
parameter
)
{
if
(
data
.
GetType
().
Equals
(
typeof
(
RobotPositionData
)))
{
RobotPositionData
robotPositionData
=
(
RobotPositionData
)
data
;
position
=
new
Vector3
(
robotPositionData
.
data
.
x
,
robotPositionData
.
data
.
y
,
robotPositionData
.
data
.
h
);
Debug
.
Log
(
position
);
}
}
private
IEnumerator
GetPositionData
()
{
while
(
true
)
{
using
(
UnityWebRequest
request
=
UnityWebRequest
.
Get
(
ProductionlineID
))
{
// 设置请求头
request
.
SetRequestHeader
(
"Content-Type"
,
"application/json"
);
// 发送请求并等待响应
yield
return
request
.
SendWebRequest
();
if
(!
string
.
IsNullOrEmpty
(
request
.
error
))
{
Debug
.
LogError
(
request
.
error
);
}
else
{
// 解析响应数据
string
responseJson
=
request
.
downloadHandler
.
text
;
Debug
.
Log
(
"Response: "
+
responseJson
);
// 使用 JsonUtility 解析 JSON 数据
positionData
=
JsonUtility
.
FromJson
<
RobotPositionData
>(
responseJson
);
OnReceiveMsg
.
Invoke
(
positionData
,
"RobotPositionData"
);
}
}
yield
return
new
WaitForSeconds
(
1
);
}
}
}
// 定义机器人位置数据结构
[System.Serializable]
public
class
RobotPositionData
{
public
int
code
;
public
string
message
;
public
RobotPositionDataDetails
data
;
}
[System.Serializable]
public
class
RobotPositionDataDetails
{
public
float
x
;
public
float
y
;
public
float
h
;
}
\ No newline at end of file
Assets/Scripts/Components/AGV/LoginManager.cs.meta
0 → 100644
View file @
c123ec5a
fileFormatVersion: 2
guid: 61673f6590d0ff745805f9319090354c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/Scripts/Components/AGV/ReceiveMsgEvent.cs
0 → 100644
View file @
c123ec5a
using
UnityEngine.Events
;
public
class
ReceiveMsgEvent
<
T
>
:
UnityEvent
<
T
>
{
}
public
class
ReceiveMsgEvent
<
T
,
K
>
:
UnityEvent
<
T
,
K
>
{
}
public
class
ReceiveMsgEvent
:
UnityEvent
{
}
\ No newline at end of file
Assets/Scripts/Components/AGV/ReceiveMsgEvent.cs.meta
0 → 100644
View file @
c123ec5a
fileFormatVersion: 2
guid: 99540299064230543b55b3ba77c168c5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Assets/_Scenes/1_Main.unity
View file @
c123ec5a
...
...
@@ -5640,6 +5640,11 @@ PrefabInstance:
propertyPath
:
UID
value
:
1158373593
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
6601457687186396561
,
guid
:
1728ef96ff7b1b44f943e3c988d53d15
,
type
:
3
}
propertyPath
:
m_IsActive
value
:
1
objectReference
:
{
fileID
:
0
}
-
target
:
{
fileID
:
6954307607829673240
,
guid
:
1728ef96ff7b1b44f943e3c988d53d15
,
type
:
3
}
propertyPath
:
UID
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment