All Projects → beinteractive → Urfairy

beinteractive / Urfairy

C# extensions for Unity development

Projects that are alternatives of or similar to Urfairy

Enhancer
A collection of utilities to enhance the Unity Editor
Stars: ✭ 394 (+672.55%)
Mutual labels:  unity, unity3d, extensions
Unitystandalonefilebrowser
A native file browser for unity standalone platforms
Stars: ✭ 1,002 (+1864.71%)
Mutual labels:  unity, unity3d
Ecs Snake
Simple snake game powered by ecs framework.
Stars: ✭ 41 (-19.61%)
Mutual labels:  unity, unity3d
Kino
A collection of custom post processing effects for Unity
Stars: ✭ 1,054 (+1966.67%)
Mutual labels:  unity, unity3d
Mesh maker vr
Mesh Maker VR
Stars: ✭ 47 (-7.84%)
Mutual labels:  unity, unity3d
Grubo
Audio visual experience with Roland Groovebox MC-101 and the Unity game engine
Stars: ✭ 41 (-19.61%)
Mutual labels:  unity, unity3d
Bepinex
Unity / XNA game patcher and plugin framework
Stars: ✭ 1,001 (+1862.75%)
Mutual labels:  unity, unity3d
Unity 3mx
Load 3MX/3MXB format LOD model files generated by Bentley ContextCapture into Unity.
Stars: ✭ 38 (-25.49%)
Mutual labels:  unity, unity3d
Unity Core Project
Core Framework for Unity
Stars: ✭ 42 (-17.65%)
Mutual labels:  unity, unity3d
Soflow
A ScriptableObject oriented design SDK.
Stars: ✭ 43 (-15.69%)
Mutual labels:  unity, extensions
Unity Executionorder
A collection of attributes to control the execution order of your scripts in Unity from your source code.
Stars: ✭ 48 (-5.88%)
Mutual labels:  unity, unity3d
Scene View Bookmarks
Unity editor extension to bookmark scene views.
Stars: ✭ 40 (-21.57%)
Mutual labels:  unity, unity3d
Unitypluginwithwsl
Unity native plugin with WSL (Windows Subsystem for Linux)
Stars: ✭ 39 (-23.53%)
Mutual labels:  unity, unity3d
Mujocounity
Reproducing MuJoCo benchmarks in a modern, commercial game /physics engine (Unity + PhysX).
Stars: ✭ 47 (-7.84%)
Mutual labels:  unity, unity3d
Packedrgbmshader
32-bit packed color format with RGBM encoding for shader use
Stars: ✭ 39 (-23.53%)
Mutual labels:  unity, unity3d
Chasingplanes unity3d
A "Missiles" game replica, 2D fun mobile game about avoiding missiles while flying a plane.
Stars: ✭ 42 (-17.65%)
Mutual labels:  unity, unity3d
Factory
Factory for object creation and dependency injection. Works with normal C# apps or under Unity3d
Stars: ✭ 50 (-1.96%)
Mutual labels:  unity, unity3d
Minimumaudioplugin
Minimum implementation of a native audio plugin for Unity
Stars: ✭ 33 (-35.29%)
Mutual labels:  unity, unity3d
Easyanimation
一套操作极简轻量的Unity UGUI动画控制小工具,适用于Unity5.x以上
Stars: ✭ 35 (-31.37%)
Mutual labels:  unity, unity3d
Minject
Mono Framework Interaction / Injection Library for .NET (C++/CLI)
Stars: ✭ 42 (-17.65%)
Mutual labels:  unity, unity3d

UrFairy

UrFairy (Your fairy) is a set of useful extensions for development in Unity.

Installation

Add following url on Unity Package Manager

List of extensions

Extensions for Vector3

Extensions for Transform

Extensions for Color

Extensions for Material

Extensions for Renderer

Extensions for int

Extensions for float

Extensions for MonoBehaviour

Extensions for IEnumerable<T>

Extensions for IEnumerable<T> where T : UnityEngine.Object

Extensions for IEnumerable<T> where T : UnityEngine.Component

Extensions for List<T>

Extensions for Dictionary<K, V>

Extensions for Dictionary<K, V> where V : UnityEngine.Object

Extensions for <T>

Other

  • Rnd - PCG Random Number Generator
  • Interpolations - Time Based Interpolation Alghorithms

Editor Extensions

Extensions for Vector3

.X() / .Y() / .Z() - One Liner Modification

Returns a new value with modifying a specified component value:

var v = new Vector3(1f, 2f, 3f);
var p = v.X(10f).Y(20f);

// p = Vector3(10f, 20f, 3f)

Relative value version:

var v = new Vector3(1f, 2f, 3f);
var p = v.X(x => x + 10f).Y(y => y + 20f);

// p = Vector3(11f, 22f, 3f)

Extensions for Transform

.LocalPosition() - One Liner Modification

Set a new value with modifying a current value:

// Set localPosition.x to 10f
g.transform.LocalPosition(p => p.X(10f));

.LocalRotation() - One Liner Modification

Set a new value with modifying a current value:

// Multiply localRotation and quaternion
g.transform.LocalRotation(r => r * quaternion);

.LocalEulerAngles() - One Liner Modification

Set a new value with modifying a current value:

// Set localEulerAngles.z to 180f
g.transform.LocalEulerAngles(r => r.Z(180f));

.LocalScale() - One Liner Modification

Set a new value with modifying a current value:

// Set localScale.y to 2f
g.transform.LocalScale(s => s.Y(2f));

.Position() - One Liner Modification

Set a new value with modifying a current value:

// Set position.x to 10f
g.transform.Position(p => p.X(10f));

.Rotation() - One Liner Modification

Set a new value with modifying a current value:

// Multiply rotation and quaternion
g.transform.Rotation(r => r * quaternion);

.EulerAngles() - One Liner Modification

Set a new value with modifying a current value:

// Set eulerAngles.z to 180f
g.transform.EulerAngles(r => r.Z(180f));

.Identity() - Reset Transform

Set initial values to position, rotation and scale.

g.transform.Identity();

// Same as:
/*
g.transform.localPosition = Vector3.zero;
g.transform.localRotation = Quaternion.identity;
g.transform.localScale = Vector3.one;
*/

.Children() - Traversing Hierarchy

Enumerates children (not includes desendants):

foreach (var child in transform.Children())
{
  Debug.Log(child.gameObject.name);
}

Enumerates children (includes desendants):

foreach (var child in transform.Children(true))
{
  Debug.Log(child.gameObject.name);
}

.FindDesendant() - Finding Desendant

Returns a transform that has a specified name by searching transform hierarchy recursive.

var d = transform.FindDesendant("DesendantName");

Extensions for Color

.R() / .G() / .B() / .A() - One Liner Modification

Returns a new value with modifying a specified component value:

var c = Color.white;
var v = c.A(0.5f);

// v = Color(1f, 1f, 1f, 0.5f)

.HSV() - Manipulating HSV

Color to HSV:

var hsv = color.HSV();

Modify HSV:

hsv.s = hsv.s - 0.5f;

HSV to Color:

var col = hsv.Color();

Extensions for Material

.Color() - One Liner Modification

Set a new value with modifying existing value (this method is chainable)

m.Color("_Color", c => c.A(0.5f)).Keyword("_ALPHA_BLEND", true);

.Float() - One Liner Modification

Set a new value with modifying existing value (this method is chainable)

m.Float("_Alpha", a => a * 0.5f).Keyword("_ALPHA_BLEND", true);

.Keyword() - One Liner Modification

Set a new value with modifying existing value (this method is chainable)

m.Keyword("_ENABLE_GRAYSCALE", b => !b).Float("_TIME_SCALE", 0.5f);

Extensions for Renderer

.Material() - One Liner Modification

Set a new material with modifying existing material.

r.Material(m => m.Color("_Color", Color.red));

.Materials() - One Liner Modification

Set a new materials with modifying existing materials.

r.Materials(m => m.Keyword("_GRAYSCALE", true));

Extensions for int

.Color() - Hex to Color

Hex value to Color:

var c = 0x112233.Color();

.RandomSign() - Random Sign

Returns positive or negative value randomly

var v = 100.RandomSign(); // 100 or -100

Extensions for float

.RandomSign() - Random Sign

var v = 100f.RandomSign(); // 100f or -100f

Extensions for MonoBehaviour

.Delay() - Delay Frames

Delay one frame:

// this is MonoBehaviour
this.Delay(() =>
{
  Debug.Log("One frame after");
});

Delay specified frames:

this.Delay(3, () =>
{
  Debug.Log("Three frames after");
});

.Delay() - Delay Seconds

// this is MonoBehaviour
this.Delay(3.0f, () =>
{
  Debug.Log("Three seconds after");
});

Extensions for IEnumerable<T>

.AsEnumerable() - Object to Enumerable

Convert a single object into IEnumerable.

// e is IEnumerable<int>
var e = 100.AsEnumerable();

.CombineFirst() - Appending Object to First

Insert a specified element to first.

var list = new int[] { 1, 2, 3 };
var n = 10;
list.CombineFirst(n); // 10, 1, 2, 3

.CombineLast() - Appending Object to Last

Insert a specified element to last.

var list = new int[] { 1, 2, 3 };
var n = 10;
list.CombineLast(n); // 1, 2, 3, 10

.Sample() - Picking Random Object

// Pick a random element
var e = list.Sample();

.Shuffle() - Enumerating in Random Order

var shuffled = list.Shuffle();

.IsEmpty() - Is Collection Empty

// Whether enumerable doesn`t have any element
var b = list.IsEmpty();

.Each() - Enumerating Elements

Same as each() in Ruby.

list.Each(e =>
{
  Debug.Log(e);
});

.EachWithIndex() - Enumerating Elements with Indicies

Same as each_with_index() in Ruby.

list.EachWithIndex((e, i) =>
{
  Debug.Log($"{i} -> {e}");
});

Extensions for IEnumerable<T> where T : UnityEngine.Object

.ActiveObjects() - Enumerating Not Destroyed Elements

Enumerates objects that is not null (means has not been destroyed yet)

var activeObjects = objects.ActiveObjects();

Extensions for IEnumerable<T> where T : UnityEngine.Component

.Actives() - Enumerating Not Destroyed Elements

Enumerates objects that is not null (means has not been destroyed yet and also related GameObject has not been destroyed)

var actives = components.Actives();

Extensions for List<T>

.Shuffle() - Shuffling

list.Shuffle();

Extensions for Dictionary<K, V>

.QueryObject() - Nullsafe Querying

Calls a closure with a object in a dictionary if exists and is not null.

dictionary.QueryObject("Foo", o => Debug.Log(o));

Extensions for Dictionary<K, V> where V : UnityEngine.Object

.Query() - Nullsafe Querying

Calls a closure with a object in a dictionary if exists and is not null (means has not been destroyed).

gameObjects.Query("Player", g => Debug.Log(g));

Extensions for <T>

.Tap()

Same as tap() in Ruby.

particle.main.Tap(m => m.startColor = Color.red);

.IfJust()

Calls a closure if object is not null.

// Invoke callback if not null
callback.IfJust(f => f());

In .NET 4.6 script backend, it's recommended to use a null conditional operator.

callback?.Invoke();

.IfNothing()

Calls a closure if object is null.

Resources.Load<GameObject>("Prefab").IfNothing(Debug.Log("Prefab is not found"));

Other

Rnd

Implementation of PCG Random Number Generation.

// With specified seed
var r = new Rnd(12345U, 678910U);
// Auto seed
var r = new Rnd();

// float
r.Value;
// uint
r.Value32;
// float range
r.Range(0.5f, 1.5f);
// uint range
r.Range(50, 150);

Interpolations

Time based interpolation alghrothims from Klak.

By passing a destination value, a current value, a speed and a delta time, an interpolated new current value will be returned.

// Approaching "to" by exponential algorhithm.
transform.localPosition = Interpolations.Expo(to, transform.localPosition, 30f, Time.deltaTime);

// Approaching "to" by critically damped spring smoothing.
transform.localPosition = Interpolations.CriticallyDamped(to, transform.localPosition, 30f, Time.deltaTime);

Editor Extensions

Spacebar Hand Tool

Toggle hand tool while pressing a space key in the scene view like Photoshop.

Capture Screenshot

Capture the game view and save png image to project directory by editor menu UrFairy | Capture Screenshot.

License

Copyright 2016 Oink Games, Inc. and other contributors.

Code licensed under the MIT License: http://opensource.org/licenses/MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].