Skip to content

Instantly share code, notes, and snippets.

@EddieCameron
EddieCameron / CanvasMesh.cs
Last active Feb 24, 2021 — forked from YclepticStudios/CanvasMesh.cs
Unity script for rendering a mesh inside the canvas UI.
View CanvasMesh.cs
/**
* ============================================================================
* MIT License
*
* Copyright (c) 2017 Eric Phillips
*
* 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,
@EddieCameron
EddieCameron / SceneViewShaderKeyword.cs
Last active Nov 26, 2020
Add to your scene to have a shader keyword enabled/disabled only for the scene view. Use for debug materials, scene visualisations
View SceneViewShaderKeyword.cs
/* SceneViewShaderKeyword.cs
* © Eddie Cameron 2020
* ----------------------------
*/
using System;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
@EddieCameron
EddieCameron / GroupSelected.cs
Last active Oct 13, 2020
Unity Group Selected GameObjects Command
View GroupSelected.cs
/* GroupSelected.cs
* © Eddie Cameron 2020
* ----------------------------
*/
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Groups all selected scene transforms under a single parent.
@EddieCameron
EddieCameron / ReorderableList.cs
Last active Mar 24, 2021
ReorderableList Property Drawer
View ReorderableList.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// In Unity pre 2020, each different type you want to make a list from needs its own subclass, like UnityEvents.
/// eg :
/// [Serializable] public class IntReorderableList : ReorderableList<int> {}
[Serializable]
View KeyCode To string
/// <summary>
/// Convert a KeyCode into the string that Unity uses in GetKeyString
/// (ToString returns a different value -_-)
/// </summary>
/// <param name="kc"></param>
/// <returns></returns>
public static string KeycodeToKeyString( KeyCode kc ) {
switch ( kc ) {
// numerals
case KeyCode.Alpha0:
@EddieCameron
EddieCameron / EdgeDetect.cs
Created Sep 3, 2017
EdgeDetection in new Unity Postprocessing Stack
View EdgeDetect.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
[Serializable]
[PostProcess( typeof( EdgeDetectRenderer ), PostProcessEvent.BeforeStack, "Custom/EdgeDetectNormals" )]
public sealed class EdgeDetect : PostProcessEffectSettings {
public enum EdgeDetectMode {
View SmoothSwitcher.cs
/* SmoothSwitcher.cs
* Copyright Eddie Cameron 2015
* ----------------------------
* When you want some value to switch slowly between on and off without all that fuss about whether it's already changing or whatnot
* (eg: light dimmer switch, audio fade in/out, zoom)
* -----------------------------
* Can be added to an object at runtime, with SmoothSwitcher.SetupSmoothSwitcher(...)
* Otherwise, make sure to set the SmoothSwitcher's onAmountSet event in the inspector, which will be called whenever the 'on amount' changes
* (when setting an event listener method, make sure to choose a 'dynamic' method in the selection menu, otherwise it'll just call whatever number is in the box)
* -----------------------------