Skip to content

Instantly share code, notes, and snippets.

View beardordie's full-sized avatar

Beard or Die beardordie

View GitHub Profile
@beardordie
beardordie / DebugInputPressed.cs
Created November 6, 2019 19:35
Unity Component for debug identification of pressed input, including keyboard, mouse, connected controllers
using UnityEngine;
/// <summary>
/// Put this monobehaviour on any object in the Scene. Now any PRESSED keyboard key or mouse button or scrollwheel.y or joystick button (up to four axes) will Debug Log for identification.
/// </summary>
public class DebugInputPressed : MonoBehaviour
{
public bool checkAxes = false;
[Tooltip("For XboxOne Windows 10 Right Trigger: Set up in Input Manager as Joystick 1, type: Axis, Axis: 3rd axis")]
@beardordie
beardordie / DebugLogCorgiEvents.cs
Created November 7, 2019 03:37
Corgi Engine Events - Debug Tool: Use the Console to easily determine which events Corgi Engine is firing, filtered by type. Tested with Corgi Engine version 6.1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.CorgiEngine;
using MoreMountains.Tools;
using System.Text;
using MoreMountains.InventoryEngine;
public class DebugLogCorgiEvents : MonoBehaviour,
MMEventListener<MMGameEvent>,
@beardordie
beardordie / CharacterJetpackNoFlip.cs
Last active February 20, 2020 14:17
Corgi Engine custom extension to the Jetpack ability that fixes three bugs with the built-in version. Tested with version 6.1. Usage: remove or disable the CharacterJetpack component and replace it with this
using MoreMountains.Tools;
using UnityEngine;
namespace MoreMountains.CorgiEngine
{
/// <summary>
/// Add this component to a character and it'll be able to jetpack
/// NOTE: This custom extended version doesn't perform a horizontal flip of the jetpack emission point
/// because that flip already happens on the parent for some PlayableCharacter prefabs
/// NOTE: It also prevents a bug in v6.1 that causes Jetpack refuel sounds and particles to play
@beardordie
beardordie / CorgiEngineSoundExtendedFeedback
Created November 7, 2019 08:54
Corgi Engine custom Feedbacks type, same as "Corgi Engine Sound" but allows you to specify an AudioSource. Useful if you want to share an audiosource for a Start and Stop sound, such as for Jetpack ability, so the looping jetpacking sound is replaced by the one-time jetpack-stopped sound.
using UnityEngine;
using System.Collections;
using MoreMountains.Tools;
using System;
using System.Collections.Generic;
using MoreMountains.Feedbacks;
using UnityEngine.Audio;
namespace MoreMountains.CorgiEngine
{
@beardordie
beardordie / MMGameEventToUnityEvent.cs
Created November 7, 2019 08:58
Corgi Engine simple component to subscribe to a MMGameEvent by string and trigger a UnityEvent with no parameters. You may also use this as a template for hooking into other event types included with the Corgi Engine
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
using UnityEngine.Events;
public class MMGameEventToUnityEvent : MonoBehaviour, MMEventListener<MMGameEvent>
{
public string MMGameEventName = "";
public UnityEvent events;
@beardordie
beardordie / PreventShootingDuringMovementStates.cs
Created November 8, 2019 03:32
Corgi Engine character component to prevent weapon from shooting during specified MovementStates, such as WallClinging, Crouching, LookingUp, LedgeHanging, etc
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MoreMountains.Tools;
namespace MoreMountains.CorgiEngine
{
/// <summary>
/// Add this class to a character so it is prevented from shooting while in a specified MovementState,
/// such as WallClinging, Crouching, LookingUp, LedgeHanging, etc
@beardordie
beardordie / CustomSettingsMenu.cs
Created March 15, 2020 19:31
Add your own submenu in Unity's Preferences window with various boolean settings that other Editor scripts can make use of
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
namespace CustomSettingsMenuNamespace
{
[InitializeOnLoad]
public class NewCustomSettingsHandler
@beardordie
beardordie / SelectionBase.cs
Created March 24, 2020 01:43
Unity - If you want a root GameObject to be selected when you click on a child object such as a mesh, put this MonoBehaviour on the root
using UnityEngine;
[SelectionBase]
public class SelectionBase : MonoBehaviour {
}
@beardordie
beardordie / ScreenFader.cs
Created March 24, 2020 01:50
Example from Unity's Gamekit2D to do fade to Black, Loading, and GameOver screens using multiple CanvasGroups, appearing on top and blocking raycasts beneath
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
namespace Gamekit2D
{
public class ScreenFader : MonoBehaviour
{
public enum FadeType
{
@beardordie
beardordie / CheatCodeDetector.cs
Created March 24, 2020 03:27
A simple Unity Cheat Code system, optionally play a sound when a cheat code is used. Add cheats in the Inspector with UnityEvent, or through code using RegisterCheat method
using UnityEngine;
using System.Collections.Generic;
using System;
using UnityEngine.Events;
[RequireComponent(typeof(AudioSource))]
public class CheatCodeDetector : MonoBehaviour
{
[SerializeField] private List<Cheat> cheats = new List<Cheat>();