Skip to content

Instantly share code, notes, and snippets.

using System.Collections.Generic;
using UnityEngine;
public static class ObjectPreviewer
{
struct Node
{
public Matrix4x4 transform;
public Mesh mesh;
public Material[] mats;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class LabelDrawer : MonoBehaviour
{
struct Label3D
{
public readonly string text;
public readonly Vector3 position;
using UnityEngine;
public static class GizmoUtils
{
public static void DrawCircle(Vector3 pos, Vector3 forward, float radius)
{
#if UNITY_EDITOR
UnityEditor.Handles.color = Gizmos.color;
UnityEditor.Handles.CircleHandleCap(
-1, pos, Quaternion.LookRotation(forward), radius, EventType.Repaint);
/// Add this script to the parent of colliders you wish to sync to the root rigidbody
using KinematicCharacterController;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BuildKCCPlatform : MonoBehaviour
{
public Transform source;
# A script for single [double] click uploading to itch using butler
# by Nothke
#
# Requirements:
# - Installed butler: https://itch.io/docs/butler/
# - butler added to PATH
#
# How to use:
# 1. Put this script in your project folder,
# 2. Edit the script by adding project names and ignores below
// Thanks to https://twitter.com/jon_barron/status/1318946131078909952
//
using UnityEngine;
public static class CurveUtils
{
// From pico8 example by @otikik
public static float BiasGain(float x, float s, float t)
{
@nothke
nothke / AStarSearchNonAlloc.cs
Last active October 24, 2020 14:49
Vector2Int in description
// This is a C# example from Red Blob Games (https://www.redblobgames.com/pathfinding/a-star/implementation.html#csharp). Remade to have no GCAllocs
// Changes:
// - Made to work in Unity and draw gizmos on screen instead of console text;
// - Cache all collections in Init(), then when Search() is called, no allocs are being made;
// - Uses Unity's Vector2Int that avoids boxing when comparing structs;
// - graph.Neighbors() no longer uses an IEnumerable<>. instead, fill a list with neighbors;
using System;
using System.Collections.Generic;
using UnityEngine;
// A very basic and silly example of some class that contains a slow operation we'd like to compile with Burst.
// This only shows how to CONVERT a -theoretically- already existing piece of code, and still reap the benefits of the Burst compiler.
// If you started with knowing it will be Burst compiled from the beginning you might design everything differently.
// This is an example of how we might do a thing in classic C# OOP
public class ClassicExample
{
public int multiplier = 2;
const int CONST = 42;
public int[] array;
template <typename T>
class SwappingPool
{
public:
const size_t size;
private:
size_t headi{ 0 };
T* data;
public:
  • gifcam records frames uncompressed, and it's a 32bit software, so you can easily run out of memory if you record a large piece of the screen for a long time. If that happens, it usually hangs and becomes unresponsive, and you need to stop the process, but sometimes it pings a warning, or just silently crashes.
  • To check how big your gif is, without saving the file, expand the menu beside Save > and click on Preview, after it's done compressing it will preview and show the size in the window title. This is important to know because there are gif upload limits everywhere, on Twitter it's 15MB, and on Discord it's 8MB (as of August 2020);
  • To reduce the size of the gif to fit in ^ those sizes, I usually try not to change a compression method (to something else than quantize, because it's almost always superior), but instead crop, trim or resize gifs.
  • Gifs ALWAYS have a one pixel wide black border (not sure why!?). You can actually remove it by just cropping the outside a bit in Edit > right click > Crop.