This file contains 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; | |
public class ScriptableObjectIdAttribute : PropertyAttribute { } | |
#if UNITY_EDITOR | |
[UnityEditor.CustomPropertyDrawer(typeof(ScriptableObjectIdAttribute))] | |
public class ScriptableObjectIdDrawer : UnityEditor.PropertyDrawer | |
{ | |
private const string CHECKED_SCRIPTABLE_DUPLICATE_KEY = "CheckedScriptableDuplicate"; |
This file contains 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.Mathematics; | |
namespace Grids.Square | |
{ | |
public class PathFinding | |
{ | |
private const int MOVE_STRAIGHT_COST = 10; | |
private const int MOVE_DIAGONAL_COST = 14; | |
This file contains 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
//To get the difference C between quaternions A and B you do this: | |
C = A * Quaternion.Inverse(B); | |
//To add the difference to D you do this: | |
D = C * D; | |
///////////////// | |
//World vs local | |
//An easy way to keep track of the order of operations for quaternions is to think of it in terms of world and local rotations. | |
//When multiplying a quaternion the world rotation is on the left, and the local rotation is on the right, like this: |
This file contains 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
private List<GameObject> _debug = new List<GameObject>(); | |
private void ClearDebug() | |
{ | |
for (int i = _debug.Count - 1; i >= 0; i--) | |
{ | |
GameObject.Destroy(_debug[i]); | |
} | |
_debug.Clear(); | |
} | |
private void Debug(Vector3 pos, Color color) |
This file contains 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
private AnimationCurve GetSnapCurve(float min, float max, float snapAt, float snapAmount, WrapMode wrapMode = WrapMode.Clamp) | |
{ | |
var keyFrames = new List<Keyframe> | |
{ | |
new Keyframe(0, min), | |
new Keyframe(1, max) | |
}; | |
for (float i = snapAt; i < max; i += snapAt) | |
{ |
This file contains 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
private Vector3Int UnityCellToCube(Vector3Int cell) | |
{ | |
var yCell = cell.x; | |
var xCell = cell.y; | |
var x = yCell - (xCell - (xCell & 1)) / 2; | |
var z = xCell; | |
var y = -x - z; | |
return new Vector3Int(x, y, z); | |
} | |
private Vector3Int CubeToUnityCell(Vector3Int cube) |
This file contains 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; | |
namespace Assets.Game.Utils | |
{ | |
public class KeyValueAttribute : PropertyAttribute | |
{ | |
public readonly string PropertyName; | |
public KeyValueAttribute(string propertyName) | |
{ |
This file contains 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
private Bounds OrthographicBounds(float orthographicSize) | |
{ | |
float screenAspect = (float)Screen.width / (float)Screen.height; | |
float cameraHeight = orthographicSize * 2; | |
Bounds bounds = new Bounds( | |
transform.position, | |
new Vector3(cameraHeight * screenAspect, cameraHeight, 0)); | |
return bounds; |
This file contains 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; | |
namespace Prototype.Scripts.Contexts.Common | |
{ | |
public interface IObserver<T, Tenum> where Tenum : struct, IConvertible | |
{ | |
void OnContextChanged(T context, Tenum property); | |
void OnAttached(T context); | |
void OnDetached(); |
This file contains 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
namespace Assets.Scripts.Tools | |
{ | |
using UnityEngine; | |
using System.Collections; | |
using System.Collections.Generic; | |
[System.Serializable] | |
public class ShuffleBag<T> : IList<T> | |
{ | |
[SerializeField] private List<T> data = new(); |
NewerOlder