Skip to content

Instantly share code, notes, and snippets.

View GhatSmith's full-sized avatar

Ghat Smith GhatSmith

View GitHub Profile
@yasirkula
yasirkula / ScrollViewFocusFunctions.cs
Created October 23, 2021 10:09
Focus/center Scroll View to the specified point/item in Unity
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public static class ScrollViewFocusFunctions
{
public static Vector2 CalculateFocusedScrollPosition( this ScrollRect scrollView, Vector2 focusPoint )
{
Vector2 contentSize = scrollView.content.rect.size;
Vector2 viewportSize = ( (RectTransform) scrollView.content.parent ).rect.size;
@andrew-raphael-lukasik
andrew-raphael-lukasik / .CapsuleCapsuleIntersection.cs.md
Last active September 28, 2023 18:51
capsule-capsule intersection test (also segment-segment)

capsule-capsule intersection test

@bgolus
bgolus / InfiniteGrid.shader
Last active November 20, 2024 01:20
Infinite Grid shader with procedural grid with configurable divisions and major and minor lines markings.
Shader "Unlit/InfiniteGrid"
{
Properties
{
[Toggle] _WorldUV ("Use World Space UV", Float) = 1.0
_GridScale ("Grid Scale", Float) = 1.0
_GridBias ("Grid Bias", Float) = 0.5
_GridDiv ("Grid Divisions", Float) = 10.0
_BaseColor ("Base Color", Color) = (0,0,0,1)
_LineColor ("Line Color", Color) = (1,1,1,1)