Skip to content

Instantly share code, notes, and snippets.

View RedDude's full-sized avatar

Rinaldo Alipio Bueno RedDude

View GitHub Profile
@RedDude
RedDude / CanvasPositioningExtensions.cs
Created August 30, 2021 18:31 — forked from FlaShG/CanvasPositioningExtensions.cs
A small Unity helper class to convert viewport, screen or world positions to canvas space.
using UnityEngine;
/// <summary>
/// Small helper class to convert viewport, screen or world positions to canvas space.
/// Only works with screen space canvases.
/// </summary>
/// <example>
/// <code>
/// objectOnCanvasRectTransform.anchoredPosition = specificCanvas.WorldToCanvasPoint(worldspaceTransform.position);
/// </code>