Created
February 22, 2018 10:53
-
-
Save zsoi/11fe2084f38f431a7f0012c8a831d7ee to your computer and use it in GitHub Desktop.
Unity3D custom editor framing bounds
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
class CustomComponent : MonoBehaviour | |
{ | |
// Configure custom world-space bounds as you like in the editor | |
public Bounds CustomFocusBounds; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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