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; | |
public enum Interaction | |
{ | |
Idle, | |
MouseDownOnItem, | |
DragItemBegin, | |
MouseDownOnSelectedItem, | |
DragItemUpdate, |
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; | |
public abstract class StateMachine<T> where T: struct, Enum | |
{ | |
public T state { get; protected set; } | |
public Action<T, T> OnStateChanged; | |
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; | |
public class RectBoundsHandle | |
{ | |
public float HandleSize = 10f; | |
public float CornerGrabRadius = 12f; | |
public Color FillColor = new Color(0, 1, 1, 0.1f); | |
public Color OutlineColor = Color.cyan; | |
public Color HandleColor = Color.blue; |
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
// Usage: schedule.Watch(Func<T> getValue, Action<T> valueWasChanged) | |
// Eg: visualElement.schedule.Watch(() => myInstance.someProperty, i => visualElement.text = $"Value:{i}"); | |
public class Observer<T> | |
{ | |
private readonly Func<T> _getValue; | |
private readonly Action<T> _onChange; | |
private T _lastValue; | |
public Observer(Func<T> getValue, Action<T> onChange) |
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 UnityEngine; | |
[Serializable] | |
public class Tree<T> | |
{ | |
[Serializable] | |
private struct Node | |
{ |
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.Reflection; | |
using System.Reflection.Emit; | |
using System; | |
using System.Collections.Generic; | |
namespace GetSetGenerator | |
{ | |
public interface IGetSet<TInstance, TField> | |
{ | |
TField Get(TInstance 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
using System; | |
using System.Collections.Generic; | |
public static class ByteArrayPool | |
{ | |
private static Queue<WeakReference> pool = new Queue<WeakReference>(); | |
public static ArraySegment<byte> Take(int count) | |
{ | |
// if there are any items to check in the pool |
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.Collections.Generic; | |
using Unity.Jobs; | |
using UnityEngine; | |
static internal class ComponentBatch<T, U, V> | |
where T : MonoBehaviourComponent<T, U, V> where U : MonoBehaviourSystem<T, U, V> | |
where V: struct, IJobParallelFor | |
{ | |
internal static Queue<T> components = new Queue<T>(); | |
internal static Queue<T> newComponents = new Queue<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 System; | |
using UnityEngine; | |
using System.Collections.Generic; | |
using System.Runtime.InteropServices; | |
using UnityEngine.Assertions; | |
[StructLayout(LayoutKind.Explicit)] | |
struct SpatialKey | |
{ | |
[FieldOffset(0)] public Int32 xz; |
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; | |
public class Logger | |
{ | |
string header; | |
public bool enabled = true; | |
public Logger(string name, string color) | |
{ | |
header = $"<color={color}>{name}:</color>"; | |
} |
NewerOlder