Skip to content

Instantly share code, notes, and snippets.

@Arakade
Arakade / ButtonAndMouseInEditor.cs
Created Mar 9, 2021
Unity3D Editor OnSceneGUI() code for detecting mouse-press while key held changed in 2020.2.7f1 (at least)
View ButtonAndMouseInEditor.cs
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
// pre C#8
//#nullable enable
public sealed class ButtonAndMouseInEditor : MonoBehaviour {
@Arakade
Arakade / AoC-2020-day5.ts
Created Dec 5, 2020
Advent of Code 2020, Day 5 TypeScript (functional style)
View AoC-2020-day5.ts
// Advent of code 2020, Day 5
import fs from 'fs';
import assert from 'assert';
function convertStringToSeatId(seatCode: string): number {
return (Array.prototype.map.call(seatCode, (c: string): number => {
switch (c) {
case 'F':
case 'L':
@Arakade
Arakade / Command.ts
Created Nov 13, 2020
AJV TypeScript JSONSchemaType requires methods?
View Command.ts
/**
* Enumeration of valid commands.
*/
export type Command = 'RegisterGame' | 'GameToController' | 'ControllerToGame';
@Arakade
Arakade / CollisionHelper.cs
Created Apr 23, 2020
Log when collisions and triggers are entered and exited.
View CollisionHelper.cs
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine.Assertions;
using UnityEngine;
namespace UGS.unityutils {
/// <summary>
/// Log when collisions and triggers are entered and exited.
/// </summary>
public sealed class CollisionHelper : MonoBehaviour {
@Arakade
Arakade / SleepHelper.cs
Created Apr 23, 2020
Log and provide a UnityEvent for when `Rigidbody.IsSleeping` changes.
View SleepHelper.cs
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.Events;
namespace UGS.unityutils {
@Arakade
Arakade / CustomJsonSerializationTest.cs
Created Mar 5, 2020
Custom JSON.Net Dictionary serialization for when value object contains the key the dictionary uses to map to it.
View CustomJsonSerializationTest.cs
// See https://unreasonablygoodsoftware.wordpress.com/2020/03/05/json-net-custom-dictionary-serialization/
using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using Newtonsoft.Json;
using NUnit.Framework;
using UnityEngine.Scripting;
namespace packageNameRemoved {
@Arakade
Arakade / CinemachineDebugger.cs
Created Jul 19, 2019
Little debug script for helping investigate Cinemachine blend issues
View CinemachineDebugger.cs
using System.Text;
using Cinemachine;
using UGS.unityutils.attributes;
using UnityEngine;
namespace UGS.snwscf.camera {
public sealed class CameraDebugger : MonoBehaviour {
#region serialized
[SerializeField, NonNull]
@Arakade
Arakade / ECS-Unity.Physics.dot
Created Jun 7, 2019
GraphViz file for Unity3D ECS including new Unity.Physics and showing spaces for its various callback groups.
View ECS-Unity.Physics.dot
# GraphViz file for Unity3D ECS including new Unity.Physics and showing spaces for its various callback groups.
# Render with:
# dot -Tpng ECS-Unity.Physics.dot -o ECS-Unity.Physics.png
#
# License: CC-SA (BY appreciated but not required)
# Original version: @Arakade Rupert Key, 2019/06/07
digraph "Unity.Physics" {
label="ECS + Unity.Physics jobs and phases"
compound=true
@Arakade
Arakade / StickCauseMB.cs
Created Jun 5, 2019
ECS/DOTS Unity.Physics preview-0.1.0 collision system that creates joints on collisions when a StickCause is present.
View StickCauseMB.cs
using Unity.Burst;
using Unity.Entities;
using Unity.Physics.Authoring;
using UnityEngine;
using UnityEngine.Assertions;
namespace UGS {
/// <summary>
/// Tag component for causing things to stick.
/// Could I also do this with a Physics.Material "Custom Flags" or "Collision Filter" ?
@Arakade
Arakade / SteamSpyUtil.gs
Created May 7, 2019
Google Scripts bound spreadsheet script to get data from Steam Spy and place in sheet
View SteamSpyUtil.gs
function getSteamSpyAppDetails() {
// Get the appId from spreadsheet for now:
var sheet = SpreadsheetApp.getActiveSheet();
var appId = sheet.getDataRange().getCell(1, 1).getValue();
// Build query
var url = 'https://steamspy.com/api.php'
+ '?request=appdetails&appid=' + encodeURIComponent(appId);
Logger.log("Sending: \"%s\"", url);