Skip to content

Instantly share code, notes, and snippets.

View rob5300's full-sized avatar

Robert rob5300

View GitHub Profile
@rob5300
rob5300 / SpriteRectUvShaderHelper.cs
Last active August 23, 2026 18:54
Writes sprite min and max uv points to materials automatically. For Unity sprite shaders.
using System;
using UnityEngine;
/// <summary>
/// Writes sprite min and max uv points to materials automatically
/// </summary>
/// https://github.com/rob5300
[ExecuteAlways, DisallowMultipleComponent]
public class SpriteRectUvShaderHelper : MonoBehaviour
{
@rob5300
rob5300 / UniTaskDemo_CancellationTokenSimple.cs
Last active August 14, 2026 16:32
Simpler example on how to use a cancellation token to stop an async function on a Unity MonoBehaviour
using Cysharp.Threading.Tasks;
using System;
using System.Threading;
using UnityEngine;
public class UniTaskDemo_CancellationToken : MonoBehaviour
{
void Start()
{
//Start our example!
@rob5300
rob5300 / AudioPan2D.cs
Created March 7, 2026 14:56
Unity Component to implement stereo audio panning in 2D
using UnityEngine;
public class AudioPan2D : MonoBehaviour
{
[SerializeField]
AudioSource audioSource;
public Transform target;
public float panRangeMax = 1f;
@rob5300
rob5300 / UniTaskDemo_CancellationToken.cs
Last active August 14, 2026 16:31
An example on using a Cancellation Token from a CancellationTokenSource to stop an async function in Unity. Uses UniTask.
using Cysharp.Threading.Tasks;
using System;
using System.Threading;
using UnityEngine;
public class UniTaskDemo_CancellationToken : MonoBehaviour
{
CancellationTokenSource animateTokenSource;
void Start()
@rob5300
rob5300 / pixelate_colour_dither.vfx
Created June 27, 2022 18:49
Retro Pixelation + Low Bit Colour + Dither Post Processing Effect for S&Box
HEADER
{
CompileTargets = ( IS_SM_50 && ( PC || VULKAN ) );
Description = "Retro Pixelation + Low Bit Colour + Dither Post Effect";
}
FEATURES
{
}
@rob5300
rob5300 / hologram.vfx
Last active November 2, 2022 20:30
Simple Hologram shader for S&Box
HEADER
{
CompileTargets = ( IS_SM_50 && ( PC || VULKAN ) );
Description = "Hologram Effect";
}
FEATURES
{
#include "common/features.hlsl"
@rob5300
rob5300 / SortCosmeticFiles.py
Created August 29, 2021 12:23
Sort VMT, VTF and MDL/VVD/VTX files into seperate directories
import shutil
import os
import sys
here = os.path.dirname(__file__)
class SortingSet:
targetFolder = ""
matches = []
@rob5300
rob5300 / AllColoursFromVMTs.py
Created August 29, 2021 12:22
A script to extract all detault tint colours from VMTs and write out the data in json.
import os
import re
import json
# A script to extract all detault tint colours from VMTs
# Outputs a json file with all values, vmtname: defaultcolour.
# Where your VMT files are stored. This is relative to the scripts path.
vmtFolder = "_SourceVMT"
@rob5300
rob5300 / bzipall.py
Created November 22, 2020 16:23
BZip each file into its own archive and save into new folder structure. Useful for Source/TF2 server files to download
# BZipAll script to quickly bzip all files in a directory.
# Made by rob5300
# FILL ME IN!!! THIS MAY NOT BE RIGHT FOR YOU!!
# Full path to your 7z.exe executable from your 7z install. Plz download or install it if you need from 7-zip.org
_7zpath = r"C:\Program Files\7-Zip\7z.exe"
#Extensions to ignore
ignore = [".py", ".sp", ".smx", ".bz2"]
@rob5300
rob5300 / InterfaceExample.cs
Created August 26, 2019 21:23
Example of using Interfaces with MonoBehaviours in Unity
using UnityEngine;
public class MyBox : MonoBehaviour, IInteractable{
//We must implement this due to the interface
public void Interact(){
Debug.Log("I was interacted with!");
Destroy(gameObject);
}
}