Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public delegate void InputKeyDelegate (KeyCode key);
public delegate void InputAxisDelegate (string name,float value);
public class InputEvents : MonoBehaviour
{
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
[RequireComponent (typeof(SpriteRenderer))]
public class SpriteAnimator : MonoBehaviour
{
public List<Sprite> frames = new List<Sprite> ();
public float fps = 15;
using UnityEngine;
using UnityEditor;
//Version 0.21 | twitter:@izm update for DK2
//Version 0.2 | s.b.Newsom Edition
//Source from http://answers.unity3d.com/questions/179775/game-window-size-from-editor-window-in-editor-mode.html
//Modified by seieibob for use at the Virtual Environment and Multimodal Interaction Lab at the University of Maine.
//Use however you'd like!
@birdinforest
birdinforest / ObliqueCameraProjection.cs
Last active September 13, 2016 04:47 — forked from mstevenson/ObliqueCameraProjection.cs
Oblique Camera Projection
using UnityEngine;
using System.Collections;
public class ObliqueCameraProjection : MonoBehaviour
{
private Matrix4x4 originalProjection;
public Vector2 slideViewport;
public Vector2 slideFrustum;
public Vector2 slideFarClip; // compound slideViewport and slideFrustum
public Vector2 skew;
@birdinforest
birdinforest / CameraLookAt.cs
Last active September 13, 2016 04:46 — forked from col000r/CameraLookAt.cs
CameraLookAt
using UnityEngine;
using System.Collections;
/// <summary>
/// Put this script on a camera, assign a target and the camera will always look at that target, smoothly following it.
/// </summary>
public class CameraLookAt : MonoBehaviour {
public Transform target; //Look at this
private Transform aimTarget;
@birdinforest
birdinforest / PlayAnimationWithoutTimeScale.cs
Created September 9, 2015 05:02
Play animation when timescale is 0
using UnityEngine;
using System.Collections;
public class PlayAnimationWithoutTimeScale : MonoBehaviour {
public Animation targetAnimation;
public string stateName;
AnimationState targetState;
float lastRealTime = 0.0f;
@birdinforest
birdinforest / convertFloatToPersentage.cs
Last active September 17, 2015 05:16
Display float numble as percentage.
var number = 44.36m;
var formatted = number.ToString("0.##\\%"); // "44.36%"
// format string @"0.##\%" works too
// using String.Format()
var sformatted = String.Format("{0:0.##\\%}", number); // "44.36%"
String.Format("Value: {0:P2}.", 0.8526) // formats as 85.26 % (varies by culture)
@birdinforest
birdinforest / GetCurrentAnimation.cs
Created September 21, 2015 08:17
Get current running animation info by animator.
AnimatorStateInfo info = upgradeAnimator.GetCurrentAnimatorStateInfo(0);
if(info.nameHash == Animator.StringToHash("Base Layer.CardUpgrading")){
Debug.Log("UICardDetailSlot::Update >> Base.CardUpgrading");
}
else if(info.nameHash == Animator.StringToHash("Base Layer.UpgradeSuccess")){
Debug.Log("UICardDetailSlot::Update >> Base.UpgradeSuccess");
}
else if(info.nameHash == Animator.StringToHash("Base Layer.New State")){
Debug.Log("UICardDetailSlot::Update >> Base.New State");
}
@birdinforest
birdinforest / WaitForAnimationsEnd.cs
Created September 21, 2015 08:21
Wait for several animation slips running to the end or wait for a specific animation clip start to run.
void TriggerAnimator (int i)
{
isEnabled = false;
upgradeAnimator.SetInteger ("stat", i);
upgradeAnimator.SetTrigger ("init");
StartCoroutine(UpgradeAnimationEnd());
}
// void Update(){
@birdinforest
birdinforest / Alert.cs
Created October 11, 2015 09:21
Event, Delegate, EventArgs in .Net Framework. A example of Observer Design Pattern in Unity3D c#
using UnityEngine;
using System.Collections;
/// <summary>
/// Observer or subscriber in Observe Design Pattern
/// It register(or subscribe) Boiled event in Heater at Main::Start(). When water boiled,
/// it receives BoiledEventArgs and Object sender. Do logic base on those received data.
/// </summary>
public class Alert : MonoBehaviour {