Skip to content

Instantly share code, notes, and snippets.

View WereWolfACE's full-sized avatar

Valeriya WereWolfACE

  • Kiev
View GitHub Profile
@sttz
sttz / ScrollToCeneter.cs
Last active November 4, 2023 05:10
Method to center an element in a ScrollRect using Unity's new UI system
using UnityEngine;
using UnityEngine.UI;
public static class UIExtensions {
// Shared array used to receive result of RectTransform.GetWorldCorners
static Vector3[] corners = new Vector3[4];
/// <summary>
/// Transform the bounds of the current rect transform to the space of another transform.
/// </summary>