Skip to content

Commit 50f9533

Browse files
authored
Merge pull request #78 from VirtueSky/dev
Dev
2 parents 0759d82 + de58432 commit 50f9533

12 files changed

Lines changed: 99 additions & 83 deletions

File tree

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.5.1`
26+
- for version `3.5.2`
2727
```json
28-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.5.1",
28+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.5.2",
2929
```
3030
- depencies:
3131
```json

VirtueSky/Advertising/Runtime/LevelPlay/LevelPlayAdClient.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public override void Initialize()
3333
LevelPlay.ValidateIntegration();
3434
LevelPlay.Init(adSetting.AppKey);
3535
#endif
36-
LoadInterstitial();
37-
LoadRewarded();
38-
LoadBanner();
3936
}
4037

4138
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
@@ -53,12 +50,16 @@ private void OnAppStateChange(bool pauseStatus)
5350
{
5451
LevelPlay.SetPauseGame(pauseStatus);
5552
}
53+
5654
void SdkInitializationCompletedEvent(LevelPlayConfiguration config)
5755
{
5856
SdkInitializationCompleted = true;
57+
LoadInterstitial();
58+
LoadRewarded();
59+
LoadBanner();
5960
}
6061
#endif
61-
62+
6263

6364
public override void LoadBanner()
6465
{

VirtueSky/Advertising/Runtime/LevelPlay/LevelPlayUnitVariable/LevelPlayBannerVariable.cs

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
using System;
22
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
33
using Unity.Services.LevelPlay;
4+
using VirtueSky.Core;
45
#endif
6+
using System.Collections;
57
using UnityEngine;
68
using VirtueSky.Inspector;
79
using VirtueSky.Misc;
@@ -14,39 +16,42 @@ public class LevelPlayBannerVariable : LevelPlayAdUnitVariable
1416
{
1517
public AdsSize size;
1618
public AdsPosition position;
19+
public bool isShowOnLoad;
1720
private bool _isBannerDestroyed = true;
1821
private bool _isBannerShowing;
1922
private bool _previousBannerShowStatus;
2023
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
21-
private LevelPlayBannerAd bannerAd;
24+
private LevelPlayBannerAd bannerAd;
25+
private readonly WaitForSeconds _waitBannerReload = new WaitForSeconds(5f);
26+
private IEnumerator _reload;
2227
#endif
2328
public override void Init()
2429
{
2530
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
2631
if (AdStatic.IsRemoveAd) return;
27-
bannerAd.OnAdLoaded += BannerOnAdLoadedEvent;
28-
bannerAd.OnAdLoadFailed += BannerOnAdLoadFailedEvent;
29-
bannerAd.OnAdClicked += BannerOnAdClickedEvent;
30-
bannerAd.OnAdDisplayed += BannerOnAdDisplayedEvent;
31-
bannerAd.OnAdDisplayFailed += BannerOnAdDisplayFailedEvent;
32-
bannerAd.OnAdLeftApplication += BannerOnAdLeftApplicationEvent;
32+
_isBannerDestroyed = true;
3333
#endif
3434
}
3535

3636
public override void Load()
3737
{
3838
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
3939
if (AdStatic.IsRemoveAd) return;
40-
if (_isBannerDestroyed)
41-
{
42-
LevelPlayBannerAd.Config.Builder builder = new LevelPlayBannerAd.Config.Builder();
43-
builder.SetPosition(ConvertBannerPosition());
44-
builder.SetSize(ConvertBannerSize());
45-
var config = builder.Build();
46-
bannerAd = new LevelPlayBannerAd(Id, config);
47-
bannerAd.LoadAd();
48-
_isBannerDestroyed = false;
49-
}
40+
Destroy();
41+
LevelPlayBannerAd.Config.Builder builder = new LevelPlayBannerAd.Config.Builder();
42+
builder.SetPosition(ConvertBannerPosition());
43+
builder.SetSize(ConvertBannerSize());
44+
builder.SetDisplayOnLoad(isShowOnLoad);
45+
var config = builder.Build();
46+
bannerAd = new LevelPlayBannerAd(Id, config);
47+
bannerAd.OnAdLoaded += BannerOnAdLoadedEvent;
48+
bannerAd.OnAdLoadFailed += BannerOnAdLoadFailedEvent;
49+
bannerAd.OnAdClicked += BannerOnAdClickedEvent;
50+
bannerAd.OnAdDisplayed += BannerOnAdDisplayedEvent;
51+
bannerAd.OnAdDisplayFailed += BannerOnAdDisplayFailedEvent;
52+
bannerAd.OnAdLeftApplication += BannerOnAdLeftApplicationEvent;
53+
bannerAd.LoadAd();
54+
_isBannerDestroyed = false;
5055
#endif
5156
}
5257

@@ -68,7 +73,7 @@ void OnWaitAppOpenDisplayed()
6873
public override bool IsReady()
6974
{
7075
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
71-
return true;
76+
return bannerAd != null;
7277
#else
7378
return false;
7479
#endif
@@ -142,7 +147,15 @@ void BannerOnAdLoadFailedEvent(LevelPlayAdError ironSourceError)
142147
{
143148
Common.CallActionAndClean(ref failedToLoadCallback);
144149
OnFailedToLoadAdEvent?.Invoke(ironSourceError.ErrorMessage);
145-
Destroy();
150+
if (_reload != null) App.StopCoroutine(_reload);
151+
_reload = DelayBannerReload();
152+
App.StartCoroutine(_reload);
153+
}
154+
155+
private IEnumerator DelayBannerReload()
156+
{
157+
yield return _waitBannerReload;
158+
Load();
146159
}
147160

148161
void BannerOnAdClickedEvent(LevelPlayAdInfo adInfo)

VirtueSky/Advertising/Runtime/LevelPlay/LevelPlayUnitVariable/LevelPlayInterVariable.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ public override void Init()
2020
{
2121
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
2222
if (AdStatic.IsRemoveAd) return;
23-
interstitialAd.OnAdLoaded += InterstitialOnAdLoadedEvent;
24-
interstitialAd.OnAdLoadFailed += InterstitialOnAdLoadFailed;
25-
interstitialAd.OnAdDisplayed += InterstitialOnAdDisplayEvent;
26-
interstitialAd.OnAdClicked += InterstitialOnAdClickedEvent;
27-
interstitialAd.OnAdDisplayFailed += InterstitialOnAdDisplayFailedEvent;
28-
interstitialAd.OnAdClosed += InterstitialOnAdClosedEvent;
2923
#endif
3024
}
3125

@@ -36,6 +30,12 @@ public override void Load()
3630
var configBuilder = new LevelPlayInterstitialAd.Config.Builder();
3731
var config = configBuilder.Build();
3832
interstitialAd = new LevelPlayInterstitialAd(Id, config);
33+
interstitialAd.OnAdLoaded += InterstitialOnAdLoadedEvent;
34+
interstitialAd.OnAdLoadFailed += InterstitialOnAdLoadFailed;
35+
interstitialAd.OnAdDisplayed += InterstitialOnAdDisplayEvent;
36+
interstitialAd.OnAdClicked += InterstitialOnAdClickedEvent;
37+
interstitialAd.OnAdDisplayFailed += InterstitialOnAdDisplayFailedEvent;
38+
interstitialAd.OnAdClosed += InterstitialOnAdClosedEvent;
3939
interstitialAd.LoadAd();
4040
#endif
4141
}
@@ -48,7 +48,7 @@ public override bool IsReady()
4848
return false;
4949
#endif
5050
}
51-
51+
5252
protected override void ShowImpl()
5353
{
5454
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
@@ -95,7 +95,7 @@ void InterstitialOnAdClickedEvent(LevelPlayAdInfo adInfo)
9595
Common.CallActionAndClean(ref clickedCallback);
9696
OnClickedAdEvent?.Invoke();
9797
}
98-
98+
9999
void InterstitialOnAdDisplayFailedEvent(LevelPlayAdInfo adInfo, LevelPlayAdError adError)
100100
{
101101
Common.CallActionAndClean(ref failedToDisplayCallback);

VirtueSky/Advertising/Runtime/LevelPlay/LevelPlayUnitVariable/LevelPlayRewardVariable.cs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ public override void Init()
2121
{
2222
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
2323
if (AdStatic.IsRemoveAd) return;
24-
rewardedAd.OnAdLoaded += OnAdLoaded;
25-
rewardedAd.OnAdDisplayed += RewardedVideoOnAdDisplayedEvent;
26-
rewardedAd.OnAdClosed += RewardedVideoOnAdClosedEvent;
27-
rewardedAd.OnAdDisplayFailed += RewardedVideoOnAdDisplayFailedEvent;
28-
rewardedAd.OnAdRewarded += RewardedVideoOnAdRewardedEvent;
29-
rewardedAd.OnAdClicked += RewardedVideoOnAdClickedEvent;
30-
rewardedAd.OnAdLoadFailed += RewardedVideoOnAdLoadFailedEvent;
3124
#endif
3225
}
3326

@@ -39,13 +32,21 @@ public override void Load()
3932
var configBuilder = new LevelPlayRewardedAd.Config.Builder();
4033
var config = configBuilder.Build();
4134
rewardedAd = new LevelPlayRewardedAd(Id, config);
35+
rewardedAd.OnAdLoaded += OnAdLoaded;
36+
rewardedAd.OnAdDisplayed += RewardedVideoOnAdDisplayedEvent;
37+
rewardedAd.OnAdClosed += RewardedVideoOnAdClosedEvent;
38+
rewardedAd.OnAdDisplayFailed += RewardedVideoOnAdDisplayFailedEvent;
39+
rewardedAd.OnAdRewarded += RewardedVideoOnAdRewardedEvent;
40+
rewardedAd.OnAdClicked += RewardedVideoOnAdClickedEvent;
41+
rewardedAd.OnAdLoadFailed += RewardedVideoOnAdLoadFailedEvent;
42+
rewardedAd.LoadAd();
4243
#endif
4344
}
4445

4546
public override bool IsReady()
4647
{
4748
#if VIRTUESKY_ADS && VIRTUESKY_LEVELPLAY
48-
return rewardedAd.IsAdReady();
49+
return rewardedAd != null && rewardedAd.IsAdReady();
4950
#else
5051
return false;
5152
#endif

VirtueSky/AssetFinder/Editor/Script/Modules/AssetFinderExport.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static void ExportCSV(AssetFinderRef[] csvSource)
3434
}
3535

3636
#if AssetFinderDEV
37-
[MenuItem("Assets/FR2/Debug details", false, 19)]
37+
[MenuItem("Assets/AssetFinder/Debug details", false, 19)]
3838
private static void DebugDetails()
3939
{
4040
var s = Selection.activeObject;
@@ -59,12 +59,12 @@ private static void DebugDetails()
5959
}
6060
#endif
6161

62-
[MenuItem("Assets/FR2/Toggle Ignore", false, 19)]
62+
[MenuItem("Assets/AssetFinder/Toggle Ignore", false, 19)]
6363
private static void Ignore()
6464
{
6565
if (!AssetFinderCache.isReady)
6666
{
67-
AssetFinderLOG.LogWarning("FR2 cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
67+
AssetFinderLOG.LogWarning("AssetFinder cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
6868
return;
6969
}
7070

@@ -84,27 +84,27 @@ private static void Ignore()
8484
}
8585
}
8686

87-
[MenuItem("Assets/FR2/Copy GUID", false, 20)]
87+
[MenuItem("Assets/AssetFinder/Copy GUID", false, 20)]
8888
private static void CopyGUID()
8989
{
9090
EditorGUIUtility.systemCopyBuffer = AssetDatabase.AssetPathToGUID(
9191
AssetDatabase.GetAssetPath(Selection.activeObject)
9292
);
9393
}
9494

95-
[MenuItem("Assets/FR2/Export Selection", false, 21)]
95+
[MenuItem("Assets/AssetFinder/Export Selection", false, 21)]
9696
private static void ExportSelection()
9797
{
9898
if (!AssetFinderCache.isReady)
9999
{
100-
AssetFinderLOG.LogWarning("FR2 cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
100+
AssetFinderLOG.LogWarning("AssetFinder cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
101101
return;
102102
}
103103

104104
AssetFinderUnity.ExportSelection();
105105
}
106106

107-
[MenuItem("Assets/FR2/Select Dependencies (assets I use)", false, 22)]
107+
[MenuItem("Assets/AssetFinder/Select Dependencies (assets I use)", false, 22)]
108108
private static void SelectDependencies_wtme()
109109
{
110110
if (!AssetFinderCache.isReady)
@@ -116,7 +116,7 @@ private static void SelectDependencies_wtme()
116116
SelectDependencies(false);
117117
}
118118

119-
[MenuItem("Assets/FR2/Refresh")]
119+
[MenuItem("Assets/AssetFinder/Refresh")]
120120
public static void ForceRefreshSelection()
121121
{
122122
string[] guids = Selection.assetGUIDs;
@@ -145,7 +145,7 @@ public static void ForceRefreshSelection()
145145
AssetFinderCache.Api.Check4Work();
146146
}
147147

148-
[MenuItem("Assets/FR2/Select Dependencies included me", false, 23)]
148+
[MenuItem("Assets/AssetFinder/Select Dependencies included me", false, 23)]
149149
private static void SelectDependencies_wme()
150150
{
151151
if (!AssetFinderCache.isReady)
@@ -157,20 +157,20 @@ private static void SelectDependencies_wme()
157157
SelectDependencies(true);
158158
}
159159

160-
//[MenuItem("Assets/FR2/Select")]
161-
[MenuItem("Assets/FR2/Select Used (assets used me)", false, 24)]
160+
//[MenuItem("Assets/AssetFinder/Select")]
161+
[MenuItem("Assets/AssetFinder/Select Used (assets used me)", false, 24)]
162162
private static void SelectUsed_wtme()
163163
{
164164
if (!AssetFinderCache.isReady)
165165
{
166-
AssetFinderLOG.LogWarning("FR2 cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
166+
AssetFinderLOG.LogWarning("AssetFinder cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
167167
return;
168168
}
169169

170170
SelectUsed(false);
171171
}
172172

173-
[MenuItem("Assets/FR2/Select Used included me", false, 25)]
173+
[MenuItem("Assets/AssetFinder/Select Used included me", false, 25)]
174174
private static void SelectUsed_wme()
175175
{
176176
if (!AssetFinderCache.isReady)
@@ -182,7 +182,7 @@ private static void SelectUsed_wme()
182182
SelectUsed(true);
183183
}
184184

185-
[MenuItem("Assets/FR2/Export Dependencies", false, 40)]
185+
[MenuItem("Assets/AssetFinder/Export Dependencies", false, 40)]
186186
private static void ExportDependencies()
187187
{
188188
if (!AssetFinderCache.isReady)
@@ -198,12 +198,12 @@ private static void ExportDependencies()
198198
AssetFinderUnity.ExportSelection();
199199
}
200200

201-
[MenuItem("Assets/FR2/Export Assets (no scripts)", false, 41)]
201+
[MenuItem("Assets/AssetFinder/Export Assets (no scripts)", false, 41)]
202202
private static void ExportAsset()
203203
{
204204
if (!AssetFinderCache.isReady)
205205
{
206-
AssetFinderLOG.LogWarning("FR2 cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
206+
AssetFinderLOG.LogWarning("AssetFinder cache not yet ready, please open Window > AssetFinderWindow and hit scan project!");
207207
return;
208208
}
209209

@@ -484,7 +484,7 @@ private static void ApplicationUpdate()
484484
}
485485

486486

487-
//[MenuItem("Assets/FR2/Tools/Fix Model Import Material")]
487+
//[MenuItem("Assets/AssetFinder/Tools/Fix Model Import Material")]
488488
//public static void FixModelImportMaterial(){
489489
// if (Selection.activeObject == null) return;
490490
// CreatePrefabReplaceModel((GameObject)Selection.activeObject);

VirtueSky/Component/AnimancerComponent/HandleAnimancerComponent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ public class HandleAnimancerComponent : MonoBehaviour
1616
public bool IsPlaying(ClipTransition clip) => animancerComponent.IsPlaying(clip);
1717

1818
public void PlayAnim(ClipTransition clip, Action _endAnim = null, float _durationFade = .2f,
19-
bool isCheckPlayingClip = true,
20-
FadeMode mode = default)
19+
bool isCheckPlayingClip = true, FadeMode mode = default, object _owner = null)
2120
{
2221
if (isCheckPlayingClip)
2322
{
@@ -36,11 +35,12 @@ void Handle()
3635
var state = animancerComponent.Play(clip, clip.Clip.length * _durationFade, mode);
3736
if (_endAnim != null)
3837
{
39-
state.Events.OnEnd += OnEndAnim;
38+
object owner = _owner ?? animancerComponent;
39+
state.Events(owner).OnEnd += OnEndAnim;
4040

4141
void OnEndAnim()
4242
{
43-
state.Events.OnEnd -= OnEndAnim;
43+
state.Events(owner).OnEnd -= OnEndAnim;
4444
_endAnim?.Invoke();
4545
}
4646
}
@@ -56,7 +56,7 @@ public void PauseClip(ClipTransition clip)
5656
// Freeze all animations on their current frame:
5757
public void PauseAll()
5858
{
59-
animancerComponent.Playable.PauseGraph();
59+
animancerComponent.Graph.PauseGraph();
6060
}
6161

6262
// Stop a single animation from affecting the character and rewind it to the start:

0 commit comments

Comments
 (0)