Skip to content

Instantly share code, notes, and snippets.

@h3r2tic
h3r2tic / raymarch.hlsl
Last active August 16, 2024 23:12
Depth buffer raymarching for contact shadows, SSGI, SSR, etc.
// Copyright (c) 2023 Tomasz Stachowiak
//
// This contribution is dual licensed under EITHER OF
//
// Apache License, Version 2.0, (http://www.apache.org/licenses/LICENSE-2.0)
// MIT license (http://opensource.org/licenses/MIT)
//
// at your option.
#include "/inc/frame_constants.hlsl"
@moosetraveller
moosetraveller / draggable-panel.md
Created August 12, 2021 22:57
Javascript: Draggable Panel

Make Panel Draggable

HTML

<div id="panelContainer">
    <div id="panelTitle">Title</div>
    <div id="panelBody">Body</div>
</div>

CSS

@LotteMakesStuff
LotteMakesStuff / Flicker.cs
Created June 16, 2021 04:49
Quake/Halflife style light flicker
using UnityEngine;
public class Flicker : MonoBehaviour
{
public string LightStyle = "mmamammmmammamamaaamammma";
private Light light;
public float loopTime = 2f;
[SerializeField]
private int currentIndex = 0;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.ResourceManagement.ResourceProviders;
public sealed class AddressablesDownloader
{
@SradnickDev
SradnickDev / SerializedScriptableObject.cs
Last active June 24, 2020 21:09
SerializedScriptableObject allows to serialize stuff that unity cant like, inheritance for custom classes in e.g in lists. With the use of https://www.newtonsoft.com/json
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;
namespace Core.Utilities
{
/// <summary>
/// To extend Unity's serialization process.
/// Unity cant serializes inheritance properly e.g in a list of base types, adding an inherited class won’t be serialized as it.
@123tris
123tris / $CooldownManagerExample.cs
Last active September 9, 2024 08:01
A unity script for easily delaying parts of your code
//----------- Example code -----------
float health = 5;
CooldownManager.Cooldown(2, () => health++); //Delay health increment by 2 seconds
CooldownManager.Cooldown(5, Shoot); //Invoke shoot in 5 seconds
void Shoot () { }
//If you dont want to use lambda's for functions with parameters you can overload the function like so:
CooldownManager.Cooldown(2, Damage, 5); //Calls Damage() function with damageValue 5 after 2 seconds have passed
@yasirkula
yasirkula / SlicedFilledImage.cs
Last active September 19, 2024 07:30
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@yasirkula
yasirkula / ScriptedAnimations.cs
Last active March 8, 2024 02:28
GC-free animation system for simple animations like scaling/moving objects or fading a UI element in Unity
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace ScriptedAnim
{
// Hide from Add Component menu
[AddComponentMenu( "" )]
public class ScriptedAnimations : MonoBehaviour
{
@sinbad
sinbad / TooltipPanel.cs
Last active September 25, 2021 17:25
Simple Unity UI tooltip system (requires DoTween)
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
// Attach this component to a UI object which will be the tooltip visual
// Must include some text somewhere of course, and optionally a CanvasGroup if you want fading
public class TooltipPanel : MonoBehaviour {
[Tooltip("The text object which will display the tooltip string")]
public TextMeshProUGUI tooltipText;
@gekidoslair
gekidoslair / PhysicsSettler.cs
Created December 30, 2019 23:58
Activate physics in Edit mode to dynamically drop or settle objects in a scene
using UnityEngine;
using UnityEditor;
using UnityEditor.ShortcutManagement;
namespace PixelWizards.Utilities
{
// This causes the class' static constructor to be called on load and on starting playmode
[InitializeOnLoad]
class PhysicsSettler