zoukankan      html  css  js  c++  java
  • Unity Easy Save简单实用

    Easy Save使用:

       1.保存游戏进度
            2.设计游戏关卡(怪物数量,坐标,背景图等等)
       

    Easy Save默认存储地址:

            C:UsersAdministratorAppDataLocalLowDefaultCompany项目名
           

    Easy Save保存的格式:(不能直接保存自定义类)

            http://moodkie.com/easysave/documentation/supported-types/ (保存的常见格式)
           

    Unity路径:

        Application.dataPath;                          //当前项目Asset路径
            Application.streamingAssetsPath;        //当前项目Asset路径streamingAssets文件夹
            Application.persistentDataPath;            //持久化数据库路径
            Application.temporaryCachePath;          //临时缓存路径
           

    简单保存:

     

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;
    
    
    
    
    public class EasySaveDemo1 : MonoBehaviour {
    
        public Student student;
    
        void OnGUI()
        {
            if (GUI.Button(new Rect(0, 0, 300, 120), "保存"))
            {
                Student student = new Student();
                student.name = "盘子";
                student.age = 18;
                student.height = 1.9f;
                student.marriage = false;
    
                List<Student> list = new List<Student>();
    
    
                //ES2Settings set = new ES2Settings(Application.dataPath + "myFile3.text");
                //set.encrypt = false;
                //set.encryptionPassword = "*";
    
                string path = Application.dataPath + "/关卡.text";
    
               //没有保存起是不会抛异常的
                  //多值保存到同一个文件
                  ES2.Save(student.name, path + "?tag=name");
                ES2.Save(student.age, path + "?tag=age");
                ES2.Save(student.height, path + "?tag=height");
                ES2.Save(student.marriage, path + "?tag=marriage");
                
    
            }
    
            if (GUI.Button(new Rect(300, 0, 300, 120), "读取"))
            {
                string path = Application.dataPath + "/关卡.text";
                student = new Student();
                student.name = ES2.Load<string>(path + "?tag=name");
                student.height = ES2.Load<float>(path + "?tag=height");
                student.age = ES2.Load<int>(path + "?tag=age");
                student.marriage = ES2.Load<bool>(path + "?tag=marriage");
                
            }
    
            if (this.student != null)
            {
                GUI.Label(new Rect(0, 120, 300, 120), "姓名:" + student.name);
                GUI.Label(new Rect(0, 150, 300, 120), "身高:" + student.height);
                GUI.Label(new Rect(0, 180, 300, 120), "年龄:" + student.age);
                GUI.Label(new Rect(0, 210, 300, 120), "婚姻:" + student.marriage);
            }
    
    
        }
        
    }
    public class Student 
    {
        public string name;
        public int age;
        public float height;
        public bool marriage;
    }
    如果你感兴趣,你可以把你妹妹介绍给我
  • 相关阅读:
    POJ 1469 COURSES 二分图最大匹配
    POJ 1325 Machine Schedule 二分图最大匹配
    USACO Humble Numbers DP?
    SGU 194 Reactor Cooling 带容量上下限制的网络流
    POJ 3084 Panic Room 求最小割
    ZOJ 2587 Unique Attack 判断最小割是否唯一
    Poj 1815 Friendship 枚举+求最小割
    POJ 3308 Paratroopers 最小点权覆盖 求最小割
    1227. Rally Championship
    Etaoin Shrdlu
  • 原文地址:https://www.cnblogs.com/plateFace/p/4202281.html
Copyright © 2011-2022 走看看