Skip to content

Instantly share code, notes, and snippets.

@zsoi
Created February 22, 2018 10:53
Show Gist options
  • Save zsoi/11fe2084f38f431a7f0012c8a831d7ee to your computer and use it in GitHub Desktop.
Save zsoi/11fe2084f38f431a7f0012c8a831d7ee to your computer and use it in GitHub Desktop.
Unity3D custom editor framing bounds
using UnityEngine;
class CustomComponent : MonoBehaviour
{
// Configure custom world-space bounds as you like in the editor
public Bounds CustomFocusBounds;
}
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(CustomComponent))]
class CustomComponentEditor : EditorWindow
{
// Called by SceneView to check if any of the components has custom frame bounds
public bool HasFrameBounds()
{
return true;
}
// In case HasFrameBounds() returns true, this returns the custom world-space bounds used for framing
public Bounds OnGetFrameBounds()
{
return (target as CustomComponent).CustomFocusBounds;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment