-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathModifier_Identification.cs
65 lines (53 loc) · 2.19 KB
/
Modifier_Identification.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Text;
using UnityEditor;
namespace Assets.Minamo.Editor {
class Modifier_Identification : IModifier {
readonly BuildTargetGroup targetGroup;
// common
string packageName;
string versionName;
// android = version code
// ios : build number
int versionCode;
internal Modifier_Identification(BuildTargetGroup targetGroup) {
this.targetGroup = targetGroup;
}
public void Reload(AnyDictionary dict) {
packageName = dict.GetValue<string>("packageName");
versionName = dict.GetValue<string>("versionName");
versionCode = dict.GetValue<int>("versionCode");
}
internal static Modifier_Identification Current(BuildTargetGroup targetGroup) {
int versionCode = 0;
if(targetGroup == BuildTargetGroup.Android) {
versionCode = PlayerSettings.Android.bundleVersionCode;
} else if(targetGroup == BuildTargetGroup.iOS) {
if(!int.TryParse(PlayerSettings.iOS.buildNumber, out versionCode)) {
versionCode = 0;
}
}
return new Modifier_Identification(targetGroup)
{
packageName = PlayerSettings.GetApplicationIdentifier(targetGroup),
versionName = PlayerSettings.bundleVersion,
versionCode = versionCode,
};
}
public void Apply() {
PlayerSettings.SetApplicationIdentifier(targetGroup, packageName);
PlayerSettings.bundleVersion = versionName;
if(targetGroup == BuildTargetGroup.Android) {
PlayerSettings.Android.bundleVersionCode = versionCode;
} else if(targetGroup == BuildTargetGroup.iOS) {
PlayerSettings.iOS.buildNumber = versionCode.ToString();
}
}
public string GetConfigText() {
var sb = new StringBuilder();
sb.AppendFormat("packageName={0}, ", packageName);
sb.AppendFormat("versionName={0}, ", versionName);
sb.AppendFormat("versionCode={0}, ", versionCode);
return sb.ToString();
}
}
}