Skip to content

Instantly share code, notes, and snippets.

View beardordie's full-sized avatar

Beard or Die beardordie

View GitHub Profile
@bzgeb
bzgeb / TriggerContainerEditor.cs
Created September 28, 2012 14:52
Example Drag & Drop area in a custom inspector for the Unity editor
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor (typeof(TriggerContainer))]
public class TriggerContainerEditor : Editor
{
private SerializedObject obj;
@mstevenson
mstevenson / MonoBehaviourSingleton.cs
Created December 18, 2012 04:51
Generic Singleton classes for Unity. Use MonoBehaviourSingletonPersistent for any singleton that must survive a level load.
using UnityEngine;
using System.Collections;
public class MonoBehaviourSingleton<T> : MonoBehaviour
where T : Component
{
private static T _instance;
public static T Instance {
get {
if (_instance == null) {
@raydog
raydog / bullshit.js
Last active October 9, 2024 01:04
Bullshit as a Service
var E_PREFIX_RATE = 0.25;
// All of our word lists:
var _word_lists = {
verb : [
"implement", "utilize", "integrate", "streamline", "optimize", "evolve", "transform", "embrace",
"enable", "orchestrate", "leverage", "reinvent", "aggregate", "architect", "enhance", "incentivize",
"morph", "empower", "envisioneer", "monetize", "harness", "facilitate", "seize", "disintermediate",
@cjddmut
cjddmut / DelegateWrappers.cs
Last active January 28, 2024 21:39
Wrapper struct for delegates. Helps avoid mistakes like '=' when '+=' was intended. Also checks for null automatically before invoke.
/*
* Created by C.J. Kimberlin (http://cjkimberlin.com)
*
* The MIT License (MIT)
*
* Copyright (c) 2014
*
* 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
@dogfuntom
dogfuntom / Extensions.cs
Last active February 6, 2022 12:30
NOTE that this gist is old (2015). Some stuff is obsolete. Some code I don't find wise to use anymore.
using System;
using System.Collections.Generic;
#if UNITY_EDITOR
using System.Reflection;
using System.Linq;
#endif
public static class Extensions
{
#region float
@marcteys
marcteys / ExtensionMethods.cs
Last active February 16, 2019 08:13
Extension Method Unity
using UnityEngine;
using System.Collections;
public static class ExtensionMethods {
public static Vector3 GetScreenPosition(Transform transform, Canvas canvas, Camera cam)
{
Vector3 pos;
@capnslipp
capnslipp / KeyedEventActionForwarder.cs
Last active December 5, 2019 15:47
SingleEventAction, KeyedEventActions, & Friends
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: Forwards keyed events to a KeyedEventActions component elsewhere.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Needs to be put on the same GameObject as the Mecanim Animator component or “legacy” Animation component.
/// Animation events should be configured in the Unity Editor's Animation timeline view or model import settings › Animations tab › Events disclosure (or via the scripting API, I suppose) to call “Function: Action, Parameter String: «your-decided-key-string-for-this-action»”.
/// @intended project path: Assets/Utils/EventAction/KeyedEventActionForwarder.cs
/// @interwebsouce: https://gist.github.com/capnslipp/50db1dc724514bb3db91
using System;
@Ludomancer
Ludomancer / ColliderExtensions.cs
Last active April 20, 2024 06:42
Unity Extensions
using UnityEngine;
public static class ColliderExtensions {
public static bool IsVisibleFrom(this Collider collider, Camera camera)
{
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(camera);
return GeometryUtility.TestPlanesAABB(planes, collider.bounds);
}
@capnslipp
capnslipp / GameObjectFindComponentExtension.cs
Last active June 20, 2023 13:06
Unity3D MonoBehaviourPopulateExtension & friends
/// @creator: Slipp Douglas Thompson
/// @license: Public Domain per The Unlicense. See <http://unlicense.org/>.
/// @purpose: More-flexible GO-tree searching for Components by type, configurable via `SearchExtent` enum arg.
/// @why: Because this functionality should be built-into Unity.
/// @usage: Call `this.gameObject.FindComponent<«component-type»>(«SearchExtent-type»);`.
/// @intended project path: Assets/Plugins/UnityEngine Extensions/GameObjectFindComponentExtension.cs
/// @interwebsouce: https://gist.github.com/capnslipp/ac26e38fce770b5c4594
using System;
using UnityEngine;
@nonathaj
nonathaj / CatchEvent
Last active September 8, 2023 22:30
Unity Event System for Designers
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
/*
Event class for catching Unity Message Events that are sent to the GameObject's attached components.
Events that are captured here are sent from the GameObjectHelper class
*/
[AddComponentMenu("Event/Catch Event")]