Skip to content

Commit 3ba3fa1

Browse files
committed
Merge pull request #58 from adjust/wack_fix
WACK fix
2 parents 94e07b1 + 5f465ce commit 3ba3fa1

35 files changed

+310
-103
lines changed

Assets/Adjust/Adjust.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ public class Adjust : MonoBehaviour
1212
private static IAdjust instance = null;
1313
private static Action<AdjustAttribution> attributionChangedDelegate = null;
1414

15-
public bool startManually = false;
15+
public bool startManually = true;
1616
public bool eventBuffering = false;
17-
public bool printAttribution = false;
17+
public bool printAttribution = true;
1818

1919
public string appToken = "{Your App Token}";
2020

@@ -25,6 +25,10 @@ public class Adjust : MonoBehaviour
2525

2626
void Awake ()
2727
{
28+
if (Adjust.instance != null) {
29+
return;
30+
}
31+
2832
DontDestroyOnLoad (transform.gameObject);
2933

3034
if (!this.startManually) {

Assets/Adjust/AdjustUnityWP.dll

0 Bytes
Binary file not shown.

Assets/Adjust/AdjustUnityWS.dll

0 Bytes
Binary file not shown.

Assets/Adjust/Android/AdjustAndroid.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace com.adjust.sdk
1010
#if UNITY_ANDROID
1111
public class AdjustAndroid : IAdjust
1212
{
13-
private const string sdkPrefix = "unity4.1.0";
13+
private const string sdkPrefix = "unity4.1.1";
1414
private AndroidJavaClass ajcAdjust;
1515
private AndroidJavaObject ajoCurrentActivity;
1616
private AttributionChangeListener onAttributionChangedListener;
1 Byte
Binary file not shown.

Assets/Adjust/Android/adjust-android.jar.meta

-23
This file was deleted.

Assets/Adjust/Metro/AdjustMetro.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace com.adjust.sdk
99
{
1010
public class AdjustMetro : IAdjust
1111
{
12-
private const string sdkPrefix = "unity4.1.0";
12+
private const string sdkPrefix = "unity4.1.1";
1313

1414
public bool isEnabled()
1515
{
@@ -52,7 +52,8 @@ public void start(AdjustConfig adjustConfig)
5252
defaultTracker: adjustConfig.defaultTracker,
5353
eventBufferingEnabled: adjustConfig.eventBufferingEnabled,
5454
sdkPrefix: sdkPrefix,
55-
attributionChangedDic: attributionChangedDictionary
55+
attributionChangedDic: attributionChangedDictionary,
56+
logDelegate: adjustConfig.logDelegate
5657
);
5758
}
5859
public void trackEvent (AdjustEvent adjustEvent)

Assets/Adjust/Metro/AdjustUnityWS.dll

-512 Bytes
Binary file not shown.

Assets/Adjust/Metro/AdjustWS.dll

-512 Bytes
Binary file not shown.

Assets/Adjust/Metro/WindowsPcl.dll

-6 KB
Binary file not shown.
0 Bytes
Binary file not shown.

Assets/Adjust/Metro/WindowsUap.dll

-512 Bytes
Binary file not shown.

Assets/Adjust/Unity/AdjustConfig.cs

+9-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ public class AdjustConfig
2020
// Android specific members
2121
internal string processName;
2222

23-
public AdjustConfig (string appToken, AdjustEnvironment environment)
23+
// Windows specific members
24+
internal Action<String> logDelegate;
25+
26+
public AdjustConfig (string appToken, AdjustEnvironment environment)
2427
{
2528
this.sceneName = "";
2629
this.appToken = appToken;
@@ -66,5 +69,10 @@ public void setProcessName (string processName)
6669
{
6770
this.processName = processName;
6871
}
72+
73+
public void setLogDelegate(Action<String> logDelegate)
74+
{
75+
this.logDelegate = logDelegate;
76+
}
6977
}
7078
}

Assets/Adjust/WP8/AdjustUnityWP.dll

0 Bytes
Binary file not shown.

Assets/Adjust/WP8/AdjustWP8.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace com.adjust.sdk
99
{
1010
public class AdjustWP8 : IAdjust
1111
{
12-
private const string sdkPrefix = "unity4.1.0";
12+
private const string sdkPrefix = "unity4.1.1";
1313

1414
public bool isEnabled()
1515
{
@@ -52,7 +52,8 @@ public void start(AdjustConfig adjustConfig)
5252
defaultTracker: adjustConfig.defaultTracker,
5353
eventBufferingEnabled: adjustConfig.eventBufferingEnabled,
5454
sdkPrefix: sdkPrefix,
55-
attributionChangedDic: attributionChangedDictionary
55+
attributionChangedDic: attributionChangedDictionary,
56+
logDelegate: adjustConfig.logDelegate
5657
);
5758
}
5859
public void trackEvent (AdjustEvent adjustEvent)

Assets/Adjust/WP8/AdjustWP80.dll

-512 Bytes
Binary file not shown.

Assets/Adjust/WP8/WindowsPcl.dll

-6 KB
Binary file not shown.

Assets/Adjust/WP8/WindowsPclNet40.dll

0 Bytes
Binary file not shown.

Assets/Adjust/iOS/Adjust.a

0 Bytes
Binary file not shown.

Assets/Adjust/iOS/AdjustiOS.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace com.adjust.sdk
1010
#if UNITY_IOS
1111
public class AdjustiOS : IAdjust
1212
{
13-
private const string sdkPrefix = "unity4.1.0";
13+
private const string sdkPrefix = "unity4.1.1";
1414

1515
#region External methods
1616

Assets/Editor/AdjustEditor.cs

+61-33
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
using System.Collections;
1+
using System;
2+
using System.IO;
3+
using System.Collections;
24
using System.Diagnostics;
5+
using System.Text.RegularExpressions;
36

47
using UnityEngine;
58
using UnityEditor;
69
using UnityEditor.Callbacks;
710

811
public class AdjustEditor : MonoBehaviour
912
{
10-
static string iOSBuildPath = "";
1113
static bool isEnabled = true;
12-
static bool isAdjusted = false;
14+
static string iOSBuildPath = "";
1315

1416
[PostProcessBuild]
1517
public static void OnPostprocessBuild (BuildTarget target, string pathToBuiltProject)
@@ -31,84 +33,110 @@ public static void OnPostprocessBuild (BuildTarget target, string pathToBuiltPro
3133
}
3234
}
3335

34-
[MenuItem("Assets/Adjust/Fix AndroidManifest.xml")]
36+
[MenuItem ("Assets/Adjust/Fix AndroidManifest.xml")]
3537
static void FixAndroidManifest ()
3638
{
3739
#if UNITY_ANDROID
3840
var exitCode = RunPostBuildScript (preBuild: true);
3941

4042
if (exitCode == 1) {
4143
EditorUtility.DisplayDialog("Adjust",
42-
string.Format("AndroidManifest.xml changed or created at {0}/Plugins/Android/ .",Application.dataPath),
44+
string.Format("AndroidManifest.xml changed or created at {0}/Plugins/Android/ .", Application.dataPath),
4345
"OK");
4446
} else if (exitCode == 0) {
45-
EditorUtility.DisplayDialog("Adjust",
46-
"AndroidManifest.xml did not needed to be changed.",
47-
"OK");
47+
EditorUtility.DisplayDialog("Adjust", "AndroidManifest.xml did not needed to be changed.", "OK");
4848
} else {
49-
EditorUtility.DisplayDialog("Adjust",
50-
GenerateErrorScriptMessage(exitCode),
51-
"OK");
49+
EditorUtility.DisplayDialog("Adjust", GenerateErrorScriptMessage(exitCode), "OK");
5250

5351
}
5452
#else
5553
EditorUtility.DisplayDialog ("Adjust", "Option only valid for the Android platform.", "OK");
5654
#endif
5755
}
5856

59-
[MenuItem("Assets/Adjust/Set iOS build path")]
57+
[MenuItem ("Assets/Adjust/Set iOS build path")]
6058
static void SetiOSBuildPath ()
6159
{
6260
#if UNITY_IOS
63-
AdjustEditor.iOSBuildPath = EditorUtility.OpenFolderPanel(
61+
AdjustEditor.iOSBuildPath = EditorUtility.OpenFolderPanel (
6462
title: "iOs build path",
65-
folder: EditorUserBuildSettings.GetBuildLocation(BuildTarget.iOS),
63+
folder: EditorUserBuildSettings.GetBuildLocation (BuildTarget.iOS),
6664
defaultName: "");
6765

6866
if (AdjustEditor.iOSBuildPath == "") {
69-
UnityEngine.Debug.Log("iOS build path reset to default path");
67+
UnityEngine.Debug.Log ("iOS build path reset to default path");
7068
} else {
71-
UnityEngine.Debug.Log(string.Format("iOS build path: {0}", AdjustEditor.iOSBuildPath));
69+
UnityEngine.Debug.Log (string.Format ("iOS build path: {0}", AdjustEditor.iOSBuildPath));
7270
}
7371
#else
7472
EditorUtility.DisplayDialog ("Adjust", "Option only valid for the Android platform.", "OK");
7573
#endif
7674
}
7775

78-
[MenuItem("Assets/Adjust/Change post processing status")]
76+
[MenuItem ("Assets/Adjust/Change post processing status")]
7977
static void ChangePostProcessingStatus ()
8078
{
8179
isEnabled = !isEnabled;
8280

83-
EditorUtility.DisplayDialog ("Adjust",
84-
"The post processing for adjust is now " +
85-
(isEnabled ? "enabled." : "disabled."),
86-
"OK");
81+
EditorUtility.DisplayDialog ("Adjust", "The post processing for adjust is now " +
82+
(isEnabled ? "enabled." : "disabled."), "OK");
8783
}
8884

8985
static int RunPostBuildScript (bool preBuild, string pathToBuiltProject = "")
9086
{
91-
string pathToScript = null;
87+
string resultContent;
9288
string arguments = null;
89+
string pathToScript = null;
9390

94-
#if UNITY_ANDROID
91+
string filePath = System.IO.Path.Combine (Environment.CurrentDirectory,
92+
@"Assets/Editor/PostprocessBuildPlayer_AdjustPostBuildiOS.py");
93+
94+
// Check if Unity is running on Windows operating system.
95+
// If yes - fix line endings in python scripts.
96+
if (Application.platform == RuntimePlatform.WindowsEditor) {
97+
UnityEngine.Debug.Log ("Windows platform");
98+
99+
using (System.IO.StreamReader streamReader = new System.IO.StreamReader (filePath)) {
100+
string fileContent = streamReader.ReadToEnd ();
101+
resultContent = Regex.Replace (fileContent, @"\r\n|\n\r|\n|\r", "\r\n");
102+
}
103+
104+
if (File.Exists (filePath)) {
105+
File.WriteAllText (filePath, resultContent);
106+
}
107+
} else {
108+
UnityEngine.Debug.Log ("Unix platform");
109+
110+
using (System.IO.StreamReader streamReader = new System.IO.StreamReader (filePath)) {
111+
string replaceWith = "\n";
112+
string fileContent = streamReader.ReadToEnd ();
113+
114+
resultContent = fileContent.Replace ("\r\n", replaceWith);
115+
}
116+
117+
if (File.Exists (filePath)) {
118+
File.WriteAllText (filePath, resultContent);
119+
}
120+
}
121+
122+
#if UNITY_ANDROID
95123
pathToScript = "/Editor/PostprocessBuildPlayer_AdjustPostBuildAndroid.py";
96124
arguments = "\"" + Application.dataPath + "\"";
97125

98126
if (preBuild) {
99127
arguments = "--pre-build " + arguments;
100128
}
101-
#elif UNITY_IOS
129+
#elif UNITY_IOS
102130
pathToScript = "/Editor/PostprocessBuildPlayer_AdjustPostBuildiOS.py";
103131

104132
if (AdjustEditor.iOSBuildPath == "") {
105133
arguments = "\"" + pathToBuiltProject + "\"";
106134
} else {
107135
arguments = "\"" + AdjustEditor.iOSBuildPath + "\"";
108136
}
109-
#else
137+
#else
110138
return -1;
111-
#endif
139+
#endif
112140

113141
Process proc = new Process ();
114142
proc.EnableRaisingEvents = false;
@@ -122,26 +150,26 @@ static int RunPostBuildScript (bool preBuild, string pathToBuiltProject = "")
122150

123151
static string GenerateErrorScriptMessage (int exitCode)
124152
{
125-
#if UNITY_ANDROID
153+
#if UNITY_ANDROID
126154
if (exitCode == 1) {
127155
return "The AndroidManifest.xml file was only changed or created after building the package. " +
128156
"PLease build again the Android Unity package so it can use the new file";
129157
}
130-
#endif
158+
#endif
131159

132160
if (exitCode != 0) {
133161
var message = "Build script exited with error." +
134-
" Please check the Adjust log file for more information at {0}";
162+
" Please check the Adjust log file for more information at {0}";
135163
string projectPath = Application.dataPath.Substring (0, Application.dataPath.Length - 7);
136164
string logFile = null;
137165

138-
#if UNITY_ANDROID
166+
#if UNITY_ANDROID
139167
logFile = projectPath + "/AdjustPostBuildAndroidLog.txt";
140-
#elif UNITY_IOS
168+
#elif UNITY_IOS
141169
logFile = projectPath + "/AdjustPostBuildiOSLog.txt";
142-
#else
170+
#else
143171
return null;
144-
#endif
172+
#endif
145173
return string.Format (message, logFile);
146174
}
147175

Assets/Editor/PostprocessBuildPlayer_AdjustPostBuildAndroid.py

100644100755
File mode changed.

Assets/Editor/PostprocessBuildPlayer_AdjustPostBuildAndroid.py.meta

-8
This file was deleted.

Assets/Editor/PostprocessBuildPlayer_AdjustPostBuildiOS.py

100644100755
File mode changed.

Assets/Editor/PostprocessBuildPlayer_AdjustPostBuildiOS.py.meta

-8
This file was deleted.

0 commit comments

Comments
 (0)