Skip to content

Instantly share code, notes, and snippets.

@frarees
frarees / SyncUtil.cs
Last active August 17, 2022 10:09
C# Solution Sync for Unity3D
// https://frarees.github.io/default-gist-license
using UnityEngine;
using UnityEditor;
using System;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine.Profiling;
[InitializeOnLoad]
@SeanMcTex
SeanMcTex / PinToSafeArea.cs
Last active August 9, 2024 07:11
Restrict Unity UI to an iPhone X or other Mobile Device's Safe Area
using UnityEngine;
/// <summary>
/// Resizes a UI element with a RectTransform to respect the safe areas of the current device.
/// This is particularly useful on an iPhone X, where we have to avoid the notch and the screen
/// corners.
///
/// The easiest way to use it is to create a root Canvas object, attach this script to a game object called "SafeAreaContainer"
/// that is the child of the root canvas, and then layout the UI elements within the SafeAreaContainer, which
/// will adjust size appropriately for the current device./// </summary>