Skip to content

Instantly share code, notes, and snippets.

@SaffronCR
SaffronCR / FSMSystem.cs
Last active October 30, 2023 02:04
[C#, Unity] Lightweight State Machine based on Stateless and this great example: http://wiki.unity3d.com/index.php?title=Finite_State_Machine
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// Place the labels for the Triggers in this enum.
/// Don't change the first label, NullTrigger as FSMSystem class uses it.
/// </summary>
public enum Trigger
{
NullTrigger = 0, // Use this trigger to represent a non-existing trigger in your system.
@SaffronCR
SaffronCR / MathUtil.cs
Created May 22, 2017 14:24
[C#, Unity] Math Helper Class.
using System.Runtime.InteropServices;
using UnityEngine;
public class MathUtil
{
// Evil floating point bit level hacking.
[StructLayout(LayoutKind.Explicit)]
private struct FloatIntUnion
{
[FieldOffset(0)]