Playmaker Load Scenes Async Additive
Summary
TLDRDG Dino 从 Jinx Games 带来了一个关于如何在 Unity 中使用 Playmaker 插件进行异步场景加载的教程。他首先感谢了购买他资产商店 Playmaker 样本的用户,并请求评价。接着,他展示了下一个教程的预览,并解释了在制作过程中遇到的一些问题,包括 Unity 的一些加载和激活场景的顺序问题。教程详细解释了如何设置断点进行调试,并通过实际操作演示了场景加载和激活的正确顺序,以及如何避免常见错误。最后,他提供了关于如何使用全局事件和监听器来改善游戏性能和用户体验的技巧。
Takeaways
- 😀 DG Dino 是来自 Jinx Games 的开发者,本教程是关于如何使用 Playmaker 插件中的加载场景(Load Scene)功能。
- 🙏 DG Dino 感谢所有在 Asset Store 上购买他 Playmaker 示例的用户,并请求用户对资产进行评分和评论。
- 🔍 DG Dino 展示了他下一个教程的预览,这将是一个完整的游戏,并且会添加到他的 Playmaker 示例资产中。
- 🛠️ 教程中提到,在制作教程时遇到了一些问题,最初以为是 Playmaker 动作的问题,但后来发现即使在 C# 脚本中也遇到了同样的问题。
- 🔄 DG Dino 演示了如何使用 Playmaker 设置断点来调试游戏,当游戏运行到断点状态时会暂停,允许开发者检查当前状态。
- 🎮 教程中展示了如何加载和激活不同的游戏级别,以及如何使用 Playmaker 来控制游戏级别的加载和激活顺序。
- ⚠️ DG Dino 强调了在加载多个场景时,必须按照正确的顺序激活它们,否则可能会导致游戏卡住。
- 🔄 教程中提到了卸载场景时需要注意的问题,如果场景未激活就尝试卸载,可能会导致游戏卡住。
- 📝 DG Dino 演示了如何使用 Playmaker 的“Load Scene Async”动作来异步加载场景,并解释了如何使用变量来控制加载过程。
- 🔧 教程中还介绍了如何使用“Activate GameObject”动作来激活或停用游戏对象,以及如何使用“Set String Value”动作来设置场景名称。
- 🔄 DG Dino 通过比较当前级别和要加载的级别,演示了如何实现游戏级别的前进和后退功能。
- 🎨 教程最后介绍了如何使用 Playmaker 来设置 UI 元素,例如更改背景颜色和更新文本显示。
Q & A
DG Dino 是哪个游戏公司的代表?
-DG Dino 是 Jinx Games 的代表。
在 Unity 中,如果加载多个场景对象,应该按照什么顺序激活它们?
-在 Unity 中,如果加载多个场景对象,应该先加载所有对象,然后再按照加载的相同顺序激活它们。
在 Unity 的 Playmaker 中设置断点有什么作用?
-在 Unity 的 Playmaker 中设置断点可以在游戏运行到特定状态时暂停游戏,用于调试和检查游戏状态。
在 DG Dino 的教程中,他提到了哪些可能导致游戏加载时出现问题的错误操作?
-DG Dino 提到的错误操作包括先加载玩家对象再加载场景,然后尝试激活场景,这会导致游戏加载时出现问题。
在 Playmaker 中,'Load Scene Async' 动作的 'Allow Scene Activation' 选项设置为 false 有什么作用?
-在 Playmaker 中,'Load Scene Async' 动作的 'Allow Scene Activation' 选项设置为 false 可以防止场景在加载后立即激活,允许开发者在激活前进行其他操作。
DG Dino 在教程中提到了哪些调试技巧?
-DG Dino 在教程中提到的调试技巧包括使用断点、触发事件以及检查游戏状态等。
在 Unity 的场景加载中,为什么 DG Dino 推荐使用场景名称而不是场景索引?
-DG Dino 推荐使用场景名称而不是场景索引,因为场景索引可能会因为构建设置中的不同位置而导致问题,而场景名称是唯一的,可以避免这种混淆。
在 DG Dino 的教程中,他是如何实现场景之间的转换的?
-在 DG Dino 的教程中,他通过 'Load Scene Async' 动作加载新场景,并在加载完成后激活新场景,同时设置 'Allow Scene Activation' 为 false 以控制激活时机。
DG Dino 在教程中提到了哪些关于场景激活和卸载的注意事项?
-DG Dino 提到,在激活和卸载场景时,需要先激活所有加载的场景,然后再进行卸载,否则可能会导致游戏卡住。
在 DG Dino 的教程中,他是如何使用全局事件来控制场景加载的?
-DG Dino 在教程中使用了全局事件来控制场景加载,他通过设置全局事件监听器,使得在游戏的任何位置都可以触发场景加载。
DG Dino 在教程中提到了哪些关于 Playmaker 动作的优化技巧?
-DG Dino 提到了使用名称而非索引来加载场景,以及使用全局事件和事件监听器来优化 Playmaker 动作的流程。
在 DG Dino 的教程中,他是如何展示如何通过按钮来触发不同场景的加载的?
-DG Dino 在教程中通过设置按钮事件,使用 Playmaker 的 FSM 发送事件来触发不同场景的加载。
Outlines
😀 Unity教程开场及感谢
DG Dino 来自 Jinx Games,感谢购买 Playmaker 资源包的用户,并请求评价。预告下一个游戏教程,将加入 Playmaker 资源包。教程制作因遇到问题而延迟,DG Dino 测试了 Playmaker 动作和 C# 脚本,发现问题并非动作本身所致,而是加载顺序错误。
🛠️ Unity调试技巧和加载顺序问题
介绍了如何在 Playmaker 中设置断点进行调试。演示了加载级别和玩家的顺序问题,正确的顺序是先加载级别再加载玩家,错误的顺序会导致游戏卡住。强调了加载和激活多个对象时,必须按照正确的顺序进行。
📚 Playmaker 异步加载场景教程
详细解释了如何使用 Playmaker 异步加载场景。包括设置场景名称、索引、加载模式为累加、禁止立即激活场景等。演示了如何通过设置变量和事件监听器来控制场景的加载和激活。
🔄 场景切换和事件监听器的使用
讨论了如何实现场景间的切换,包括设置文本窗口显示当前级别、比较当前级别与加载级别、使用事件监听器响应按钮点击等。强调了在进行场景切换时要考虑玩家的重力影响和激活顺序。
🎨 界面颜色设置和教程总结
介绍了如何根据场景加载状态设置界面颜色,以及如何使用全局事件和事件监听器简化 FSM 的触发。最后,DG Dino 总结了教程内容,并鼓励观众点赞、订阅频道、支持 Patreon、通过 PayPal 捐款或在 Asset Store 购买资产。
📢 教程结束和观众互动
DG Dino 预告了未来可能会有更多关于加载场景的教程,但在此之前他有其他事情要做。他感谢观众观看,并邀请他们点赞、订阅频道,并提供了 Patreon、PayPal 和 Asset Store 的链接,鼓励观众支持他的工作。
Mindmap
Keywords
💡PlayMaker
💡Asset Store
💡Breakpoints
💡Load Scene
💡Async Additive
💡Scene Activation
💡Event
💡Global Transitions
💡Debugging
💡Tutorial
Highlights
DG Dino 感谢购买 Playmaker 样本的用户,并请求评分和评论。
预告下一个教程将是完整的游戏,并将添加到 Playmaker 样本资产中。
教程中遇到了问题,最初以为是 Playmaker 动作的问题,后来发现 C# 脚本也有同样的问题。
介绍了如何设置和使用断点进行调试。
展示了如何加载和激活关卡以及玩家,以及如何通过断点调试。
解释了加载多个对象时激活顺序的重要性。
强调了在卸载场景前必须先激活所有加载的对象。
演示了如何使用 Playmaker 动作设置场景名称和索引。
讨论了使用场景名称而非索引加载场景的优势。
介绍了如何使用异步加载和激活场景。
展示了如何使用 Playmaker 动作激活和取消激活游戏对象。
讨论了在激活玩家场景时需要考虑的重力因素。
演示了如何使用事件监听器和按钮来改变关卡。
介绍了如何使用比较操作来判断当前关卡是否为最低级别。
展示了如何使用全局转换和事件监听器来激活关卡。
讨论了设置文本和背景颜色来反映当前关卡的方法。
讲解了如何使用字符串比较来检查和加载新关卡。
强调了在加载新场景前先激活当前场景的重要性。
介绍了如何使用发送事件来无需箭头连接地触发事件监听器。
教程最后,DG Dino 邀请观众点赞、订阅频道,并支持他的工作。
Transcripts
hi I'm DG Dino from jinx games and this
tutorial is about how to use loads seen
async additive let's get started
but first I would like to thank everyone
who purchased my play maker samples on
the asset store also I would like to ask
if you could rate the asset and maybe
give a review also I would like to show
you a preview on my next tutorial and
this is going to be a proper game and
this will also be added to my play maker
samples asset and now let's start with
the tutorial it took a little bit longer
than I expected to make this tutorial
because I ran into some issues and at
first I thought there were some issues
with some of the actions I used so then
I made the same sample in a c-sharp
script and noticed that I had the same
issues so then I decided to rebuild the
sample and also show you what not to do
now let's place some breakpoints and
play this so you can see how this works
you can right-click on a state and click
this toggle breakpoint to set a
breakpoint here and if you click it
again it will disable this breakpoint
again and you can see on a state here
when a breakpoint is active you have
this red rectangle here and place
another one and what this does is when
you play the game and it reaches this
state the game will be paused and
anything inside the state is not yet
activated so everything before has been
done and it stops here and then you can
unpause and then you can continue and
that's very useful for debugging let's
play this
so first I'm loading my level then I'm
loading my player and then
activating my level and then I am
activating my player and then I can
choose a different level I have only
four now and just activated and as you
can see I have a different level here
and also different camera position so
level four or level two and back to
level one
okay so let's go to the states now and
first I will explain you the issue I had
so this works fine but this side won't
work and let me go first in here in here
I just have a sent event so it goes
automatically here for working so I'm
gonna turn this off now on both and now
I need to click this myself I can all
click this or command-click I think but
I can also do this in the inspector and
how to get this in inspector is very
simple you just select an event and just
turn on inspector and now you can click
on this to trigger so let's play this
and I now go to not working and as you
can see it just get stuck here and the
reason for this is because I loaded the
player then I loaded to level and then I
wanted to activate the level and after
that I wanted to activate the player so
I first loaded the player and then level
and then I wanted to activate the level
and that is an issue so the way you
should do this if you load multiple
things before activating them you need
to activate them in this
same sequence so here I loaded first the
level and then the player and an
activate level and then player here I
did I swapped these two so I loaded the
player and then loaded the level and
this gives issues that it gets stuck
here and also in a c-sharp script it
just gets stuck it doesn't give errors
it just doesn't do anything so it's
unity issue and nothing to do with these
actions I will try to find if there is a
solution for this that it will at least
give a failure event but for now just be
careful that you always use the right
sequence now for unloading because I'm
also unloading this other level so if I
load a level I'm gonna unload the other
level so the current level I have the
issue with the allow scene activation
here so when I want to unload and I have
something loaded that isn't activated
yet
then I it gets stuck also and if i do
first activation and then unload then
it's fine so also if you have more
things loaded you need to activate them
all and then unload so be careful with
that let's look now two old states so
this one is just the same event so it
would go automatically that's just for
debugging and for the tutorial here so
you can choose to turn it on or you can
just use these two for working and not
working but let me set this back to
automatic then when I go here I have my
set string value and I'm gonna set my
I first seen so that's gonna be level
one and here you can see it's the same
scene name and then I have this current
level in an int so I use this for the
index I'll show you later on and then I
have my load level and this is actually
to reset it so it's it's on zero and
then I have my load seen asic and my
scene reference is seen by name and not
at index and I prefer to do this by name
because if I have in the build setting a
different position here are the index
numbers and you see level 1 is index 3
so you might get issues with that and
that's why I prefer to use names then my
load scene mode is additive because I
want to add this to this scene then I
have allow scene activation set to false
as I don't want it to activate
immediately I want to load it first and
do something and then I want to activate
it later on okay so in the result I have
this async operation hash and I cannot
see what's the complete word here but
anyway this is to save the index for
this load scene so I can use this on
activate action to know which scene that
is so it's like an index number then I
have done event and the done event is if
you have your allow scene activation on
else it will not finish so it will not
be done so then you can use the pending
activation event and I'm
using this level loaded you can also use
an error for the scene not found or
something so but I'm sure it's there
so I didn't use this now then let's go
to the next state and we have the same
load scene async and also seen by name
load scene acing player that's my player
here additive and everything is the same
except I use different variable here for
hash player and here I had a progress
but it just worked so fast so doesn't
really matter but you can use it if you
want then I have began this pending and
I'm going to the next one and here I
have activate game object and I'm
deactivating my camera my main camera
because I have a camera here on my main
and on all the scenes I also have
cameras so I deactivate this first and
then I activate the scene so this is my
level scene that I'm activating as this
is the index from the level that is
stored on the hash level like it it see
here somewhere yeah
here the progress is also not needed and
then I have this is done bull but I
don't need it also here actually but I
do have this done event and a failure
event and when it's done it goes to the
next one and then I'm just setting the
color for this background and then I
have to allow scene activation for the
player and at this moment
I have to do my scene first and then my
player because my player has gravity and
if my player would be placed first it
might fall down so that are things that
you have to think of when you use this
and here I just have a listener and
that's listening to my buttons here solo
previous and alone next next scene is a
button and you can connect this with
dropping this in and then playmaker fsm
send event and then put the name here
for the event and as you can see here
load previous and next then if I would
press the previous I'm doing this in
compare for the current level so here's
my current level now and I'm gonna check
if it's level one so if it's equal it
say it is lowest level already and less
than also just for a fail-safe so if
it's equal or less then it should go
back to the listener and do nothing
because there is no lower level and if
it's greater than I'm gonna load the
lower level and I'm just doing in ad
minus one on my current level and then I
do this in two operator minus one here
so actually I'm doing this ad minus one
so actually deducting one and I'm gonna
store this result in this load level
variable and why I do this because of
the array because an array starts with
I mean zero and not with one and that's
why I just deduct one for this level and
it's easier like this so my level one is
gonna be one and my level four is gonna
be for and to get it from the array I
just have this minus one so level four
will be on element 3 so that's why I use
this so I'm getting the string here for
my load level scenes and show it here
again here just text for the load level
async level 1 2 3 4 and as you can see
they are the same as here and then I'm
gonna set this text here on this text
window and then I'm gonna compare if my
string so if my current level string is
the same as the load level string so
here I am saving this load level string
here and here I've set this current
level string and so so if it's the same
if it's equal it's gonna send this same
event and gonna go here if it's not
equal then it's gonna set the background
color to white and continue so let me
show you here the same level and I'm
just changing the color and going back
to the listener and here I just have
white and also back to the listener and
that's just it to change the level in
the check highest so I'm gonna look if
the highest level is 4 if it's higher is
equal or greater then it goes back to
the listener and if it's lower it's
gonna in add
so that's just for the levels then if I
press activate so you can see I have
this set as a global so anytime I can
press this activate and that's why I use
Global's and you can just right click at
global transitions and place them so
that's a big advantage of Global's that
you can send or trigger them anytime
inside this episode so also I have this
on a button here the same as I showed
you before so I'm not gonna show it
again now and here again this was just
for debugging so for the working or not
working I'm gonna set this on also again
and then I have my string compare and
I'm gonna compare the current level
string to the load level string and if
it's equal I have this event listener
but I don't have it here
but I do have it here as a global and
this is again a nice thing here so if we
have some global things here you can
just set this listener or set this event
and you don't need to wire it so like
like this part
I wanted to group it separately so it
just looks nicer also like this then I
have here another wire and here another
wire so in performance it's the same so
I like to do this especially if I'm
grouping things together so but that's
all up to you of course now so if it's
equal it goes back to the listener here
and then I can change levels again and
if it's not equal I will have this done
event and I'm gonna go here and
gonna load this scene so the scene that
I selected and I'm gonna store this hash
level so that index again also additive
progress we can't really see the next is
my pending activation so the pool is
also not really needed now and it's done
also not it's just to show you that you
can set these then done event is also
empty because I have my allow scene
activation turn off so I need to use
this one to continue and then after I've
loaded this and I did some stuff then I
can activate that scene and then unload
the currency so important is first to
activate everything and then unload else
you will get stuck once it's loaded I
have my set string value here and I'm
just gonna set this current level with
this load level so load level is the new
level that was loaded and it's gonna be
set to the current level because that's
the current active now and then I have
just this current level string for the
text to change this one here and then
I'm setting this color to red as it
would be the same as the current and a
load so that's why I turned this back to
red here and then I have a send event
here because I didn't want to put this
connection I could just do like this
finished and in connect this but I
wanted just to use use it without wire
without an arrow and so I use the send
event and the target itself so to this
FSM here and then I'm just sending an
event listener
and I'm just sending this to this
listener again so it will go back here
and well that is about all for this
tutorial and I'm probably gonna do some
more load scene tutorials but first I
have some other things to do so anyway
thank you for watching if you liked the
tutorial please like the video and don't
forget to subscribe to my channel you
can support my work by becoming a patron
at patreon or donate me with PayPal or
purchase my assets on the asset store
you can find the links in the
descriptions below
Browse More Related Video
Adding an App Icon and Launch Screen to SwiftUI | Todo List #7
Unreal Engine 5 RPG Tutorial Series - #20: AI Behavior Trees Patrolling
How to Set Up an Unreal Engine 5 Git Repository - SourceTree Source Control
Nuxt Instance Unavailable - Async Code in Vue and Nuxt with the Composition API (+ raffle 🎁)
New apk without Activation for play games with keyboard and mouse in mobile like Computer |free fire
macOS Menu Bar App (Code Along) | SwiftUI, Xcode
5.0 / 5 (0 votes)