先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
101 lines
2.7 KiB
C#
101 lines
2.7 KiB
C#
using UnityEngine;
|
|
using System;
|
|
using System.Linq;
|
|
using System.IO;
|
|
|
|
public class VersionTool : IComparable<VersionTool>
|
|
{
|
|
public const string Build_Ver_File_Name = "buildver.txt";
|
|
public static string PackVer
|
|
{
|
|
get
|
|
{
|
|
string[] splitVersion = Application.version.Split('.');
|
|
return $"{splitVersion[0]}_{splitVersion[1]}";
|
|
}
|
|
}
|
|
|
|
public int Major { get; private set; }
|
|
public int Minor { get; private set; }
|
|
public string Build { get; private set; }
|
|
|
|
private VersionTool(int major, int minor, string build)
|
|
{
|
|
Major = major;
|
|
Minor = minor;
|
|
Build = build;
|
|
}
|
|
|
|
public static VersionTool FromString(string version)
|
|
{
|
|
string[] splitVersion = version.Split('.');
|
|
return new VersionTool(int.Parse(splitVersion[0]), int.Parse(splitVersion[1]), splitVersion[2]);
|
|
}
|
|
|
|
public static VersionTool FromLocal()
|
|
{
|
|
string appVerStr = Application.version;
|
|
string [] splitVersion = appVerStr.Split('.');
|
|
return new VersionTool(int.Parse(splitVersion[0]), int.Parse(splitVersion[1]), GetLoacalBuild());
|
|
}
|
|
|
|
private static string GetLoacalBuild()
|
|
{
|
|
var persisterBVerFile = $"{Application.persistentDataPath}/{Build_Ver_File_Name}";
|
|
if(File.Exists(persisterBVerFile))
|
|
{
|
|
return File.ReadAllText(persisterBVerFile);
|
|
}
|
|
if (BetterStreamingAssets.FileExists(Build_Ver_File_Name))
|
|
return BetterStreamingAssets.ReadAllText(Build_Ver_File_Name);
|
|
return "None";
|
|
}
|
|
|
|
public int CompareTo(VersionTool other)
|
|
{
|
|
int result = Major.CompareTo(other.Major);
|
|
if (result == 0)
|
|
{
|
|
result = Minor.CompareTo(other.Minor);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
public static bool operator >(VersionTool a, VersionTool b)
|
|
{
|
|
return a.CompareTo(b) > 0;
|
|
}
|
|
|
|
public static bool operator <(VersionTool a, VersionTool b)
|
|
{
|
|
return a.CompareTo(b) < 0;
|
|
}
|
|
public static bool operator ==(VersionTool a, VersionTool b)
|
|
{
|
|
return a.CompareTo(b) == 0;
|
|
}
|
|
|
|
public static bool operator !=(VersionTool a, VersionTool b)
|
|
{
|
|
return a.CompareTo(b) !=0 ;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return $"Ver {Major}_{Minor}_{Build}";
|
|
}
|
|
|
|
public string ToVerString()
|
|
{
|
|
Debug.Log($"{Major}.{Minor}.{Build}");
|
|
return $"{Major}.{Minor}.{Build}";
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
var persisterBVerFile = $"{Application.persistentDataPath}/{Build_Ver_File_Name}";
|
|
File.Delete(persisterBVerFile);
|
|
File.WriteAllText(persisterBVerFile, Build);
|
|
}
|
|
}
|