Skip to content

Chart3DComponent

ClassChartGuruChartGuru.3D
public class Chart3DComponent : ChartComponent, IChartHost

World-space host that turns a 3D Chart into actual rendered geometry: a surface mesh, a line mesh for axes and grid, camera-facing labels and UnityEngine.Graphics.DrawMeshInstanced(UnityEngine.Mesh, int, UnityEngine.Material, UnityEngine.Matrix4x4[], int, UnityEngine.MaterialPropertyBlock, UnityEngine.Rendering.ShadowCastingMode, bool, int, UnityEngine.Camera, UnityEngine.Rendering.LightProbeUsage, UnityEngine.LightProbeProxyVolume) point symbols, all under a hidden content child. Without a camera rig the content turns about the plot center to show the chart's pose, so any camera sees the pose; a Chart3DCameraRig orbits by the pose instead.

A ChartRaycaster on the camera brings it pointer events: hover tooltips, tap selection of marks and of X, Y and Z values, drag to orbit and scroll or pinch to zoom.

public void PlayLift(float lift, Animation? animation = null, Action completed = null)

Animates Chart3DComponent.Lift to lift: toward 1 the flat chart lifts into 3D, toward 0 it flattens into its 2D drawing. The marks move from where they are drawn through a keyed transition, as data changes do, and the pose turns between the front view and the chart’s pose. animation defaults to the chart’s animation; without one, or while the host is inactive, the lift shows at once. completed runs when the lift ends, or at once without an animation.

Parameters

NameType
liftSystem.Single
animationSystem.Nullable{ChartGuru.Animation}
completedSystem.Action
public void RebuildMeshes()

Ends a running transition and rebuilds the chart’s geometry and axis chrome now, instead of on the next update.

public Texture2D Capture(Chart3DCaptureOptions options)

Renders what this host shows into a new image: its chart, compiled from the definition or set from code, with its plot size, data proportions, materials, axes, shadow plane, pose, projection and theme, framed like a camera orbiting by the pose. The scene is not involved: the chart renders on a private layer, without post-processing, so a transparent background keeps its alpha. A running transition is captured at its end.

Parameters

NameTypeDescription
optionsChartGuru.Chart3DCaptureOptionsSize, supersampling and background. Unset sizes use Chart3DCaptureOptions.Default.

Returns

UnityEngine.Texture2D: An sRGB RGBA32 texture the caller owns and destroys, or null when the host shows no chart.

public byte[] CaptureToPng(Chart3DCaptureOptions options)

Renders what this host shows as with Chart3DComponent.Capture(Chart3DCaptureOptions) and encodes it as PNG, keeping a transparent background’s alpha. Returns null when the host shows no chart.

Parameters

NameType
optionsChartGuru.Chart3DCaptureOptions

Returns

System.Byte[]

public Chart3DComponent()

A new 3D chart starts as a 3D bar chart wherever it is created, including AddComponent in a player, where ChartGuru.Chart3DComponent.Reset never runs. Unity constructs a component before it deserializes one, so a saved definition, 2D chart types included, replaces this default.

public float Lift { get; set; }

How lifted the chart is drawn: 1, the default, draws it at full depth and its pose; 0 draws it flat and facing the viewer from the front pose, as its 2D chart. Setting it shows the new lift at once; Chart3DComponent.PlayLift(float, Animation?, Action) animates it. Definitions of 2D chart types always draw flat.

Returns

System.Single

public bool IsLifting { get; }

True while Chart3DComponent.PlayLift(float, Animation?, Action) animates the lift.

Returns

System.Boolean

public Vector3 PlotSize { get; set; }

Returns

UnityEngine.Vector3

public bool PreserveDataProportions { get; set; }

Returns

System.Boolean

public Material SurfaceMaterialOverride { get; set; }

Optional material for this chart’s surfaces, bars and points. When set it wins over the chart’s surface preset (ChartSpatialSettings.SurfacePreset) and the theme’s material.

Returns

UnityEngine.Material

public Material EffectiveSurfaceMaterial { get; }

Resolved surface material: Chart3DComponent.SurfaceMaterialOverride, else the chart’s surface preset when it is not Chart3DSurfacePreset.Theme, else the theme’s material, else the built-in theme preset.

Returns

UnityEngine.Material

public bool DrawAxes { get; set; }

Returns

System.Boolean

public bool DrawShadowPlane { get; set; }

Returns

System.Boolean

public bool DrawEnvironment { get; set; }

Returns

System.Boolean

public Chart3DCameraRig CameraRig { get; }

Returns

ChartGuru.Chart3DCameraRig

public Bounds LocalPlotBounds { get; }

Returns

UnityEngine.Bounds

public Bounds ResolvedPlotBounds { get; }

Plot-space envelope after applying explicit axis ranges.

Returns

UnityEngine.Bounds