public void SetPosition(Anchor anchor, Pivot?pivot = null) { Anchor = anchor; Pivot = pivot ?? MatchPivotToAnchor(anchor); ScreenSpaceOffset = Point.Zero; recalculateRect = true; RecalculateChildren(false, false); }
private void Init(RectTransform parent = null, Anchor anchor = Anchor.TopLeft, Pivot?pivot = null) { this.parent = parent; parent?.children.Add(this); Anchor = anchor; Pivot = pivot ?? MatchPivotToAnchor(Anchor); }
public RectTransform(Vector2 relativeSize, RectTransform parent, Anchor anchor = Anchor.TopLeft, Pivot?pivot = null, Point?minSize = null, Point?maxSize = null) { Init(parent, anchor, pivot); this.relativeSize = relativeSize; this.minSize = minSize; this.maxSize = maxSize; RecalculateScale(); RecalculateAbsoluteSize(); RecalculateAnchorPoint(); RecalculatePivotOffset(); parent?.ChildrenChanged?.Invoke(this); }
/// <summary> /// By default, elements defined with an absolute size (in pixels), will be treated as fixed sized. /// This can be changed by setting IsFixedSize to false. /// </summary> public RectTransform(Point absoluteSize, RectTransform parent = null, Anchor anchor = Anchor.TopLeft, Pivot?pivot = null) { Init(parent, anchor, pivot); this.nonScaledSize = absoluteSize; RecalculateScale(); RecalculateRelativeSize(); RecalculateAnchorPoint(); RecalculatePivotOffset(); IsFixedSize = true; parent?.ChildrenChanged?.Invoke(this); }
/// <summary> /// By default, elements defined with an absolute size (in pixels) will scale with the parent. /// This can be changed by setting IsFixedSize to true. /// </summary> public RectTransform(Point absoluteSize, RectTransform parent = null, Anchor anchor = Anchor.TopLeft, Pivot?pivot = null, ScaleBasis scaleBasis = ScaleBasis.Normal, bool isFixedSize = false) { Init(parent, anchor, pivot); _scaleBasis = scaleBasis; this.nonScaledSize = absoluteSize; RecalculateScale(); RecalculateRelativeSize(); if (scaleBasis != ScaleBasis.Normal) { RecalculateAbsoluteSize(); } RecalculateAnchorPoint(); RecalculatePivotOffset(); IsFixedSize = isFixedSize; parent?.ChildrenChanged?.Invoke(this); }