Skip to content

Commit 010dce6

Browse files
authored
Merge pull request #12 from aosoft/aosoft/fix-bugs
Update profiler to handle empty event data and add Debug derive
2 parents 0c711d9 + 3641a53 commit 010dce6

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

unity-native-plugin-sample-profiler/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ fn plugin_load(interfaces: &unity_native_plugin::interface::UnityInterfaces) {
9797
desc.desc.name()
9898
))
9999
.ok();
100+
101+
for data in desc.event_data.iter() {
102+
sender.send(format!("data={:?}", data.value())).ok();
103+
}
100104
}),
101105
);
102106
}));

unity-native-plugin/src/profiler_callbacks.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl ProfilerMarkerData {
123123
}
124124
}
125125

126+
#[derive(Debug)]
126127
pub enum ProfilerMarkerDataValue<'a> {
127128
None,
128129
InstanceId(i32),
@@ -176,7 +177,16 @@ extern "system" fn marker_event_bridge(
176177
None => return,
177178
};
178179

179-
let event_data = unsafe { std::slice::from_raw_parts(_event_data as *const ProfilerMarkerData, _event_data_count as usize) };
180+
let event_data = if !_event_data.is_null() && _event_data_count > 0 {
181+
unsafe {
182+
std::slice::from_raw_parts(
183+
_event_data as *const ProfilerMarkerData,
184+
_event_data_count as usize,
185+
)
186+
}
187+
} else {
188+
&[]
189+
};
180190

181191
let desc = ProfilerMarkerEvent {
182192
desc,

0 commit comments

Comments
 (0)