Skip to content

Commit

Permalink
Merge pull request #10 from VirtueSky/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VirtueSky authored Aug 13, 2024
2 parents 41b5e31 + c436d14 commit 8bee642
Show file tree
Hide file tree
Showing 18 changed files with 240 additions and 18 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
### 1: Download the repo and drop it into folder `Assets`
### 2: Add the line below to `Packages/manifest.json`

for version `2.9.4`
for version `2.9.5`
```csharp
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#2.9.4",
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#2.9.5",
```

## Includes modules
Expand Down
45 changes: 45 additions & 0 deletions VirtueSky/ControlPanel/CPAdjustDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
using UnityEditor;
using UnityEngine;
using VirtueSky.Tracking;
using VirtueSky.UtilsEditor;

namespace VirtueSky.ControlPanel.Editor
{
public class CPAdjustDrawer
{
private static AdjustSetting _setting;
private static UnityEditor.Editor _editor;

public static void OnEnable()
{
Init();
}

private static void Init()
{
if (_editor != null) _editor = null;
_setting = CreateAsset.GetScriptableAsset<AdjustSetting>();
_editor = UnityEditor.Editor.CreateEditor(_setting);
}


public static void OnDrawAdjust()
{
GUILayout.Space(10);
Expand All @@ -25,6 +42,34 @@ public static void OnDrawAdjust()
GUILayout.Space(10);
GUILayout.Label("ADD DEFINE SYMBOLS", EditorStyles.boldLabel);
CPUtility.DrawButtonAddDefineSymbols(ConstantDefineSymbols.VIRTUESKY_ADJUST);
GUILayout.Space(10);
CPUtility.GuiLine(2);
GUILayout.Label("ADJUST SETTINGS", EditorStyles.boldLabel);
GUILayout.Space(10);
if (_setting == null)
{
if (GUILayout.Button("Create AdjustSettings"))
{
_setting =
CreateAsset.CreateAndGetScriptableAsset<AdjustSetting>("/AdjustTracking/Resources",
isPingAsset: false);
Init();
}
}
else
{
if (_editor == null)
{
EditorGUILayout.HelpBox("Couldn't create the settings editor.",
MessageType.Error);
return;
}
else
{
_editor.OnInspectorGUI();
}
}

GUILayout.Space(10);
CPUtility.GuiLine(2);
GUILayout.Space(10);
Expand Down
2 changes: 0 additions & 2 deletions VirtueSky/ControlPanel/CPAdvertisingDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace VirtueSky.ControlPanel.Editor
{
public class CPAdvertisingDrawer
{
private static bool isFieldMax = false;
private static bool isFielAdmob = false;
private static Vector2 _scrollPosition;
private static UnityEditor.Editor _editor;
private static AdSetting _adSetting;
Expand Down
48 changes: 47 additions & 1 deletion VirtueSky/ControlPanel/CPAppsFlyerDrawer.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
using UnityEditor;
using UnityEngine;
using VirtueSky.Tracking;
using VirtueSky.UtilsEditor;

namespace VirtueSky.ControlPanel.Editor
{
public class CPAppsFlyerDrawer
{
private static AppsFlyerSetting _setting;
private static UnityEditor.Editor _editor;

public static void OnEnable()
{
Init();
}

private static void Init()
{
if (_editor != null) _editor = null;
_setting = CreateAsset.GetScriptableAsset<AppsFlyerSetting>();
_editor = UnityEditor.Editor.CreateEditor(_setting);
}

public static void OnDrawAppsFlyer()
{
GUILayout.Space(10);
Expand All @@ -20,7 +36,7 @@ public static void OnDrawAppsFlyer()
CPUtility.GuiLine(2);
GUILayout.Space(10);
#if !VIRTUESKY_APPSFLYER
EditorGUILayout.HelpBox(
EditorGUILayout.HelpBox(
$"Add scripting define symbols: {ConstantDefineSymbols.VIRTUESKY_APPSFLYER} for AppsFlyer to use",
MessageType.Info);
#endif
Expand All @@ -29,7 +45,37 @@ public static void OnDrawAppsFlyer()
CPUtility.DrawButtonAddDefineSymbols(ConstantDefineSymbols.VIRTUESKY_APPSFLYER);
GUILayout.Space(10);
CPUtility.GuiLine(2);
GUILayout.Label("APPSFLYER SETTINGS", EditorStyles.boldLabel);
GUILayout.Space(10);
if (_setting == null)
{
if (GUILayout.Button("Create AppsFlyerSettings"))
{
_setting =
CreateAsset.CreateAndGetScriptableAsset<AppsFlyerSetting>("/AppsFlyerTracking/Resources",
isPingAsset: false);
Init();
}
}
else
{
if (_editor == null)
{
EditorGUILayout.HelpBox("Couldn't create the settings editor.",
MessageType.Error);
return;
}
else
{
EditorGUILayout.HelpBox(
"Set your devKey and appID to init the AppsFlyer SDK and start tracking. You must modify these fields and provide:\ndevKey - Your application devKey provided by AppsFlyer.\nappId - For iOS only. Your iTunes Application ID.\nUWP app id - For UWP only. Your application app id \nMac OS app id - For MacOS app only.",
MessageType.Info);
_editor.OnInspectorGUI();
}
}

GUILayout.Space(10);
CPUtility.GuiLine(2);
GUILayout.Label("APPSFLYER TRACKING", EditorStyles.boldLabel);
GUILayout.Space(10);

Expand Down
5 changes: 1 addition & 4 deletions VirtueSky/ControlPanel/CPRegisterPackageDrawer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ namespace VirtueSky.ControlPanel.Editor
public static class CPRegisterPackageDrawer
{
private static Vector2 scrollPositionFileManifest = Vector2.zero;
private static Vector2 scrollPositionAddPackage = Vector2.zero;
private static Vector2 scrollPositionRemovePackage = Vector2.zero;
private static Vector2 scrollPositionAddSomePackage = Vector2.zero;
private static bool isShowAddPackage = false;
private static bool isShowRemovePackage = false;


public static void OnDrawRegisterPackageByManifest(Rect position)
{
Expand Down
2 changes: 1 addition & 1 deletion VirtueSky/ControlPanel/ConstantPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class ConstantPackage
{
public const string VersionSunflower = "2.9.4";
public const string VersionSunflower = "2.9.5";
public const string PackageNameInAppPurchase = "com.unity.purchasing";
public const string MaxVersionInAppPurchase = "4.12.2";
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
Expand Down
6 changes: 2 additions & 4 deletions VirtueSky/ControlPanel/ControlPanelWindowEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ namespace VirtueSky.ControlPanel.Editor
public class ControlPanelWindowEditor : EditorWindow
{
private StatePanelControl statePanelControl;
private bool isFieldMax = false;
private bool isFielAdmob = false;
private string inputPackageFullNameAdd = "";
private string inputPackageFullNameRemove = "";
private Vector2 scrollButton = Vector2.zero;

[MenuItem("Sunflower/Control Panel &1", false, priority = 1)]
Expand All @@ -37,6 +33,8 @@ private void OnEnable()
CPIapDrawer.OnEnable();
CPLevelEditorDrawer.OnEnable();
CPFolderIconDrawer.OnEnable();
CPAdjustDrawer.OnEnable();
CPAppsFlyerDrawer.OnEnable();
}

private void OnDisable()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"GUID:fca7ec166e04dc948b624a983315e2c9",
"GUID:2ba9ab3e4292d6e4b81f0022dc854eee",
"GUID:ade1d0a32a74d554ab9bf506427a1b1b",
"GUID:877be62fd20bbdb489dd86ee21cee87d"
"GUID:877be62fd20bbdb489dd86ee21cee87d",
"GUID:5e9107a8f2499184ea26564811dda246"
],
"includePlatforms": [
"Editor"
Expand Down
24 changes: 24 additions & 0 deletions VirtueSky/Tracking/Runtime/AdjustTracking/AdjustSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#if VIRTUESKY_ADJUST
using com.adjust.sdk;
#endif
using UnityEngine;
using VirtueSky.Inspector;
using VirtueSky.Utils;

namespace VirtueSky.Tracking
{
[EditorIcon("icon_scriptable"), HideMonoScript]
public class AdjustSetting : ScriptableSettings<AdjustSetting>
{
[SerializeField] private string appToken;
#if VIRTUESKY_ADJUST
[SerializeField] private AdjustEnvironment adjustEnvironment = AdjustEnvironment.Production;
[SerializeField] private AdjustLogLevel logLevel = AdjustLogLevel.Error;
#endif
public static string AppToken => Instance.appToken;
#if VIRTUESKY_ADJUST
public static AdjustEnvironment AdjustEnvironment => Instance.adjustEnvironment;
public static AdjustLogLevel LogLevel => Instance.logLevel;
#endif
}
}
11 changes: 11 additions & 0 deletions VirtueSky/Tracking/Runtime/AdjustTracking/AdjustSetting.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions VirtueSky/Tracking/Runtime/AppTracking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ public static void FirebaseAnalyticTrackATTResult(int status)
{
#if VIRTUESKY_FIREBASE_ANALYTIC
FirebaseAnalytics.LogEvent("app_tracking_transparency", "status", status);
#endif
}

public static void StartTrackingAdjust()
{
#if VIRTUESKY_ADJUST
var adjust = new UnityEngine.GameObject("Adjust", typeof(com.adjust.sdk.Adjust));
com.adjust.sdk.Adjust.StartTracking(AdjustSetting.AppToken, AdjustSetting.AdjustEnvironment,
AdjustSetting.LogLevel);
#endif
}

public static void StartTrackingAppsFlyer()
{
#if VIRTUESKY_APPSFLYER
var appFlyerObject =
new UnityEngine.GameObject("AppsFlyerObject", typeof(VirtueSky.Tracking.AppsFlyerObject));
#endif
}
}
Expand Down
42 changes: 42 additions & 0 deletions VirtueSky/Tracking/Runtime/AppsFlyerTracking/AppsFlyerObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if VIRTUESKY_APPSFLYER
using AppsFlyerSDK;
#endif

using System;
using UnityEngine;

namespace VirtueSky.Tracking
{
public class AppsFlyerObject : MonoBehaviour
{
private void Awake()
{
#if !UNITY_EDITOR
DontDestroyOnLoad(this);
#endif
}

private void Start()
{
#if VIRTUESKY_APPSFLYER
// These fields are set from the editor so do not modify!
//******************************//
AppsFlyer.setIsDebug(AppsFlyerSetting.IsDebug);
#if UNITY_WSA_10_0 && !UNITY_EDITOR
AppsFlyer.initSDK(AppsFlyerSetting.DevKey, AppsFlyerSetting.UWPAppID,
AppsFlyerSetting.GetConversionData ? this : null);
#elif UNITY_STANDALONE_OSX && !UNITY_EDITOR
AppsFlyer.initSDK(AppsFlyerSetting.DevKey, AppsFlyerSetting.MacOSAppID,
AppsFlyerSetting.GetConversionData ? this : null);
#else

AppsFlyer.initSDK(AppsFlyerSetting.DevKey, AppsFlyerSetting.AppID,
AppsFlyerSetting.GetConversionData ? this : null);
#endif
//******************************/

AppsFlyer.startSDK();
#endif
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions VirtueSky/Tracking/Runtime/AppsFlyerTracking/AppsFlyerSetting.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using UnityEngine;
using VirtueSky.Inspector;
using VirtueSky.Utils;

namespace VirtueSky.Tracking
{
[EditorIcon("icon_scriptable"), HideMonoScript]
public class AppsFlyerSetting : ScriptableSettings<AppsFlyerSetting>
{
[SerializeField] private string devKey;
[SerializeField] private string appID;
[SerializeField] private string uwpAppID;
[SerializeField] private string macOSAppID;
[SerializeField] private bool getConversionData;
[SerializeField] private bool isDebug;


public static string DevKey => Instance.devKey;
public static string AppID => Instance.appID;
public static string UWPAppID => Instance.uwpAppID;
public static string MacOSAppID => Instance.macOSAppID;
public static bool IsDebug => Instance.isDebug;
public static bool GetConversionData => Instance.getConversionData;
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"AppsFlyer",
"AppsFlyerAdRevenue",
"UnityEngine.Purchasing",
"Virtuesky.Sunflower.Misc"
"Virtuesky.Sunflower.Misc",
"Virtuesky.Sunflower.Utils"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
5 changes: 4 additions & 1 deletion VirtueSky/Utils/Runtime/ScriptableSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ public static T Instance
if (instance != null) return instance;

instance = Resources.Load<T>(typeof(T).Name);
if (instance == null) throw new Exception($"Scriptable setting for {typeof(T)} must be create before run!");
if (instance == null)
throw new Exception($"Scriptable setting for {typeof(T)} must be create before run!");
return instance;
}
}

public static bool IsExist() => Resources.Load<T>(typeof(T).Name) != null;
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "com.virtuesky.sunflower",
"displayName": "Sunflower",
"description": "Core ScriptableObject Architecture for building Unity games",
"version": "2.9.4",
"version": "2.9.5",
"unity": "2022.3",
"category": "virtuesky",
"license": "MIT",
Expand Down

0 comments on commit 8bee642

Please sign in to comment.