Skip to content

Instantly share code, notes, and snippets.

View Fenikkel's full-sized avatar

Pau Fenollosa Fenikkel

View GitHub Profile
@Fenikkel
Fenikkel / Singleton.cs
Last active June 12, 2024 10:13
Unity singleton
using UnityEngine;
public abstract class Singleton<T> : MonoBehaviour where T : MonoBehaviour
{
public static T Instance { get; private set; }
protected virtual void Awake()
{
CheckSingleton();
}
@keijiro
keijiro / setup_scoped_registry.md
Last active April 21, 2024 04:56
How to add "Keijiro" scoped registry to your Unity project

How to add "Keijiro" scoped registry to your Unity project

Open the Package Manager page in the Project Settings window and add the following entry to the "Scoped Registries" list:

  • Name: Keijiro
  • URL: https://registry.npmjs.com
  • Scope: jp.keijiro

Scoped Registry

@mandarinx
mandarinx / Outline.shader
Created March 28, 2022 07:48 — forked from ScottJDaley/Outline.shader
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@ScottJDaley
ScottJDaley / Outline.shader
Last active May 24, 2024 01:49
Wide Outlines Renderer Feature for URP and ECS/DOTS/Hybrid Renderer
// Original shader by @bgolus, modified slightly by @alexanderameye for URP, modified slightly more
// by @gravitonpunch for ECS/DOTS/HybridRenderer.
// https://twitter.com/bgolus
// https://medium.com/@bgolus/the-quest-for-very-wide-outlines-ba82ed442cd9
// https://alexanderameye.github.io/
// https://twitter.com/alexanderameye/status/1332286868222775298
Shader "Hidden/Outline"
{
Properties
@hasanbayatme
hasanbayatme / GlobalVariables.cs
Last active November 17, 2023 09:14
A simple C# static class to get and set globally accessible variables through a key-value approach (C#, Unity, .NET)
using System.Collections.Generic;
/// <summary>
/// A simple static class to get and set globally accessible variables through a key-value approach.
/// </summary>
/// <remarks>
/// <para>Uses a key-value approach (dictionary) for storing and modifying variables.</para>
/// <para>It also uses a lock to ensure consistency between the threads.</para>
/// </remarks>
public static class GlobalVariables
@JohannesMP
JohannesMP / UIBlur.shader
Last active July 10, 2024 11:36
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
@mandarinx
mandarinx / ScreenShake.cs
Created January 21, 2016 08:11 — forked from insominx/gist:f3acce17108d0a2e4619
Screen shake in Unity
IEnumerator Shake() {
float elapsed = 0.0f;
Vector3 originalCamPos = Camera.main.transform.position;
while (elapsed < duration) {
elapsed += Time.deltaTime;
@frozax
frozax / DrawBounds.cs
Last active February 8, 2023 13:37
Unity component to show object bounds (in editor and in-game)
using UnityEngine;
public static class RendererArrayExtension
{
public static Bounds ComputeBounds(this Renderer[] renderers)
{
Bounds bounds = new Bounds();
for (int ir = 0; ir < renderers.Length; ir++)
{
Renderer renderer = renderers[ir];