Skip to content

Instantly share code, notes, and snippets.

@pyjamads
pyjamads / AutoExpandGridLayoutGroup.cs
Last active December 29, 2022 10:07
A Unity UI Auto expanding grid layout group, that automatically changes column and row count - adapted from collin_patrick's AutoExpandGridLayoutGroup https://forum.unity.com/threads/solved-how-to-make-grid-layout-group-cell-size-x-auto-expand.448534/
namespace UnityEngine.UI
{
[AddComponentMenu("Layout/Auto Expand Grid Layout Group", 152)]
public class AutoExpandGridLayoutGroup : LayoutGroup
{
public enum Corner { UpperLeft = 0, UpperRight = 1, LowerLeft = 2, LowerRight = 3 }
public enum Axis { Horizontal = 0, Vertical = 1 }
public enum Constraint { Flexible = 0, FixedColumnCount = 1, FixedRowCount = 2 }
[SerializeField]
@JohannesMP
JohannesMP / UIBlur.shader
Last active July 17, 2024 19:42
UI.Image Blur Shader with layering and masking support
Shader "Custom/UIBlur"
{
Properties
{
[Toggle(IS_BLUR_ALPHA_MASKED)] _IsAlphaMasked("Image Alpha Masks Blur", Float) = 1
[Toggle(IS_SPRITE_VISIBLE)] _IsSpriteVisible("Show Image", Float) = 1
// Internally enforced by MAX_RADIUS
_Radius("Blur Radius", Range(0, 64)) = 1
@kormyen
kormyen / GyroCamera.cs
Last active September 22, 2023 13:37
Unity3D script for rotating camera with a phone's gyro. Includes smoothing and initial offset. Edited from https://forum.unity3d.com/threads/sharing-gyroscope-camera-script-ios-tested.241825/
using UnityEngine;
using System.Collections;
public class GyroCamera : MonoBehaviour
{
// STATE
private float _initialYAngle = 0f;
private float _appliedGyroYAngle = 0f;
private float _calibrationYAngle = 0f;
private Transform _rawGyroRotation;