Skip to content

Instantly share code, notes, and snippets.

View iSnakeBuzz's full-sized avatar
🎯
Focusing

Martín iSnakeBuzz

🎯
Focusing
View GitHub Profile
@fadookie
fadookie / CameraAnchor.cs
Last active June 12, 2025 06:10
Screen-relative anchoring component for Unity3D. Find more Unity code at http://www.eliotlash.com/2015/01/unity3d-components-and-code-snippets/
/***
* This script will anchor a GameObject to a relative screen position.
* This script is intended to be used with ViewportHandler.cs by Marcel Căşvan, available here: http://gamedev.stackexchange.com/a/89973/50623
* It is also copied in this gist below.
*
* Note: For performance reasons it's currently assumed that the game resolution will not change after the game starts.
* You could not make this assumption by periodically calling UpdateAnchor() in the Update() function or a coroutine, but is left as an exercise to the reader.
*/
/* The MIT License (MIT)