简体   繁体   English

在游戏中间保存场景

[英]Save scene in middle of game

I made a mini-game that when you near some object if the user press an specific key it changes the scene, on that scene there is an option to return to the main scene But when it return to the main scene it goes back to the original position and not on the previous position.我做了一个小游戏,当你靠近一些 object 时,如果用户按下特定键,它会改变场景,在那个场景上有一个返回主场景的选项但是当它返回主场景时,它会返回原装 position 而不是以前的 position。 How can i make to when the player returns to the main scene he spawns on the previous position?当玩家返回他在之前的 position 上生成的主要场景时,我该怎么做?

Thanks in advance.提前致谢。

You've to store the scene currently state on a variable.您必须将当前 state 的场景存储在一个变量上。

If for example you have a button that can have two states you have to store the state of the button in a variable of an object that will be marked as DontDestroyOnLoad, or save it in a file, so when you load again the scene, you have to set the scene from the information of your stored variable.例如,如果您有一个可以具有两种状态的按钮,则必须将按钮的 state 存储在 object 的变量中,该变量将被标记为 DontDestroyOnLoad,或者将其保存在文件中,因此当您再次加载场景时,您必须从您存储的变量的信息中设置场景。

You can also set your scene (or objects than can mutate) to DontDestroyOnLoad and change deactivate them on the new scene.您还可以将您的场景(或不能变异的对象)设置为DontDestroyOnLoad并在新场景中更改停用它们。 But this is really dirty.但这真的很脏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM