Skip to content

Instantly share code, notes, and snippets.

View BrodyB's full-sized avatar
🚀
[rocket-like mouth sounds]

Brody Brooks BrodyB

🚀
[rocket-like mouth sounds]
View GitHub Profile
@BrodyB
BrodyB / SceneViewControlWindow.cs
Created December 30, 2019 21:18
How to make a Unity EditorWindow take and swallow input from the Scene View!
using UnityEditor;
using UnityEngine;
/// <summary>
/// This window shows how you can listen for and consume user input events
/// from the Scene View. Super useful for making editor tools!
/// </summary>
public class SceneViewControlWindow : EditorWindow
{
/// <summary>
@BrodyB
BrodyB / SceneSwitchWindow.cs
Last active March 8, 2017 20:10
Adds a window for Unity that lets you easily switch to scenes in your build settings
using UnityEngine;
using UnityEditor;
using UnityEditor.SceneManagement;
public class SceneSwitchWindow : EditorWindow
{
[MenuItem("Window/Scene Switch Window")]
public static void ShowWindow ()
{
SceneSwitchWindow win = (SceneSwitchWindow)EditorWindow.GetWindow(typeof(SceneSwitchWindow));
@BrodyB
BrodyB / Singleton.cs
Created January 22, 2017 18:33
Reusable singleton base class for use in Unity
using UnityEngine;
using System.Collections;
/// <summary>
/// Singleton manager base class.
/// </summary>
public class Singleton<T> : MonoBehaviour where T : Singleton<T>
{
static T _instance;
public static T Instance
@BrodyB
BrodyB / GetOrAddComponent.cs
Created January 22, 2017 18:27
Unity extension method for GameObject that gets a component, or adds it if it doesn't exist.
using UnityEngine;
using System.Collections;
public static class ExtensionMethods
{
// Note: Making the parameter "this GameObject variableName" makes it an
// extension method for GameObject. Change it to Transform or whatever
// to make it a part of Transform, etc etc.
public static T GetOrAddComponent<T> (this GameObject obj) where T : Component
{