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 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
| 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 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; | |
| // PagedMap is a memory-efficient map for large ranges of integer keys. | |
| public class PagedIntegerMap | |
| { | |
| private const int PageBits = 10; // 1024 entries per page | |
| private const int PageSize = 1 << PageBits; | |
| private const int PageMask = PageSize - 1; |
OlderNewer