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
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 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 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
public class Subject<T> : IDisposable { | |
Action<T> _action; | |
bool _disposed; | |
public void Subscribe(Action<T> a) { | |
Asr.IsFalse(_disposed); | |
_action += a; | |
} | |
public void Publish(T msg) { |
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 unsafe class BinaryWriterExtensions { | |
public static void Write(this IBinaryWriter writer, byte value) { | |
writer.WriteBytes(&value, 1); | |
} | |
public static void Write(this IBinaryWriter writer, int value) { | |
writer.WriteBytes(&value, sizeof(int)); | |
} | |
public static void Write(this IBinaryWriter writer, ulong value) { |
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.Runtime.CompilerServices; | |
using Leopotam.Ecs; | |
public static class EcsWorldExt | |
{ | |
[MethodImpl(MethodImplOptions.AggressiveInlining)] | |
public static bool InFilter(this EcsEntity e, EcsFilter f) | |
{ | |
ref var entityData = ref e.Owner.GetEntityData(e); |
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
#if UNITY_EDITOR_WIN | |
using System; | |
using UnityEngine; | |
using UnityEditor; | |
using System.Diagnostics; | |
class CreateSymlinkProject { | |
[MenuItem("Tools/Create Symlink Project")] | |
static void SymlinkProject() { | |
var src = Application.dataPath.Replace("/Assets", string.Empty); |
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.IO; | |
using UnityEngine; | |
namespace Asset_Cleaner.Serialization { | |
public static class PersistenceUtils { | |
public static void Load(ref Config result) { | |
var serializable = Deserialize(); | |
AufSerializableData.OnDeserialize(in serializable, ref result); | |
} |
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
static void CatmullRom(List<float3> input, List<float3> result) { | |
result.Clear(); | |
if (input.Count <= 2) { | |
foreach (var p in input) result.Add(p); | |
return; | |
} | |
var count = input.Count; | |
// first curve | |
CatmullRom(input[0], input[0], input[1], input[2]); |