Skip to content

Instantly share code, notes, and snippets.

@N-Carter
Created May 26, 2012 19:22
Show Gist options
  • Save N-Carter/2795037 to your computer and use it in GitHub Desktop.
Save N-Carter/2795037 to your computer and use it in GitHub Desktop.
OnGetFrameBounds
protected Bounds OnGetFrameBounds()
{
Bounds bounds;
if(m_SelectedWaypoints.Count > 0)
{
// Focus the selected waypoints:
bounds = new Bounds(m_Path.transform.TransformPoint(m_SelectedWaypoints.First().position), Vector3.zero);
foreach(var waypoint in m_SelectedWaypoints.Skip(1))
bounds.Encapsulate(m_Path.transform.TransformPoint(waypoint.position));
}
else
{
// Focus all waypoints and the path's transform.position:
bounds = new Bounds(m_Path.transform.position, Vector3.zero);
foreach(var waypoint in m_Path.m_Waypoints)
bounds.Encapsulate(m_Path.transform.TransformPoint(waypoint.position));
}
return bounds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment