Skip to content

Commit d9cec0e

Browse files
authored
Merge pull request #62 from VirtueSky/dev
Dev
2 parents 3684580 + cb12303 commit d9cec0e

11 files changed

+89
-109
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
### 1: Download the repository and drop it into folder `Assets`
2424
### 2: Add the line below to `Packages/manifest.json`
2525

26-
for version `3.3.9`
26+
for version `3.4.0`
2727
```json
28-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.3.9",
28+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.4.0",
2929
```
3030

3131
## Includes modules

VirtueSky/ATT_IOS/Editor/PostBuildStep.cs

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ public static class PostBuildStep
1010
public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToXcode)
1111
{
1212
if (buildTarget != BuildTarget.iOS) return;
13+
ModifyInfoPlist(pathToXcode);
14+
CopyGoogleServiceInfoPlist(pathToXcode);
15+
AddCapability(pathToXcode);
16+
}
1317

14-
// === 1. Modify Info.plist ===
18+
static void ModifyInfoPlist(string pathToXcode)
19+
{
1520
string plistPath = Path.Combine(pathToXcode, "Info.plist");
1621
PlistDocument plistObj = new PlistDocument();
1722
plistObj.ReadFromString(File.ReadAllText(plistPath));
1823
PlistElementDict plistRoot = plistObj.root;
19-
plistRoot.SetString("NSUserTrackingUsageDescription", "Your data will be used to provide you a better and personalized ad experience.");
24+
plistRoot.SetString("NSUserTrackingUsageDescription",
25+
"Your data will be used to provide you a better and personalized ad experience.");
2026
File.WriteAllText(plistPath, plistObj.WriteToString());
27+
}
2128

22-
// === 2. Copy GoogleService-Info.plist ===
29+
static void CopyGoogleServiceInfoPlist(string pathToXcode)
30+
{
2331
string sourceSplitPath = Path.Combine("Assets", "GoogleService-Info.plist");
2432
string destSplitPath = Path.Combine(pathToXcode, "GoogleService-Info.plist");
2533
if (File.Exists(sourceSplitPath))
@@ -31,29 +39,42 @@ public static void OnPostProcessBuild(BuildTarget buildTarget, string pathToXcod
3139
{
3240
UnityEngine.Debug.LogWarning("[PostBuildStep] GoogleService-Info.plist not found in Assets.");
3341
}
42+
}
3443

35-
// === 3. Setup Push Notification Capability ===
44+
static void AddCapability(string pathToXcode)
45+
{
3646
string projPath = PBXProject.GetPBXProjectPath(pathToXcode);
3747
PBXProject proj = new PBXProject();
3848
proj.ReadFromFile(projPath);
3949

4050
string targetGuid = proj.GetUnityMainTargetGuid();
51+
string frameworkTargetGuid = proj.GetUnityFrameworkTargetGuid();
4152

42-
// Determine environment type (Debug or Release)
4353
string apsEnvironment = EditorUserBuildSettings.development ? "development" : "production";
4454

45-
// Create Entitlements.entitlements
46-
string entitlementsFileName = "Entitlements.entitlements";
47-
string entitlementsPath = Path.Combine(pathToXcode, entitlementsFileName);
55+
// Use a safe path
56+
string entitlementsFileName = "Unity-iPhone/Entitlements.entitlements";
57+
string entitlementsFullPath = Path.Combine(pathToXcode, entitlementsFileName);
58+
59+
// Create Entitlements file
4860
PlistDocument entitlements = new PlistDocument();
4961
entitlements.root.SetString("aps-environment", apsEnvironment);
50-
File.WriteAllText(entitlementsPath, entitlements.WriteToString());
62+
File.WriteAllText(entitlementsFullPath, entitlements.WriteToString());
63+
64+
// Capability manager
65+
var projCapability = new ProjectCapabilityManager(projPath, entitlementsFileName, "Unity-iPhone");
66+
67+
projCapability.AddPushNotifications(false);
68+
69+
#if VIRTUESKY_APPLE_AUTH
70+
projCapability.AddSignInWithApple();
71+
#endif
5172

52-
// Add Push Notification capability and entitlements
53-
proj.AddCapability(targetGuid, PBXCapabilityType.PushNotifications, entitlementsFileName);
73+
projCapability.WriteToFile();
5474

55-
// Use SetBuildProperty to avoid duplicate CODE_SIGN_ENTITLEMENTS
75+
// update build property for target
5676
proj.SetBuildProperty(targetGuid, "CODE_SIGN_ENTITLEMENTS", entitlementsFileName);
77+
proj.SetBuildProperty(frameworkTargetGuid, "CODE_SIGN_ENTITLEMENTS", entitlementsFileName);
5778

5879
proj.WriteToFile(projPath);
5980
}
@@ -66,7 +87,8 @@ public static void OnPostProcessBuildAddFirebaseFile(BuildTarget buildTarget, st
6687
string projPath = PBXProject.GetPBXProjectPath(pathToBuiltProject);
6788
PBXProject proj = new PBXProject();
6889
proj.ReadFromFile(projPath);
69-
proj.AddFileToBuild(proj.GetUnityMainTargetGuid(), proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
90+
proj.AddFileToBuild(proj.GetUnityMainTargetGuid(),
91+
proj.AddFile("GoogleService-Info.plist", "GoogleService-Info.plist"));
7092
proj.WriteToFile(projPath);
7193
}
7294
}

VirtueSky/Component/FollowTargetComponent.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ public class FollowTargetComponent : BaseMono
1313
private Transform currentTrans;
1414

1515
[Space, SerializeField] private Transform targetTrans;
16-
[ReadOnly, SerializeField] private Vector3 offsetTrans;
16+
[SerializeField] private bool useOffsetTrans = true;
17+
18+
[ShowIf(nameof(useOffsetTrans), true), ReadOnly, SerializeField]
19+
private Vector3 offsetTrans;
20+
1721
[Space, SerializeField] private DirectionFollowTarget directionFollowTarget;
1822
[Space, SerializeField] private TypeFollowTarget typeFollowTarget;
1923

@@ -89,7 +93,7 @@ private void Awake()
8993
currentTrans = gameObject.transform;
9094
}
9195

92-
offsetTrans = currentTrans.position - targetTrans.position;
96+
offsetTrans = useOffsetTrans ? currentTrans.position - targetTrans.position : Vector3.zero;
9397
}
9498

9599
public void SetTarget(Transform t)

VirtueSky/ControlPanel/ConstantPackage.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class ConstantPackage
44
{
5-
public const string VersionSunflower = "3.3.9";
5+
public const string VersionSunflower = "3.4.0";
66
public const string PackageNameInAppPurchase = "com.unity.purchasing";
77
public const string MaxVersionInAppPurchase = "4.12.2";
88
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
@@ -15,12 +15,12 @@ public class ConstantPackage
1515
public const string MaxVersionAddressables = "1.21.21";
1616

1717
public const string PackageNameLevelPlay = "com.unity.services.levelplay";
18-
public const string MaxVersionLevelPlay = "8.8.1";
18+
public const string MaxVersionLevelPlay = "8.10.0";
1919

2020
public const string PackageNameAdmob = "com.google.ads.mobile";
2121

2222
public const string VersionAdmob =
23-
"https://github.com/googleads/googleads-mobile-unity.git?path=packages/com.google.ads.mobile#v10.2.0";
23+
"https://github.com/googleads/googleads-mobile-unity.git?path=packages/com.google.ads.mobile#v10.3.0";
2424

2525
#region Google Unity
2626

@@ -52,37 +52,37 @@ public class ConstantPackage
5252
public const string PackageNameFirebaseApp = "com.google.firebase.app";
5353

5454
public const string MaxVersionFirebaseApp =
55-
"https://github.com/RageAgainstThePixel/com.google.firebase.app.git#12.9.0";
55+
"https://github.com/RageAgainstThePixel/com.google.firebase.app.git#12.10.1";
5656

5757
public const string PackageNameFirebaseRemoteConfig = "com.google.firebase.remote-config";
5858

5959
public const string MaxVersionFirebaseRemoteConfig =
60-
"https://github.com/RageAgainstThePixel/com.google.firebase.remote-config.git#12.9.0";
60+
"https://github.com/RageAgainstThePixel/com.google.firebase.remote-config.git#12.10.1";
6161

6262
public const string PackageNameFirebaseAnalytics = "com.google.firebase.analytics";
6363

6464
public const string MaxVersionFirebaseAnalytics =
65-
"https://github.com/RageAgainstThePixel/com.google.firebase.analytics.git#12.9.0";
65+
"https://github.com/RageAgainstThePixel/com.google.firebase.analytics.git#12.10.1";
6666

6767
public const string PackageNameFirebaseDatabase = "com.google.firebase.database";
6868

6969
public const string MaxVersionFirebaseDatabase =
70-
"https://github.com/RageAgainstThePixel/com.google.firebase.database.git#12.9.0";
70+
"https://github.com/RageAgainstThePixel/com.google.firebase.database.git#12.10.1";
7171

7272
public const string PackageNameFirebaseAuth = "com.google.firebase.auth";
7373

7474
public const string MaxVersionFirebaseAuth =
75-
"https://github.com/RageAgainstThePixel/com.google.firebase.auth.git#12.9.0";
75+
"https://github.com/RageAgainstThePixel/com.google.firebase.auth.git#12.10.1";
7676

7777
public const string PackageNameFirebaseCrashlytics = "com.google.firebase.crashlytics";
7878

7979
public const string MaxVersionFirebaseCrashlytics =
80-
"https://github.com/RageAgainstThePixel/com.google.firebase.crashlytics.git#12.9.0";
80+
"https://github.com/RageAgainstThePixel/com.google.firebase.crashlytics.git#12.10.1";
8181

8282
#endregion
8383

8484
public const string PackageNameAdjust = "com.adjust.sdk";
85-
public const string MaxVersionAdjust = "https://github.com/adjust/unity_sdk.git?path=Assets/Adjust#v5.4.0";
85+
public const string MaxVersionAdjust = "https://github.com/adjust/unity_sdk.git?path=Assets/Adjust#v5.4.1";
8686
public const string PackageNamePlayFab = "com.pancake.playfab";
8787

8888
public const string MaxVersionPlayFab =
@@ -91,12 +91,12 @@ public class ConstantPackage
9191
public const string PackageNameAppFlyer = "appsflyer-unity-plugin";
9292

9393
public const string MaxVersionAppFlyer =
94-
"https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git?path=Assets/AppsFlyer#v6.16.21";
94+
"https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git?path=Assets/AppsFlyer#v6.17.1";
9595

9696
public const string PackageNameCoffeeUIEffect = "com.coffee.ui-effect";
9797

9898
public const string MaxVersionCoffeeUIEffect =
99-
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.2";
99+
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.5";
100100

101101
public const string PackageNameCoffeeUIParticle = "com.coffee.ui-particle";
102102

@@ -105,7 +105,8 @@ public class ConstantPackage
105105

106106
public const string PackageNameAppleSignIn = "com.lupidan.apple-signin-unity";
107107

108-
public const string MaxVersionAppleSignIn = "https://github.com/lupidan/apple-signin-unity.git#v1.5.0";
108+
public const string MaxVersionAppleSignIn =
109+
"https://github.com/lupidan/apple-signin-unity.git?path=Source#1.5.0";
109110

110111
#region Spine
111112

VirtueSky/GameService/Editor.meta

Lines changed: 0 additions & 8 deletions
This file was deleted.

VirtueSky/GameService/Editor/SignInWithApplePostprocessor.cs

Lines changed: 0 additions & 39 deletions
This file was deleted.

VirtueSky/GameService/Editor/SignInWithApplePostprocessor.cs.meta

Lines changed: 0 additions & 3 deletions
This file was deleted.

VirtueSky/GameService/Editor/Virtuesky.Sunflower.GameService.Editor.asmdef

Lines changed: 0 additions & 19 deletions
This file was deleted.

VirtueSky/GameService/Editor/Virtuesky.Sunflower.GameService.Editor.asmdef.meta

Lines changed: 0 additions & 7 deletions
This file was deleted.

VirtueSky/GameService/Runtime/AppleAuthentication.cs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Text;
22
using UnityEngine;
3+
using VirtueSky.Events;
34
using VirtueSky.Inspector;
45
using VirtueSky.Variables;
56

@@ -20,6 +21,7 @@ public class AppleAuthentication : ServiceAuthentication
2021
{
2122
[SerializeField] private StringVariable authorizationCodeVariable;
2223
[SerializeField] private StringVariable userIdVariable;
24+
[SerializeField] private EventNoParam tryLoginEvent;
2325

2426
#if UNITY_IOS && VIRTUESKY_APPLE_AUTH
2527
private IAppleAuthManager _iAppleAuthManager;
@@ -39,6 +41,7 @@ protected override void Init()
3941
// Creates an Apple Authentication manager with the deserializer
4042
this._iAppleAuthManager = new AppleAuthManager(deserializer);
4143
loginEvent.AddListener(Login);
44+
tryLoginEvent.AddListener(TryLogin);
4245
}
4346
#endif
4447
}
@@ -108,10 +111,36 @@ protected override void Login()
108111
{
109112
// Something went wrong
110113
var authorizationErrorCode = error.GetAuthorizationErrorCode();
111-
serverCode.Value = "";
112-
userIdVariable.Value = "";
113114
status.SetFailed();
114115
});
116+
#endif
117+
}
118+
119+
/// <summary>
120+
/// Login when Apple credential still valid.
121+
/// </summary>
122+
private void TryLogin()
123+
{
124+
#if UNITY_IOS && VIRTUESKY_APPLE_AUTH
125+
if (string.IsNullOrEmpty(userIdVariable.Value)) return;
126+
this._iAppleAuthManager.GetCredentialState(userIdVariable.Value, state =>
127+
{
128+
switch (state)
129+
{
130+
case CredentialState.Revoked:
131+
break;
132+
case CredentialState.Authorized:
133+
Debug.Log($"Apple credential still valid. Auto-login with userId: {userIdVariable.Value}");
134+
Login();
135+
break;
136+
case CredentialState.NotFound:
137+
Debug.LogWarning("Apple credential invalid or revoked.");
138+
userIdVariable.Value = "";
139+
break;
140+
case CredentialState.Transferred:
141+
break;
142+
}
143+
}, error => { Debug.LogError("CredentialState check failed: " + error.ToString()); });
115144
#endif
116145
}
117146
}

0 commit comments

Comments
 (0)