Skip to content

Instantly share code, notes, and snippets.

Avatar

David Evans phosphoer

View GitHub Profile
@phosphoer
phosphoer / AnimatorCallbacks.cs
Created Oct 26, 2020
Unity Animator Callbacks
View AnimatorCallbacks.cs
using UnityEngine;
using System.Collections.Generic;
// Provides an interface to register callbacks for Animation Events, given they are named 'OnAnimEvent'
// with a string parameter defining the actual event name.
[RequireComponent(typeof(Animator))]
public class AnimatorCallbacks : MonoBehaviour
{
private Dictionary<string, System.Action> _callbacks = new Dictionary<string, System.Action>();
View CellShadedOutline.shader
Shader "Custom/CellShadedOutline"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_OutlineColor ("Outline Color", Color) = (1,1,1,1)
_OutlineThickness ("Outline Thickness", float) = 0.1
_MainTex ("Texture", 2D) = "white" {}
_LightRamp ("Light Ramp", 2D) = "white" {}
_VertexColorWeight ("Vertex Color Weight", float) = 1
@phosphoer
phosphoer / EditorSelectionHistory.cs
Last active Nov 1, 2020
Selection history for Unity Editor
View EditorSelectionHistory.cs
// The MIT License (MIT)
// Copyright (c) 2020 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
@phosphoer
phosphoer / BlendTreeEditorExtensions.cs
Created Oct 25, 2019
Useful utilities for working with blend trees in Unity, drop this in an Editor/ folder.
View BlendTreeEditorExtensions.cs
using UnityEditor;
using UnityEditor.Animations;
public class BlendTreeEditorExtensions
{
private static BlendTree copiedBlendTree;
[MenuItem("Assets/Copy Blend Tree")]
private static void CopyBlendTree()
{
View ControllerIconMapDefinition.cs
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
[CreateAssetMenu(fileName = "new-controller-icon-mapping", menuName = "Controller Icon Mapping")]
public class ControllerIconMapDefinition : ScriptableObject
{
[SerializeField]
private InputIconMapDefinition gamepadMap = null;
@phosphoer
phosphoer / TexturePackDefinition.cs
Last active Jun 21, 2020
TexturePackDefinition.cs
View TexturePackDefinition.cs
// The MIT License (MIT)
// Copyright (c) 2019 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
View Fish.shader
Shader "Custom/Fish"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Texture", 2D) = "white" {}
_LightRamp ("Light Ramp", 2D) = "white" {}
_VertexColorWeight ("Vertex Color Weight", float) = 1
_FishLength ("Fish Length", float) = 1
_FishFrontOffset ("Fish Front Offset", float) = 0
View CurveExample.cs
using UnityEngine;
using MinMaxCurve = UnityEngine.ParticleSystem.MinMaxCurve;
public class CurveExample : MonoBehaviour
{
[Range(0, 10)]
public int CurrentLevel = 0;
public int LevelCount = 10;
@phosphoer
phosphoer / PostFXBlend.cs
Created Mar 28, 2018
Unity PostFX Profile Blending
View PostFXBlend.cs
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using System.Collections;
public abstract class PostFXBlend : MonoBehaviour
{
public float FadeInTime = 1.0f;
public float FadeOutTime = 1.0f;
public float BlendWeightDebug;
@phosphoer
phosphoer / Mathfx.cs
Last active Nov 1, 2020
My own version of the Unity Wiki Mathfx
View Mathfx.cs
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
You can’t perform that action at this time.