Skip to content

Instantly share code, notes, and snippets.

View townofdon's full-sized avatar

Don Juan Javier townofdon

View GitHub Profile
@Mylab6
Mylab6 / CamControl.cs
Created August 2, 2022 22:39
Switch Cinemachine cameras during gameplay.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Cinemachine;
public class CamControl : MonoBehaviour
{
public List<CinemachineVirtualCamera> virtualCameras;
@alexanderameye
alexanderameye / SceneSwitcherToolbarOverlay.cs
Last active December 1, 2023 22:37
A small scene switcher utility for Unity
using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.Overlays;
using UnityEditor.SceneManagement;
using UnityEditor.Toolbars;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UIElements;
@Yanrishatum
Yanrishatum / luts.md
Last active September 25, 2023 04:56
Cheap pixel-art color swap based on LUTs: An article

Cheap pixel-art color swaps based on LUTs: why, how and alternatives.

Why

Pixel-art is a palette-limited image that uses strictly specific colors, and those colors can be easily swapped in the editor. But what about doing it at runtime without a need to re-edit them? For example on sprites to make them appear belonging to a specific team. That technology was used for a long time, but with modern pixel-art games using PNGs, it became harder to do so, since those are not indexed colors.

Working with various people I've seen that it's often done in an inefficient way of just preparing copy of exact same sprite just to change the colors, or make limited version of palette swap by recoloring only a specific color (like magenta) at runtime. But what if we could just use a simple lookup table and swap any color we want during the rendering for a fairly cheap price? That is the why this a thing now.

How

Let's start what we have. Usually people use 8-bit images, meaning that there's 8 bits per the primary c

@gamemachine
gamemachine / SpatialHash.cs
Created May 29, 2021 20:10
Spatial Hash
using Unity.Mathematics;
namespace GameCommon.Spatial
{
public struct SpatialHash
{
public const int Goffset = 10000;
public const int Max = 20480;
public int CellSize;
@bartofzo
bartofzo / LogRangeAttribute.cs
Last active December 22, 2023 19:48
Unity Logarithmic Range Slider
using System;
using UnityEditor;
using UnityEngine;
namespace Tools
{
/// <summary>
/// Add this attribute to a float property to make it a logarithmic range slider
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
@sampattuzzi
sampattuzzi / FPSCharacter.cpp
Created April 3, 2020 10:47
Enable ragdoll on a character with weapon
void AFPSCharacter::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (Health <= 0 && Controller != nullptr)
{
// Shouldn't be in control after we die.
DetachFromControllerPendingDestroy();
// Capsule collisions off

Given a subscribed calendar with a url like

https://example.com/example.ics

To force Google Calendar to refresh and reload the contents right now, unsubscribe from the calendar and subscribe to a new calendar with a URL like

https://example.com/example.ics#1

Adding the anchor tag will force Google Calendar to think of it as a new calendar

@SheldonWangRJT
SheldonWangRJT / Convert .mov or .MP4 to .gif.md
Last active May 15, 2024 22:27
Convert Movie(.mov) file to Gif(.gif) file in one command line in Mac Terminal

This notes is written by Sheldon. You can find me with #iOSBySheldon in Github, Youtube, Facebook, etc.

Need

Convert .mov/.MP4 to .gif

Reason

As a developer, I feel better to upload a short video when I create the pull request to show other viewers what I did in this PR. I tried .mov format directly got after finishing recording screen using Quicktime, however, gif offers preview in most web pages, and has smaller file size.

This is not limited to developer, anyone has this need can use this method to convert the files.

@judy2k
judy2k / parse_dotenv.bash
Created March 22, 2017 13:34
Parse a .env (dotenv) file directly using BASH
# Pass the env-vars to MYCOMMAND
eval $(egrep -v '^#' .env | xargs) MYCOMMAND
# … or ...
# Export the vars in .env into your shell:
export $(egrep -v '^#' .env | xargs)
@tpae
tpae / Trie.js
Created November 20, 2016 23:49
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;