This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class DebugFileInfo { | |
Dictionary<StackFrame, string> FrameToLine; | |
Dictionary<string, string[]> PathToLines; | |
public DebugFileInfo() { | |
FrameToLine = new Dictionary<StackFrame, string>(); | |
PathToLines = new Dictionary<string, string[]>(); | |
} | |
[Conditional("DEBUG")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using Unity.Mathematics; | |
using static Unity.Mathematics.math; | |
// Credit to Inigo Quilez for these distance functions. All I did was make them work with Unity.Mathematics. | |
// https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm | |
public static class Distance | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Option { | |
public static Option<T> Some<T>(T value) => new Option<T>(value, true); | |
public static Option<T> None<T>() => new Option<T>(default, false); | |
public static bool IsNotNull<T>(T t) { | |
return Option<T>.IsValueType || t != null; | |
} | |
} | |
public struct Option<T> : IEquatable<Option<T>>, IComparable<Option<T>> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
using UnityEngine; | |
static class MissingScriptFix { | |
[MenuItem("Assets/- Fix MissingScripts Recursively on Selection")] | |
[MenuItem("GameObject/- Fix MissingScripts Recursively on Selection", false, -1)] | |
static void Fix() { | |
foreach (GameObject g in Selection.gameObjects) { | |
foreach (var t in g.GetComponentsInChildren<Transform>(true)) { | |
var i = GameObjectUtility.RemoveMonoBehavioursWithMissingScript(t.gameObject); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using UnityEngine; | |
using Random = UnityEngine.Random; | |
using Unity.Collections; | |
using Unity.Jobs; | |
[ExecuteAlways] | |
public class Avoidance : MonoBehaviour |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using MessagePack; | |
using Mk.Routines; | |
using Unity.Collections; | |
using Unity.Networking.Transport; | |
using UnityEngine; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class GrowList<T> { | |
public T[] Items; | |
public int Count; | |
public GrowList (int capacity) { | |
Items = new T[capacity]; | |
Count = 0; | |
} | |
public void Add (T item) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[DllImport("USER32.dll")] | |
public static extern short GetKeyState(int keycode); | |
var capsLocked = (GetKeyState(0x14) & 1) > 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[System.Serializable] | |
public class SimplePID { | |
public float Kp = 1f; | |
public float Ki = 0f; | |
public float Kd = .1f; | |
float _lastError; | |
float _p, _i, _d; | |
public void Reset() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const string s_Arrow0 = "iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuNWWFMmUAAACYSURBVDhPzZExDoQwDATzE4oU4QXXcgUFj+YxtETwgpMwXuFcwMFSRMVKKwzZcWzhiMg91jtg34XIntkre5EaT7yjjhI9pOD5Mw5k2X/DdUwFr3cQ7Pu23E/BiwXyWSOxrNqx+ewnsayam5OLBtbOGPUM/r93YZL4/dhpR/amwByGFBz170gNChA6w5bQQMqramBTgJ+Z3A58WuWejPCaHQAAAABJRU5ErkJggg=="; | |
static Texture2D Base64ToTexture (string base64) { | |
Texture2D t = new Texture2D (1, 1); | |
t.hideFlags = HideFlags.HideAndDontSave; | |
t.LoadImage (System.Convert.FromBase64String (base64)); | |
return t; | |
} |