Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 4a630a7

Browse files
author
chrwend
committed
Fix script initialization
1 parent 0da4c28 commit 4a630a7

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

ExampleGame/Assets/Editor/PostBuildTrigger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static void InsertCodeIntoClass(string filepath, string[] methodSignatur
126126
newContents.Add(valuesToAppend[foundIndex] + rn);
127127
found = false;
128128
} else if((positionsInMethod[foundIndex] == Position.End) && line.Trim().Equals("}")) {
129-
newContents = newContents.GetRange(0, newContents.Count - 3);
129+
newContents = newContents.GetRange(0, newContents.Count - 1);
130130
newContents.Add(valuesToAppend[foundIndex] + rn + "}" + rn);
131131
found = false;
132132
}

ExampleGame/Assets/HockeyAppUnityIOS/HockeyAppUnity-Scripts/HockeyAppIOS.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class HockeyAppIOS : MonoBehaviour
1616
protected const string HOCKEYAPP_CRASHESPATH = "api/2/apps/[APPID]/crashes/upload";
1717
protected const string LOG_FILE_DIR = "/logs/";
1818
protected const int MAX_CHARS = 199800;
19+
private static HockeyAppIOS instance;
1920

2021
public enum AuthenticatorType
2122
{
@@ -67,6 +68,11 @@ void Awake ()
6768
{
6869

6970
#if (UNITY_IPHONE && !UNITY_EDITOR)
71+
if (instance != null) {
72+
Destroy(gameObject);
73+
return;
74+
}
75+
7076
DontDestroyOnLoad(gameObject);
7177
CreateLogDirectory();
7278

@@ -106,6 +112,7 @@ void GameViewLoaded (string message)
106112
string urlString = GetBaseURL();
107113
string authTypeString = GetAuthenticatorTypeString();
108114
HockeyApp_StartHockeyManager(appID, urlString, authTypeString, secret, updateAlert, userMetrics, autoUploadCrashes);
115+
instance = this;
109116
#endif
110117
}
111118

Plugin/Editor/PostBuildTrigger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private static void InsertCodeIntoClass(string filepath, string[] methodSignatur
126126
newContents.Add(valuesToAppend[foundIndex] + rn);
127127
found = false;
128128
} else if((positionsInMethod[foundIndex] == Position.End) && line.Trim().Equals("}")) {
129-
newContents = newContents.GetRange(0, newContents.Count - 3);
129+
newContents = newContents.GetRange(0, newContents.Count - 1);
130130
newContents.Add(valuesToAppend[foundIndex] + rn + "}" + rn);
131131
found = false;
132132
}

Plugin/HockeyAppUnityIOS/HockeyAppUnity-Scripts/HockeyAppIOS.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class HockeyAppIOS : MonoBehaviour
1616
protected const string HOCKEYAPP_CRASHESPATH = "api/2/apps/[APPID]/crashes/upload";
1717
protected const string LOG_FILE_DIR = "/logs/";
1818
protected const int MAX_CHARS = 199800;
19+
private static HockeyAppIOS instance;
1920

2021
public enum AuthenticatorType
2122
{
@@ -67,6 +68,11 @@ void Awake ()
6768
{
6869

6970
#if (UNITY_IPHONE && !UNITY_EDITOR)
71+
if (instance != null) {
72+
Destroy(gameObject);
73+
return;
74+
}
75+
7076
DontDestroyOnLoad(gameObject);
7177
CreateLogDirectory();
7278

@@ -106,6 +112,7 @@ void GameViewLoaded (string message)
106112
string urlString = GetBaseURL();
107113
string authTypeString = GetAuthenticatorTypeString();
108114
HockeyApp_StartHockeyManager(appID, urlString, authTypeString, secret, updateAlert, userMetrics, autoUploadCrashes);
115+
instance = this;
109116
#endif
110117
}
111118

0 commit comments

Comments
 (0)