在此介绍一下使用可序列化类保存配置,并且将可序列化类保存成Unity的自定义文件(.asset),然后配置自定义文件(.asset)。
public enum LoadAssetsMode { ?? ?Resources, ?? ?Bundle }
[Serializable] ?? ?[CreateAssetMenu(menuName = "ScriptableOject/BuildConfig")] ?? ?public class BuildConfigTool : ScriptableObject ?? ?{ ?? ??? ?public string configVersion = "1.0.1";
?? ??? ?public LoadAssetsMode loadAssetsMode;
?? ??? ?public string keyStorePassword = "abcdef";
?? ??? ?public string keyStoreAlias = "zjgd";
?? ??? ?public string keyStoreAliasPassword = "123456";
?? ??? ?public int bundleVersionCode = 1;
?? ??? ?public bool isBuildDev; ?? ?}
也可配置图片、颜色、预制体、curve 等
?
读取: 如放在Resources文件夹下的assets文件夹下,则:
BuildConfigTool buildConfigTool = Resources.Load<BuildConfigTool>("assets/BuildConfig"); ?? ??? ?if (buildConfigTool.isBuildDev) ?? ??? ?{ ?? ??? ??? ?aaa(); ?? ??? ?} ?? ??? ?else ?? ??? ?{ ?? ??? ??? ?bbb(); ?? ??? ?}
|