Skip to content

Instantly share code, notes, and snippets.

@kraj0t
Last active February 14, 2022 02:26
Show Gist options
  • Save kraj0t/48d062ef996f953adae899855858e58d to your computer and use it in GitHub Desktop.
Save kraj0t/48d062ef996f953adae899855858e58d to your computer and use it in GitHub Desktop.
Unity Editor: undocumented callbacks in Editor class to define bounds for focus
/// <summary>
/// Undocumented Unity callback. More info here:
/// https://forum.unity.com/threads/editor-how-do-i-set-the-bounds-of-an-empty-gameobject-for-focus-f-key.427093/
/// </summary>
/// <returns></returns>
public bool HasFrameBounds()
{
return true;
}
/// <summary>
/// Undocumented Unity callback. More info here:
/// https://forum.unity.com/threads/editor-how-do-i-set-the-bounds-of-an-empty-gameobject-for-focus-f-key.427093/
/// </summary>
/// <returns></returns>
public Bounds OnGetFrameBounds()
{
var line = target as UILineRendererSimplified;
var bounds = new Bounds();
foreach (var p in line.Points)
{
bounds.Encapsulate(p);
}
bounds.center = line.transform.position;
return bounds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment