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
// Adds a menu item for easy creation of your ScriptableObject types | |
// Usage: Right click in project view -> Create -> ScriptableObject... -> Select your type | |
// It will land in the root of your assets folder with the same name as your class | |
// Freya Holmér - [email protected] | |
using UnityEngine; | |
using UnityEditor; | |
using System.Reflection; | |
using System.Linq; | |
using System.IO; |
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; | |
public enum TransformType { Point, Direction, Vector }; | |
public static class TransformExtensions { | |
public static Vector3 WorldToLocal( this Transform tf, Vector3 v3, TransformType type = TransformType.Point ) { | |
if( type == TransformType.Point ) | |
return tf.InverseTransformPoint( v3 ); | |
else if( type == TransformType.Direction ) |
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; | |
using System.Collections.Generic; | |
public static class GameObjectExtensions { | |
public static T[] GetComponentsInChildrenOfAsset<T>( this GameObject go ) where T : Component { | |
List<Transform> tfs = new List<Transform>(); | |
CollectChildren( tfs, go.transform ); | |
List<T> all = new List<T>(); | |
for (int i = 0; i < tfs.Count; i++) |
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
///////////////////////////////////////////////////////////////////////////// | |
// int2 is similar to Vector2, but with integers instead of floats | |
// Useful for various grid related things. | |
// | |
// - Swizzle operators xx/xy/yx/yy | |
// - Extended arithmetic operators similar to shader data types | |
// A few examples: | |
// int2(8,4) / int2(2,4) -> int2(4,1) | |
// 16 / int2(2,4) -> int2(8,4) | |
// int2(2,3) * int2(4,5) -> int2(8,15) |
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; | |
using System.Linq; | |
[RequireComponent(typeof(Rigidbody))] | |
public class RigidbodyMassCalculator : MonoBehaviour { | |
public float density = 1f; | |
public bool recalculateOnAwake = true; | |
Rigidbody rb; |
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
Shader "Custom/Circular Circles" { | |
Properties { | |
_CircleCount ("Circle Count", Float ) = 8 | |
_CircleRadius ("Circle Radius", Range(0, 1)) = 0.18 | |
_CircleSharpness ("Circle Sharpness", Range(0, 0.999)) = 0.95 | |
_GroupRadius("Group Radius", Range(0, 1)) = 0.6 | |
} | |
SubShader { | |
Pass { | |
CGPROGRAM |
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 UnityEditor; | |
using System; | |
public static class IMGUIDebugger { | |
static Type type = Type.GetType( "UnityEditor.GUIViewDebuggerWindow,UnityEditor" ); | |
[MenuItem( "Window/IMGUI Debugger" )] | |
public static void Open() => EditorWindow.GetWindow( type ).Show(); | |
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; | |
public class LengthTable { | |
public float[] distances; | |
int SmpCount => distances.Length; | |
float TotalLength => distances[SmpCount - 1]; | |
public LengthTable( OrientedCubicBezier3D bezier, int precision = 16 ) { | |
distances = new float[precision]; |
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
public class MathWishlist { | |
// Mathf | |
public const float TAU = 6.28318530717959f; | |
public static float Frac( float x ) => x - Mathf.Floor( x ); | |
public static float Smooth01(float x) => x * x * (3 - 2 * x); | |
public static float InverseLerpUnclamped( float a, float b, float value) => (value - a) / (b - a); | |
public static float Remap(float iMin, float iMax, float oMin, float oMax, float value) { | |
float t = Mathf.InverseLerp(iMin, iMax, value); | |
return Mathf.Lerp( oMin, oMax, t ); |
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; | |
[RequireComponent( typeof(Camera) )] | |
public class FlyCamera : MonoBehaviour { | |
public float acceleration = 50; // how fast you accelerate | |
public float accSprintMultiplier = 4; // how much faster you go when "sprinting" | |
public float lookSensitivity = 1; // mouse look sensitivity | |
public float dampingCoefficient = 5; // how quickly you break to a halt after you stop your input | |
public bool focusOnEnable = true; // whether or not to focus and lock cursor immediately on enable |
OlderNewer