public static void Save(string fileName, object saveObject) { //获取文件路径,有两个地方可以选择 string savePath = GetGameSaveFilePath(fileName); Logger.Log("保存文件:" + savePath); BinaryFormatter formatter = new BinaryFormatter(); FileStream saveFile = File.Create(savePath); formatter.Seriali...
if(File.Exists(Application.persistentDataPath +"/gamesave.save")) { ClearBullets(); ClearRobots(); RefreshRobots(); // 2 BinaryFormatter bf =newBinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath +"/gamesave.save", FileMode.Open); Save save = (Save)bf.Deserialize(file...
要保存游戏,在玩的过程中按下 esc 键,然后点击 Save 按钮。你会注意到所有东西都被重置了,控制台会显示一条消息,说游戏已经被保存。 在Game 脚本中 LoadGame 方法已经连接到 Load 按钮了。打开 Game 脚本,找到 LoadGame 函数。将它修改为: public void LoadGame() { // 1 if (File.Exists(Application.pers...
Easy Save可以很方便的给文件加密,这里用的第三个版本;其中filePassCode是文件解密的密码,它的后台用的是Rijndael算法 3.写(存档) 1staticpublicvoidWriteGameSaveData(stringfileName)2{3BinaryFormatter bf =newBinaryFormatter();4FileStream file = File.Create(Application.persistentDataPath +"/"+fileName);5bf.S...
你可能已经猜到了,暂停可用于暂停Game 视图中运行的游戏。该功能有助于你发现通过其他方法不能发现的视觉效果问题或游戏体验问题。 单步执行 (Step) 单步执行用于逐帧浏览暂停的场景。在游戏世界中寻找需要实时观察的实时变化时,该按钮非常有效。 操纵对象
因为我们的游戏非常简单,所以我们将只使用一个Game组件脚本来控制它。它会根据我们的预制体生成立方体。所以它需要包含一个公共字段来连接一个预置实例。 在场景中添加一个游戏对象,并将此组件附加到上面。然后再创建一个默认的立方体,把它转化成一个预置,并给游戏对象一个它的引用。
1、【File】->【New Scene】创建一个新场景,由于我们的Onclick表示要切到Game场景里面去,所以我们马上【File】->【Save Scene】一个叫Game就可以,然后Game场景我们需要布置如下的UI,具体如下图所示,除了Slider部分属性需要调整一下以外,其余没什么好说的,其中这里的Whole Numbers表示Slider是全条都可以使用,而不是...
(1)新建场景。选择“File”→“New Scene”,然后选择“File”→“Save Scene”选项(或者Ctrl+S),在保存对话框中输入场景名“GameScene”,如图4-24所示。▲图4-24 新建场景(2)创建光源。选择“GameObject”→“Create Other”→“Directional Light”选项后会自动创建一个定向光源,如图4-25所示。
bf=newBinaryFormatter();//打开一个文件流FileStream fileStream=File.Open(Application.dataPath+"/StreamingFile"+"/byBin.txt",FileMode.Open);//调用格式化程序的反序列化方法,将文件流转换为一个Save对象Save save=(Save)bf.Deserialize(fileStream);//关闭文件流fileStream.Close();SetGame(save);UIManager._...
System.IO.Stream s = new System.IO.FileStream(filepath, System.IO.FileMode.Create, System.IO.FileAccess.Write); System.Runtime.Serialization.IFormatter formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter(); formatter.Serialize(s, saveGame); ...