Unity3D-----持久化数据案例应用
2020-06-04 04:48
393 查看
人物换装备
- 制作一个开始界面分别有三个可以更换角色服装的按钮。
- 点击"保存并进入游戏"按钮即可进入游戏场景,在游戏场景诞生角色,并且,角色身上的装备是在开始界面保存的装备效果.
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; ///<summary> /// ///</summary> public class ChageRoleCloth : MonoBehaviour { public Texture[] cloth; private SkinnedMeshRenderer clothRenderer; public GameObject weapon; private int clothIndex = 0; public Mesh[] wpModeCloth; private MeshFilter wpMode; public Texture[] wpCloth; private Renderer wp; private void Start() { clothRenderer = this.GetComponentInChildren<SkinnedMeshRenderer>(); wpMode = weapon.GetComponent<MeshFilter>(); wp = weapon.GetComponent<MeshRenderer>(); } private void OnGUI() { if (GUILayout.Button("服装1")) { clothRenderer.material.mainTexture = cloth[0]; wpMode.mesh = wpModeCloth[0]; wp.material.mainTexture = wpCloth[0]; clothIndex = 0; } if (GUILayout.Button("服装2")) { clothRenderer.material.mainTexture = cloth[1]; wpMode.mesh = wpModeCloth[1]; wp.material.mainTexture = wpCloth[1]; clothIndex = 1; } if (GUILayout.Button("保存服装,并开始游戏")) { PlayerPrefs.SetInt("clothIndex",clothIndex); SceneManager.LoadScene("Goblin"); } } }
相关文章推荐
- Unity3d,数据本地持久化保存与读取PlayerPrefs类
- 数据挖掘应用案例:RFM模型分析与客户细分(转)
- sqoop数据导入导出应用案例
- 大数据平台OLTP应用场景案例分析
- 大数据架构师必读:医药企业大数据应用案例
- 基于Greenplum Hadoop分布式平台的大数据解决方案及商业应用案例剖析
- JAVA笔记14__多线程共享数据(同步)/ 线程死锁 / 生产者与消费者应用案例 / 线程池
- 大数据应用的几个实际案例
- Json数据解析在Unity3d中的应用
- SQLite实现数据持久化存储小案例之购买商品
- 大数据备份和恢复应用案例--通过分区表备份和恢复数据
- PostgreSQL 30天 培训视频(SQL基础,备份恢复,HA,服务端编程,大数据,内核,应用案例)
- 数据挖掘应用案例集
- Unity3d-Json数据解析在登录注册本地存取的应用
- HBase建表高级属性,hbase应用案例看行键设计,HBase和mapreduce结合,从Hbase中读取数据、分析,写入hdfs,从hdfs中读取数据写入Hbase,协处理器和二级索引
- [COPY]大数据 hadoop 应用案例 大众点评
- 案例:中科院光机所应用大数据可视化工具-LightningChart |见证高性能图表
- 数据挖掘算法与现实生活中的应用案例
- 三个应用案例——大数据挖掘潜在的威胁