Skip to content

Instantly share code, notes, and snippets.

View sebtoun's full-sized avatar

Sebtoun sebtoun

  • Montpellier, FRANCE
View GitHub Profile
@sebtoun
sebtoun / Easing.cs
Last active January 28, 2022 14:18 — forked from cjddmut/EasingFunctions.cs
Easing Functions for Unity with support for Inspector with animation preview and Animation Curve for custom easing
using System;
using UnityEngine;
[ Serializable ]
public class Easing
{
public enum EasingType
{
Curve,
Function
@sebtoun
sebtoun / UniformPoissonDiskSampler.cs
Created March 10, 2018 09:03
Poisson Disk Sampler
// Adapted from java source by Herman Tulleken
// http://www.luma.co.za/labs/2008/02/27/poisson-disk-sampling/
// The algorithm is from the "Fast Poisson Disk Sampling in Arbitrary Dimensions" paper by Robert Bridson
// http://www.cs.ubc.ca/~rbridson/docs/bridson-siggraph07-poissondisk.pdf
using System;
using System.Collections.Generic;
using UnityEngine;
using Random = System.Random;
using UnityEngine;
/// <summary>
/// Attribute to select a single layer.
/// </summary>
public class LayerAttribute : PropertyAttribute
{
}
@sebtoun
sebtoun / CameraFade.cs
Last active March 19, 2018 20:08
Camera Fade (depends on GameLogic Extension Singleton<> class) for Unity
using System;
using Gamelogic.Extensions;
using UnityEngine;
public class CameraFade : Singleton<CameraFade>
{
private void Awake()
{
if ( Instance.FadeTexture != null ) return;
Instance.FadeTexture = new Texture2D( 1, 1 );
@sebtoun
sebtoun / ShakeBehaviour.cs
Last active August 4, 2018 08:29
Shake Behaviour for Unity
#define USE_GAMELOGIC_EXTENSION
#if USE_GAMELOGIC_EXTENSION
using Gamelogic.Extensions;
#endif
using UnityEngine;
#if USE_GAMELOGIC_EXTENSION
public class ShakeBehaviour : GLMonoBehaviour
@sebtoun
sebtoun / StretchWithVelocity.cs
Last active April 14, 2022 16:51
Stretch With Velocity Animation for Unity
using UnityEngine;
public class StretchWithVelocity : MonoBehaviour
{
public float MaxVelocity = 10;
public float MaxSpeedStretch = 0.5f;
public bool CompensatePosition = true;
public float MinVelocity = 0.1f;
public float Smoothing = 0.1f;
using UnityEngine;
using System;
//Original version of the ConditionalHideAttribute created by Brecht Lecluyse (www.brechtos.com)
//Modified by: -
[ AttributeUsage( AttributeTargets.Field ) ]
public class ConditionalHideAttribute : PropertyAttribute
{
public readonly string ConditionalSourceField;
@sebtoun
sebtoun / CoroutineExtensions.cs
Last active April 12, 2018 08:14
Unity's coroutines extensions
using System;
using System.Collections;
using UnityEngine;
public static class CoroutineExtensions
{
public static Coroutine Then( this Coroutine self, Action action )
{
return DefaultCoroutineHost.Instance.StartCoroutine( ChainWithAction( self, action ) );
}
@sebtoun
sebtoun / CoroutineEvent.cs
Created April 12, 2018 16:33
C# events like object for Unity's coroutine
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CoroutineEvent<T1, T2>
{
public delegate IEnumerator CoroutineDelegate( T1 parameter1, T2 parameter2 );
private readonly List<CoroutineDelegate> _eventHandlers = new List<CoroutineDelegate>();
private int _runningCoroutinesCount;
@sebtoun
sebtoun / SimpleStateMachine.cs
Created July 20, 2018 15:51
Simple State machine for unity
using System;
using System.Collections;
using System.Collections.Generic;
#if USE_GAMELOGIC_EXTENSIONS
using Gamelogic.Extensions;
#endif
using UnityEngine;
/// <summary>
/// A lightweight state machine that support either update or coroutine pattern for states update.