SetPivotWithCounterAdjust(Vector2, bool)
Sets the pivot point of the RectTransform, adjusting the position to keep the rectangle in place.
Read time 1 minuteLast updated 4 days ago
Definition
- Type: Method
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
public void SetPivotWithCounterAdjust(Vector2 newPivot, bool adjustChildren = false)
Parameters
Remarks
adjustChildren only affects direct children without the component, because always takes its parent's pivot into account when calculating its position.
RectTransformRectTransformExamples
using UnityEngine;public class Example : MonoBehaviour{ RectTransform rectTransform; void Start() { rectTransform = GetComponent<RectTransform>(); } void Update() { rectTransform.SetPivotWithCounterAdjust(new Vector2(0f, 1f)); }}