/// <summary> /// Converts the edge settings configured in this component to settings for the /// relative panel. /// </summary> /// <param name="dest">The location where the converted settings will be stored.</param> /// <param name="status">The original component edge configuration.</param> /// <param name="mapping">The mapping from PLib UI components to Unity objects.</param> private void Resolve(RelativeLayoutParams.EdgeStatus dest, RelativeConfig.EdgeStatus status, IDictionary <IUIComponent, GameObject> mapping) { var c = status.FromComponent; dest.FromAnchor = status.FromAnchor; if (c != null) { dest.FromComponent = mapping[c]; } dest.Constraint = status.Constraint; dest.Offset = status.Offset; }
/// <summary> /// Sets a component's edge constraint. /// </summary> /// <param name="edge">The edge to set.</param> /// <param name="fraction">The fraction of the parent to anchor.</param> /// <param name="child">The other component to anchor.</param> private void SetEdge(RelativeLayoutParams.EdgeStatus edge, float fraction, GameObject child) { if (fraction >= 0.0f && fraction <= 1.0f) { edge.Constraint = RelativeConstraintType.ToAnchor; edge.FromAnchor = fraction; edge.FromComponent = null; } else if (child != null) { edge.Constraint = RelativeConstraintType.ToComponent; edge.FromComponent = child; } else { edge.Constraint = RelativeConstraintType.Unconstrained; edge.FromComponent = null; } }