Class FlexalonScaleToFitAdapter
- Namespace
- Flexalon
- Assembly
- Flexalon.dll
Sizes an object by scaling it instead of resizing its components. The object's components are measured as usual, then the transform is scaled so the object matches its Flexalon size.
[ExecuteAlways]
[AddComponentMenu("Flexalon/Flexalon Scale To Fit Adapter")]
public class FlexalonScaleToFitAdapter : FlexalonComponent, IFlexalonAdapter
- Inheritance
-
objectObjectComponentBehaviourMonoBehaviourFlexalonScaleToFitAdapter
- Implements
- Inherited Members
Properties
MaxScale
The largest scale allowed on each axis when MaxScaleEnabled is set.
public Vector3 MaxScale { get; set; }
Property Value
- Vector3
MaxScaleEnabled
Whether to limit how large the object can be scaled, using MaxScale.
public bool MaxScaleEnabled { get; set; }
Property Value
- bool
MinScale
The smallest scale allowed on each axis when MinScaleEnabled is set.
public Vector3 MinScale { get; set; }
Property Value
- Vector3
MinScaleEnabled
Whether to limit how small the object can be scaled, using MinScale.
public bool MinScaleEnabled { get; set; }
Property Value
- bool
PreserveAspectRatio
Whether to scale all axes by the same amount, so the object keeps its proportions and fits inside its Flexalon size. Otherwise, each axis is scaled to fill the size exactly.
public bool PreserveAspectRatio { get; set; }
Property Value
- bool
Methods
Measure(IFlexalonNode, Vector3, Vector3, Vector3)
Measure the size of this node.
public Bounds Measure(IFlexalonNode node, Vector3 size, Vector3 min, Vector3 max)
Parameters
nodeIFlexalonNodeThe node to measure.
sizeVector3The size set by the Flexalon Object Component. The adapter should update any axis set to SizeType.Component.
minVector3The maximum size, determined by the MinSizeType.
maxVector3The maximum size, determined by the MaxSizeType and the parent layout.
Returns
- Bounds
The measured bounds to use in layout. Bounds are relative to the transform origin, so RectTransform adapters should account for RectTransform.pivot in Bounds.center.
ResetProperties()
Removes this component's properties from the IFlexalonNode, undoing UpdateProperties. Called when the component is disabled or destroyed. It can run more than once in a row, so it must be idempotent.
protected override void ResetProperties()
TryGetRectSize(IFlexalonNode, out Vector2)
Return what the rect transform size should be.
public bool TryGetRectSize(IFlexalonNode node, out Vector2 rectSize)
Parameters
nodeIFlexalonNodeThe node to update.
rectSizeVector2The desired rect size.
Returns
- bool
True if the rect size should be modified.
TryGetScale(IFlexalonNode, out Vector3)
Return what the gameObject's scale should be in local space.
public bool TryGetScale(IFlexalonNode node, out Vector3 scale)
Parameters
nodeIFlexalonNodeThe node to update.
scaleVector3The desired scale.
Returns
- bool
True if the scale should be modified.
UpdateProperties()
Applies this component's properties to the IFlexalonNode, such as registering the component as the node's layout, adapter, or modifier. Called when the component is enabled, and from MarkDirty while it's active, so it can run many times in a row. It must be idempotent and cheap.
protected override void UpdateProperties()