Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions Unity/UnityDemo/Assets/AirSimAssets/Scripts/Vehicles/Vehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,26 @@ private void InitializeVehicle() {
captureResetEvent = new AutoResetEvent(false);
}

//Register all the capture cameras in the scene for recording and data capture.
//Make sure every camera is a child of a gameobject with tag "CaptureCameras"
//Register capture cameras for this vehicle (recording / data capture).
//Each vehicle should own a child hierarchy tagged "CaptureCameras".
//Scene-wide FindGameObjectWithTag only returns the first match and breaks multi-drone simGetImages.
private GameObject FindChildWithTag(GameObject parent, string tag) {
if (parent == null) {
return null;
}
foreach (Transform transform in parent.transform) {
if (transform.CompareTag(tag)) {
return transform.gameObject;
}
}
return null;
}

private void SetUpCameras() {
GameObject camerasParent = GameObject.FindGameObjectWithTag("CaptureCameras");
GameObject thisVehicle = GameObject.Find(this.name);
GameObject camerasParent = FindChildWithTag(thisVehicle, "CaptureCameras");
if (!camerasParent) {
Debug.LogWarning("No Cameras found in the scene to capture data");
Debug.LogWarning("No CaptureCameras found under vehicle '" + this.name + "'");
return;
}

Expand Down