FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UnLua/Content/Script/Tutorials/04_DynamicBinding.lua at master · Tencent/UnLua · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
Tencent
/
UnLua
Public
Notifications
You must be signed in to change notification settings
Fork
723
Star
2.8k
Code
Issues
164
Pull requests
23
Discussions
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
UnLua
/
Content
/
Script
/
Tutorials
/
04_DynamicBinding.lua
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (33 loc) · 1.44 KB
Breadcrumbs
UnLua
/
Content
/
Script
/
Tutorials
/
04_DynamicBinding.lua
Copy path
File metadata and controls
44 lines (33 loc) · 1.44 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
--[[
说明:除了实现 UnLuaInterface 的静态绑定方式外,还可以在运行时动态绑定对象到Lua
对于 Actor 类,可以使用 SpawnActor 接口,例如:
World:SpawnActor(SpawnClass, Transform, AlwaysSpawn, self, self, "Tutorials.GravitySphereActor")
对于非 Actor 类,可以使用 NewObject 接口,例如:
NewObject(WidgetClass, self, nil, "Tutorials.IconWidget")
注意:无论哪种绑定方式,都需要指定脚本文件路径。它是一个相对于 {工程目录}/Content/Script 下的相对路径。
]]
--
local
Screen
=
require
"
Tutorials.Screen
"
local
M
=
UnLua
.
Class
()
function
M
:
ReceiveBeginPlay
()
local
msg
=
[[
鼠标左键:创建动态绑定的 Actor
鼠标右键:创建动态绑定的 Object
—— 本示例来自 "Content/Script/Tutorials.04_DynamicBinding.lua"
]]
Screen
.
Print
(
msg
)
end
function
M
:
LeftMouseButton_Pressed
()
local
World
=
self
:
GetWorld
()
local
SpawnClass
=
self
.
SpawnClass
local
Transform
=
self
.
SpawnPointActor
:
GetTransform
()
local
AlwaysSpawn
=
UE
.
ESpawnActorCollisionHandlingMethod
.
AlwaysSpawn
World
:
SpawnActor
(
SpawnClass
,
Transform
,
AlwaysSpawn
,
self
,
self
,
"
Tutorials.GravitySphereActor
"
)
end
function
M
:
RightMouseButton_Pressed
()
local
WidgetClass
=
self
.
WidgetClass
local
img
=
NewObject
(
WidgetClass
,
self
,
nil
,
"
Tutorials.IconWidget
"
)
img
:
AddToViewport
()
img
:
RandomPosition
()
end
return
M
Back
|
FazBrowse Home
|
New Git URL