不允许销毁资产以避免数据丢失 [英] Destroying asset is not permitted to avoid data lose

查看:847
本文介绍了不允许销毁资产以避免数据丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好我试图为我的游戏创建一个重置按钮,一旦点击所有游戏对象并从当前场景中销毁游戏对象已被重置为原始状态,下面的代码似乎是这个错误是关于如何停止的任何想法这个: -



//重置星星

if(whatToSpawnClone.Count> 0)

{

for(int i = 0; i< whatToSpawnClone.Count; i ++)

{

if(whatToSpawnClone [i]!= null)

{

Destroy(whatToSpawnClone [i]);

}

}

}



在这个当前场景中有4个游戏对象,其中一些如果不是全部都可以被销毁,但如果玩家犯了错误我需要这个重置来修改场景开始。



我尝试过:



DestroyImmediate( )不是答案,因为这是一个循环是永恒的

hi all im trying to create a reset button for my game where once clicked all gameobject and destroyed gameobject from the current scene have been reset to the origanal state the code below seems to be where this error is any ideas on how to stop this :-

//reset stars
if (whatToSpawnClone.Count > 0)
{
for (int i = 0; i < whatToSpawnClone.Count; i++)
{
if (whatToSpawnClone[i] != null)
{
Destroy(whatToSpawnClone[i]);
}
}
}

there are 4 gameobject in this current scene where some if not all can be destroyed, but if the player makes a mistake i need this reset to amend the scene to the start.

What I have tried:

DestroyImmediate() is not the answer as this is a loop which will be eternal

推荐答案

当用户开始新游戏时,你会调用与初始化游戏状态相同的方法。你有这样的方法或方法,对吗?



至于Destroy和DestroyImmediate方法,那些似乎是你的创作,因为你已经说过任何关于使用任何游戏的内容引擎库。



我们对你如何跟踪游戏状态或设置方式一无所知,所以任何人都不可能告诉你任何有用的东西。
You would call the same method you used to initialize the game state when a user starts a new game. You DO have such a method or methods, correct?

As for the Destroy and DestroyImmediate methods, those appear to be your creations as you have said anything about using any game engine libraries.

We know nothing about how you are tracking game state or how it's setup so it's pretty much impossible for anyone to tell you anything useful.


这篇关于不允许销毁资产以避免数据丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆