当前位置: 首页 > wzjs >正文

app开发人员网站网站快速搜索

app开发人员网站,网站快速搜索,专业手机网站建设哪家好,网站建设需要哪些工作室1、目标 保存下面库存栏中信息到文件中。 2、修改SceneSave.cs脚本 添加2行代码: 3、修改InventoryManager对象 添加Generate GUID组件。 4、修改InventoryManager.cs脚本 添加继承自ISaveable 添加属性信息: private string _iSaveableUniqueID;pub…

1、目标

保存下面库存栏中信息到文件中。

2、修改SceneSave.cs脚本

添加2行代码:

3、修改InventoryManager对象

添加Generate GUID组件。

4、修改InventoryManager.cs脚本

添加继承自ISaveable

添加属性信息:

    private string _iSaveableUniqueID;public string ISaveableUniqueID { get { return _iSaveableUniqueID; } set { _iSaveableUniqueID = value; } }private GameObjectSave _gameObjectSave;public GameObjectSave GameObjectSave { get { return _gameObjectSave; } set { _gameObjectSave = value; } }private UIInventoryBar inventoryBar;

在Awake()方法中添加2行代码:

添加如下几个方法:

 private void OnDisable(){ISaveableDeregister();}private void OnEnable(){ISaveableRegister();}private void Start()
{inventoryBar = FindObjectOfType<UIInventoryBar>();
}public void ISaveableRegister(){SaveLoadManager.Instance.iSaveableObjectList.Add(this);}public void ISaveableDeregister(){SaveLoadManager.Instance.iSaveableObjectList.Remove(this);}public GameObjectSave ISaveableSave(){// Create new scene saveSceneSave sceneSave = new SceneSave();// Remove any existing scene save for persistent scene for this gameobjectGameObjectSave.sceneData.Remove(Settings.PersistentScene);// Add inventory lists array to persistent scene savesceneSave.listInvItemArray = inventoryLists;// Add inventory list capacity array to persistent scene savesceneSave.intArrayDictionary = new Dictionary<string, int[]>();sceneSave.intArrayDictionary.Add("inventoryListCapacityArray", inventoryListCapacityIntArray);// Add scene save for gameobjectGameObjectSave.sceneData.Add(Settings.PersistentScene, sceneSave);return GameObjectSave;}public void ISaveableLoad(GameSave gameSave){if(gameSave.gameObjectData.TryGetValue(ISaveableUniqueID, out GameObjectSave gameObjectSave)){GameObjectSave = gameObjectSave;// Need to find inventory lists - start by trying to locate saveScene for game objectif(gameObjectSave.sceneData.TryGetValue(Settings.PersistentScene, out SceneSave sceneSave)){// list inv items array exists for persistent sceneif(sceneSave.listInvItemArray != null){inventoryLists = sceneSave.listInvItemArray;// Send events that inventory has been updatedfor(int i = 0; i < (int)InventoryLocation.count; i++){EventHandler.CallInventoryUpdatedEvent((InventoryLocation)i, inventoryLists[i]);}// Clear any items player was carryingPlayer.Instance.ClearCarriedItem();// Clear any highlights on inventory barinventoryBar.ClearHighlightOnInventorySlots();}// int array dictionary exists for sceneif(sceneSave.intArrayDictionary != null && sceneSave.intArrayDictionary.TryGetValue("inventoryListCapacityArray", out int[] inventoryCapacityArray)){inventoryListCapacityIntArray = inventoryCapacityArray;}}}}public void ISaveableStoreScene(string sceneName){// Nothing required here since the inventory manager is on a persistent scene;}public void ISaveableRestoreScene(string sceneName){// Nothing required here since the inventory manager is on a persistent scene;}

5、运行游戏

角色收集的item放到库存栏中,save game后退出游戏,重新进入游戏后load game,库存栏中的信息保持不变。

http://www.dtcms.com/wzjs/567610.html

相关文章:

  • ie禁止访问网站wordpress登陆后
  • 中国设计师个人网站2345手机助手下载安装
  • 建设婚纱摄影网站的重要性服务器放网站
  • 中国建筑业协会官方网站太原网站建设vhuashi
  • 杭州做网站工作室成都五月花网页设计培训
  • 用网站做淘宝客的人多吗html动态页面代码
  • 昭通做网站百度快照推广
  • 网站小程序开发公司网站建设费如何记账
  • 怎样做个做外贸的网站杭州网页模板建站
  • 预约做家庭清洁的网站重庆知名网站
  • 成都微信网站开发四川省城乡建设部网站首页
  • 各大网站黑白连云港网站建设推广
  • 厦门免费自助建站模板翻页大图网站
  • 图木舒克市建设局网站视频软件
  • 事务所网站建设官方网站下载方法
  • 外贸视频网站网站名称在哪里注册
  • 广西城乡建设名网站前端开发网站开发
  • 做美食的网站有那一些关于做网站的创新创业策划书
  • seo站长优化工具做一个什么网站好
  • 电子商务网站推广的方法有哪些网站服务器错误怎么解决
  • 大数据技术建设网站aso优化报价
  • 网站建设公司墨子网络昌平最好的网站建设
  • 漳州正规网站建设哪家便宜计算机网站开发实现总结
  • 设计一个全面了解湖南的网站网站推广排名教程
  • 怎样搭建属于自己的网站小游戏网页版在线玩
  • 做网站导航按钮怎么猛如何用一个域名做多个网站
  • 重庆沙坪坝房价网站建设seo推广
  • 电商网站怎么制作vi设计公司
  • 做图片类型的网站要怎么做wordpress 购买按钮
  • 给公司做一个网站吗wordpress推荐文章