Used for drawing runtime gizmos in builds and editor (Unity3D)
Used for drawing runtime gizmos in builds and editor (Unity3D)
Used for drawing gizmos in either builds or the editor, as the built in gizmos API by Unity only does so in the editor. With some extra features.
Note: Currently doesn't work if a render pipline asset is set in the graphics settings of the project in SRP, if the version of the SRP package is below 7.1.1
…By default, gizmos will only be drawn to the MainCamera, and the Scene view camera. If you'd like to specify other cameras to also render the gizmos, the Gizmos.CameraFilter predicate allows you to subscribe to a delegate where you can manually specify if a camera should be rendered to or not.
Example
private void OnEnable()
{
//always sub in on enable, because OnEnable gets called when code gets recompiled AND on awake
Gizmos.CameraFilter += cam =>
{
return cam.name == "MyOtherCamera";
};
}The ability to add custom drawers is possible. Inherit from the Drawer class and implement the Draw method. To see an example of drawing a line using a custom drawer, look at the LineDrawer.cs file.
The Draw method takes in a ref parameter to a Vector3 array as the buffer, and then a params array of objects. The method expects to return the number of points allocated to the buffer. For example, if renderering a single line, allocate the two points at buffer[0] and buffer[1], and return 2. If the number returned is not the same as the amount of points actually used, then the end result of the drawn element will look incorrect and corrupt.
Gizmos.Line = Draws a line from point a to b. Equivalent to Gizmos.DrawLineGizmos.Square = Draws a 2D square in the XY planeGizmos.Cube = Draws a 3D cube in world space with orientation and scale parameters. Equivalent to Gizmos.DrawWireCubeGizmos.Bounds = Draws a representation of a Bounds objectGizmos.Rect = Draws a rect object to a specific cameraGizmos.Cone = Draws a cone with specified orientation, length and angle. It looks like the spotlight gizmoGizmos.Sphere = Draws a 3D sphere. Equivalent to Gizmos.DrawWireSphereGizmos.Circle = Draws a 2D circle that is oriented to the camera by defaultThe package uses the same class name as the built-in gizmo class, because of this, you will need to use an alias to point to the right class (using Gizmos = Popcron.Gizmos).
The alternative is to make a global class with the same name that redirects all of its calls to Popcron.Gizmos. The downside to this is that you will need to be explicit when calling the UnityEngine.Gizmos class if you ever need to. Choose your poison.
PopcronGizmos.FrustumCullingOnDrawGizmos(), because this method isnt called in builds, and ensure that Gizmos.Enabled is trueNo open issues yet, or sync has not completed.