Skip to content

Commit 51ea280

Browse files
committed
Version 2.0.3: Fixed game object null condition
1 parent c72f9d7 commit 51ea280

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Backtrace Unity Release Notes
22

3+
## Version 2.0.3
4+
5+
- Annotations object will validate game object before converting it.
6+
37
## Version 2.0.2
48

59
- Fixed invalid cast for nested game objects in Backtrace Attributes,

src/Model/BacktraceData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public string ToJson()
123123
["lang"] = "csharp",
124124
["langVersion"] = "Unity",
125125
["agent"] = "backtrace-unity",
126-
["agentVersion"] = "2.0.2",
126+
["agentVersion"] = "2.0.3",
127127
["mainThread"] = MainThread,
128128
["classifiers"] = new JArray(Classifier),
129129
["attributes"] = Attributes.ToJson(),
@@ -169,7 +169,7 @@ private void SetReportInformation()
169169
Uuid = Report.Uuid;
170170
Timestamp = Report.Timestamp;
171171
LangVersion = "Mono/IL2CPP";
172-
AgentVersion = "2.0.2";
172+
AgentVersion = "2.0.3";
173173
Classifier = Report.ExceptionTypeReport ? new[] { Report.Classifier } : null;
174174
}
175175
}

src/Model/JsonData/Annotations.cs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,14 @@ private BacktraceJObject ConvertGameObject(GameObject gameObject)
117117
var jGameObject = GetJObject(gameObject);
118118
var innerObjects = new JArray();
119119

120-
foreach (RectTransform childObject in gameObject.transform)
120+
foreach (var childObject in gameObject.transform)
121121
{
122-
innerObjects.Add(ConvertGameObject(childObject, gameObject.name));
122+
var transformChildObject = childObject as RectTransform;
123+
if(transformChildObject == null)
124+
{
125+
continue;
126+
}
127+
innerObjects.Add(ConvertGameObject(transformChildObject, gameObject.name));
123128
}
124129
jGameObject["childrens"] = innerObjects;
125130
return jGameObject;
@@ -130,9 +135,14 @@ private BacktraceJObject ConvertGameObject(RectTransform gameObject, string pare
130135
var result = GetJObject(gameObject, parentName);
131136
var innerObjects = new JArray();
132137

133-
foreach (RectTransform childObject in gameObject.transform)
134-
{
135-
innerObjects.Add(ConvertGameObject(childObject, gameObject.name));
138+
foreach (var childObject in gameObject.transform)
139+
{
140+
var transformChildObject = childObject as RectTransform;
141+
if (transformChildObject == null)
142+
{
143+
continue;
144+
}
145+
innerObjects.Add(ConvertGameObject(transformChildObject, gameObject.name));
136146
}
137147
result["childrens"] = innerObjects;
138148
return result;

0 commit comments

Comments
 (0)