Skip to content

Commit

Permalink
Deprecate ChangeFOV
Browse files Browse the repository at this point in the history
  • Loading branch information
AlvaroHG committed Oct 3, 2024
1 parent 020bb5b commit 803cbba
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions unity/Assets/Scripts/PhysicsRemoteFPSAgentController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6113,47 +6113,9 @@ public void RotateUniverseAroundAgent(ServerAction action) {
}

public void ChangeFOV(float fieldOfView, string camera = "") {
if (fieldOfView > 0 && fieldOfView < 180) {
if (string.IsNullOrEmpty(camera)) {
m_Camera.fieldOfView = fieldOfView;
actionFinished(true);
} else {
var cameraTuples = new List<(Camera camera, bool isThirdPartyCamera, int id)>()
{
(camera: m_Camera, isThirdPartyCamera: false, id: -1)
}.Concat(
this.agentManager.thirdPartyCameras.Select(
(c, i) => (camera: c, isThirdPartyCamera: true, id: i)
)
);
var matches = cameraTuples;
if (camera != "*") {
matches = cameraTuples.Where(t => t.camera.name == camera);
}
// Debug.Log($"Camera matches: {matches.Count()} {string.Join(", ", matches.Select(m => m.camera.name))}");
if (matches.Count() == 0) {
errorMessage =
$"Camera '{camera}' is not present in the agent, make sure the agent was initialized correctly or camera was added via 'AddThirdPartyCamera'.";
actionFinished(false);
} else {
foreach (var tuple in matches) {
if (tuple.isThirdPartyCamera) {
agentManager.UpdateThirdPartyCamera(
tuple.id,
fieldOfView: fieldOfView
);
} else {
tuple.camera.fieldOfView = fieldOfView;
}
}
actionFinished(true);
}
}
} else {
errorMessage = "fov must be in (0, 180) noninclusive.";
Debug.Log(errorMessage);
actionFinished(false);
}
throw new InvalidOperationException(
"This action is deprecated. Use `UpdateMainCamera` or `UpdateThirdPartyCamera` instead."
);
}

// in case you want to change the timescale
Expand Down

0 comments on commit 803cbba

Please sign in to comment.