Skip to content

Commit

Permalink
Merge pull request #40 from adjust/unity_upgrade
Browse files Browse the repository at this point in the history
Unity upgrade
  • Loading branch information
Uglješa Erceg committed Jun 9, 2015
2 parents 69c9fbb + 7e2209f commit 73757c5
Show file tree
Hide file tree
Showing 231 changed files with 1,743 additions and 5,142 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,8 @@ ProjectSettings/
# ==================== #
Assembly-CSharp*
unity_sdk*.sln

# ==================== #
# Exceptions
# ==================== #
!google-play-services_lib/AndroidManifest.xml
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[submodule "Assets/Plugins/iOS/src/Adjust"]
path = Assets/Plugins/iOS/src/Adjust
url = [email protected]:adjust/ios_sdk.git
[submodule "Assets/Plugins/Android/src/Adjust"]
path = Assets/Plugins/Android/src/Adjust
[submodule "ext/Android/sdk"]
path = ext/Android/sdk
url = [email protected]:adjust/android_sdk.git
[submodule "ext/iOS/sdk"]
path = ext/iOS/sdk
url = [email protected]:adjust/ios_sdk.git
Binary file removed Adjust_v3.4.4.unitypackage
Binary file not shown.
125 changes: 0 additions & 125 deletions Assets/Adjust.cs

This file was deleted.

9 changes: 9 additions & 0 deletions Assets/Adjust.meta

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

Binary file removed Assets/Adjust.prefab
Binary file not shown.
9 changes: 9 additions & 0 deletions Assets/Adjust/3rd Party.meta

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

File renamed without changes.

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

193 changes: 193 additions & 0 deletions Assets/Adjust/Adjust.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
using System;
using System.Collections.Generic;

using UnityEngine;

namespace com.adjust.sdk
{
public class Adjust : MonoBehaviour
{
private const string sdkPrefix = "unity4.0.0";
private const string errorMessage = "adjust: SDK not started. Start it manually using the 'appDidLaunch' method.";

private static IAdjust instance = null;
private static Action<AdjustAttribution> attributionChangedDelegate = null;

public bool startManually = false;
public bool eventBuffering = false;
public bool printAttribution = false;

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

public AdjustLogLevel logLevel = AdjustLogLevel.Info;
public AdjustEnvironment environment = AdjustEnvironment.Sandbox;

#region Unity lifecycle methods

void Awake ()
{
if (!this.startManually) {
AdjustConfig adjustConfig = new AdjustConfig (this.appToken, this.environment);
adjustConfig.setLogLevel (this.logLevel);
adjustConfig.setEventBufferingEnabled (eventBuffering);

if (printAttribution) {
adjustConfig.setAttributionChangedDelegate(responseDelegate);
}

Adjust.start (adjustConfig);
}
}

void OnApplicationPause(bool pauseStatus) {
if (Adjust.instance == null) {
return;
}

if (pauseStatus) {
Adjust.instance.onPause();
} else {
Adjust.instance.onResume();
}
}

#endregion

#region Adjust methods

public static void start (AdjustConfig adjustConfig)
{
if (Adjust.instance != null) {
Debug.Log ("adjust: Error, SDK already started.");
return;
}

if (adjustConfig == null) {
Debug.Log ("adjust: Missing config to start.");
return;
}

#if UNITY_EDITOR
Adjust.instance = null;
#elif UNITY_IOS
Adjust.instance = new AdjustiOS();
#elif UNITY_ANDROID
Adjust.instance = new AdjustAndroid();
#else
Adjust.instance = null;
#endif

if (Adjust.instance == null) {
Debug.Log ("adjust: SDK can only be used in Android, iOS, Windows Phone 8 or Windows Store apps.");
return;
}

adjustConfig.setSdkPrefix(Adjust.sdkPrefix);
Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate ();

Adjust.instance.start (adjustConfig);
}

public static void trackEvent (AdjustEvent adjustEvent)
{
if (Adjust.instance == null) {
Debug.Log (Adjust.errorMessage);
return;
}

if (adjustEvent == null) {
Debug.Log ("adjust: Missing event to track.");
return;
}

Adjust.instance.trackEvent (adjustEvent);
}

public static void setEnabled(bool enabled) {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}

Adjust.instance.setEnabled(enabled);
}

public static bool isEnabled() {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return false;
}

return Adjust.instance.isEnabled();
}

public static void setOfflineMode(bool enabled) {
if (Adjust.instance == null) {
Debug.Log(Adjust.errorMessage);
return;
}

Adjust.instance.setOfflineMode(enabled);
}

#endregion

#region Attribution callback

public void getNativeMessage (string sAttributionData)
{
Adjust.runAttributionChangedDelegate (sAttributionData);
}

public static void runAttributionChangedDelegate (string stringAttributionData)
{
if (instance == null) {
Debug.Log (Adjust.errorMessage);
return;
}
if (Adjust.attributionChangedDelegate == null) {
Debug.Log ("adjust: Attribution changed delegate was not set.");
return;
}

var attribution = new AdjustAttribution (stringAttributionData);
Adjust.attributionChangedDelegate (attribution);
}

#endregion

#region Private & helper methods

// Our delegate for detecting attribution changes if choosen not to start manually.
private void responseDelegate(AdjustAttribution responseData)
{
Debug.Log ("Attribution changed!");

if (responseData.trackerName != null) {
Debug.Log ("trackerName " + responseData.trackerName);
}

if (responseData.trackerToken != null) {
Debug.Log ("trackerToken " + responseData.trackerToken);
}

if (responseData.network != null) {
Debug.Log ("network " + responseData.network);
}

if (responseData.campaign != null) {
Debug.Log ("campaign " + responseData.campaign);
}

if (responseData.adgroup != null) {
Debug.Log ("adgroup " + responseData.adgroup);
}

if (responseData.creative != null) {
Debug.Log ("creative " + responseData.creative);
}
}

#endregion
}
}
2 changes: 1 addition & 1 deletion Assets/Adjust.cs.meta → Assets/Adjust/Adjust.cs.meta

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

Binary file added Assets/Adjust/Adjust.prefab
Binary file not shown.

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

9 changes: 9 additions & 0 deletions Assets/Adjust/Android.meta

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

Loading

0 comments on commit 73757c5

Please sign in to comment.