Beispiel #1
0
    public void ChangeVOL(float i)
    {
        if (Gaming)                    //判断该滑杆的属性
        {
            VOLBaseSetting.BgmVOL = i; //给全局变量赋值,i是当前拖动滑杆的值
        }
        else if (Prop)
        {
            VOLBaseSetting.PropVOL = i;
        }
        else if (Action)
        {
            VOLBaseSetting.ActionVOL = i;
        }
        BGM.GetComponent <AudioSource>().volume = i;
        var model = new VOLBase();

        model.ActionVOL = VOLBaseSetting.ActionVOL;
        model.PropVOL   = VOLBaseSetting.PropVOL;
        model.BgmVOL    = VOLBaseSetting.BgmVOL;
        //根据最新的音量配置实例化一个新的实体,转换成Json串
        var str = JsonUtility.ToJson(model);

        SaveJson.Save(GameBaseSetting.VolJsonPath, str);//保存到本地
    }
Beispiel #2
0
 //
 void Awake()
 {
     Time.timeScale = 1; GameBaseSetting.Life = 5;                //初始化生命值
     GameBaseSetting.PartPosition = new int[] { -68, 0, 20, 36 }; //初始化地图位置
     GameBaseSetting.Score        = 0;                            //分数
     GetValue();
     SetValue();
     if (!File.Exists(GameBaseSetting.VolJsonPath))//初次打开设置音量
     {
         File.Create(GameBaseSetting.VolJsonPath).Dispose();
         VOLBase vOL = new VOLBase()
         {
             ActionVOL = 0.5f, BgmVOL = 0.5f, PropVOL = 0.5f
         };
         File.WriteAllText(GameBaseSetting.VolJsonPath, JsonUtility.ToJson(vOL));
     }
 }