Skip to content

Commit 73757c5

Browse files
author
Uglješa Erceg
committed
Merge pull request #40 from adjust/unity_upgrade
Unity upgrade
2 parents 69c9fbb + 7e2209f commit 73757c5

File tree

231 files changed

+1743
-5142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+1743
-5142
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,8 @@ ProjectSettings/
157157
# ==================== #
158158
Assembly-CSharp*
159159
unity_sdk*.sln
160+
161+
# ==================== #
162+
# Exceptions
163+
# ==================== #
164+
!google-play-services_lib/AndroidManifest.xml

.gitmodules

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
[submodule "Assets/Plugins/iOS/src/Adjust"]
2-
path = Assets/Plugins/iOS/src/Adjust
3-
url = [email protected]:adjust/ios_sdk.git
4-
[submodule "Assets/Plugins/Android/src/Adjust"]
5-
path = Assets/Plugins/Android/src/Adjust
1+
[submodule "ext/Android/sdk"]
2+
path = ext/Android/sdk
63
url = [email protected]:adjust/android_sdk.git
4+
[submodule "ext/iOS/sdk"]
5+
path = ext/iOS/sdk
6+
url = [email protected]:adjust/ios_sdk.git

Adjust_v3.4.4.unitypackage

-848 KB
Binary file not shown.

Assets/Adjust.cs

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

Assets/Adjust.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Adjust.prefab

-5.8 KB
Binary file not shown.

Assets/Adjust/3rd Party.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
File renamed without changes.

Assets/Plugins/SimpleJSON.cs.meta renamed to Assets/Adjust/3rd Party/SimpleJSON.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Adjust/Adjust.cs

Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
using UnityEngine;
5+
6+
namespace com.adjust.sdk
7+
{
8+
public class Adjust : MonoBehaviour
9+
{
10+
private const string sdkPrefix = "unity4.0.0";
11+
private const string errorMessage = "adjust: SDK not started. Start it manually using the 'appDidLaunch' method.";
12+
13+
private static IAdjust instance = null;
14+
private static Action<AdjustAttribution> attributionChangedDelegate = null;
15+
16+
public bool startManually = false;
17+
public bool eventBuffering = false;
18+
public bool printAttribution = false;
19+
20+
public string appToken = "{Your App Token}";
21+
22+
public AdjustLogLevel logLevel = AdjustLogLevel.Info;
23+
public AdjustEnvironment environment = AdjustEnvironment.Sandbox;
24+
25+
#region Unity lifecycle methods
26+
27+
void Awake ()
28+
{
29+
if (!this.startManually) {
30+
AdjustConfig adjustConfig = new AdjustConfig (this.appToken, this.environment);
31+
adjustConfig.setLogLevel (this.logLevel);
32+
adjustConfig.setEventBufferingEnabled (eventBuffering);
33+
34+
if (printAttribution) {
35+
adjustConfig.setAttributionChangedDelegate(responseDelegate);
36+
}
37+
38+
Adjust.start (adjustConfig);
39+
}
40+
}
41+
42+
void OnApplicationPause(bool pauseStatus) {
43+
if (Adjust.instance == null) {
44+
return;
45+
}
46+
47+
if (pauseStatus) {
48+
Adjust.instance.onPause();
49+
} else {
50+
Adjust.instance.onResume();
51+
}
52+
}
53+
54+
#endregion
55+
56+
#region Adjust methods
57+
58+
public static void start (AdjustConfig adjustConfig)
59+
{
60+
if (Adjust.instance != null) {
61+
Debug.Log ("adjust: Error, SDK already started.");
62+
return;
63+
}
64+
65+
if (adjustConfig == null) {
66+
Debug.Log ("adjust: Missing config to start.");
67+
return;
68+
}
69+
70+
#if UNITY_EDITOR
71+
Adjust.instance = null;
72+
#elif UNITY_IOS
73+
Adjust.instance = new AdjustiOS();
74+
#elif UNITY_ANDROID
75+
Adjust.instance = new AdjustAndroid();
76+
#else
77+
Adjust.instance = null;
78+
#endif
79+
80+
if (Adjust.instance == null) {
81+
Debug.Log ("adjust: SDK can only be used in Android, iOS, Windows Phone 8 or Windows Store apps.");
82+
return;
83+
}
84+
85+
adjustConfig.setSdkPrefix(Adjust.sdkPrefix);
86+
Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate ();
87+
88+
Adjust.instance.start (adjustConfig);
89+
}
90+
91+
public static void trackEvent (AdjustEvent adjustEvent)
92+
{
93+
if (Adjust.instance == null) {
94+
Debug.Log (Adjust.errorMessage);
95+
return;
96+
}
97+
98+
if (adjustEvent == null) {
99+
Debug.Log ("adjust: Missing event to track.");
100+
return;
101+
}
102+
103+
Adjust.instance.trackEvent (adjustEvent);
104+
}
105+
106+
public static void setEnabled(bool enabled) {
107+
if (Adjust.instance == null) {
108+
Debug.Log(Adjust.errorMessage);
109+
return;
110+
}
111+
112+
Adjust.instance.setEnabled(enabled);
113+
}
114+
115+
public static bool isEnabled() {
116+
if (Adjust.instance == null) {
117+
Debug.Log(Adjust.errorMessage);
118+
return false;
119+
}
120+
121+
return Adjust.instance.isEnabled();
122+
}
123+
124+
public static void setOfflineMode(bool enabled) {
125+
if (Adjust.instance == null) {
126+
Debug.Log(Adjust.errorMessage);
127+
return;
128+
}
129+
130+
Adjust.instance.setOfflineMode(enabled);
131+
}
132+
133+
#endregion
134+
135+
#region Attribution callback
136+
137+
public void getNativeMessage (string sAttributionData)
138+
{
139+
Adjust.runAttributionChangedDelegate (sAttributionData);
140+
}
141+
142+
public static void runAttributionChangedDelegate (string stringAttributionData)
143+
{
144+
if (instance == null) {
145+
Debug.Log (Adjust.errorMessage);
146+
return;
147+
}
148+
if (Adjust.attributionChangedDelegate == null) {
149+
Debug.Log ("adjust: Attribution changed delegate was not set.");
150+
return;
151+
}
152+
153+
var attribution = new AdjustAttribution (stringAttributionData);
154+
Adjust.attributionChangedDelegate (attribution);
155+
}
156+
157+
#endregion
158+
159+
#region Private & helper methods
160+
161+
// Our delegate for detecting attribution changes if choosen not to start manually.
162+
private void responseDelegate(AdjustAttribution responseData)
163+
{
164+
Debug.Log ("Attribution changed!");
165+
166+
if (responseData.trackerName != null) {
167+
Debug.Log ("trackerName " + responseData.trackerName);
168+
}
169+
170+
if (responseData.trackerToken != null) {
171+
Debug.Log ("trackerToken " + responseData.trackerToken);
172+
}
173+
174+
if (responseData.network != null) {
175+
Debug.Log ("network " + responseData.network);
176+
}
177+
178+
if (responseData.campaign != null) {
179+
Debug.Log ("campaign " + responseData.campaign);
180+
}
181+
182+
if (responseData.adgroup != null) {
183+
Debug.Log ("adgroup " + responseData.adgroup);
184+
}
185+
186+
if (responseData.creative != null) {
187+
Debug.Log ("creative " + responseData.creative);
188+
}
189+
}
190+
191+
#endregion
192+
}
193+
}

Assets/Adjust.cs.meta renamed to Assets/Adjust/Adjust.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Adjust/Adjust.prefab

4.37 KB
Binary file not shown.

Assets/Adjust.prefab.meta renamed to Assets/Adjust/Adjust.prefab.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Adjust/Android.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)