Skip to content

Instantly share code, notes, and snippets.

Johannes JohannesMP

Block or report user

Report or block JohannesMP

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@JohannesMP
JohannesMP / EventProxyContainer.cs
Last active Jun 2, 2019
Proxying an Action<T> event as Action<object> and Action in C#
View EventProxyContainer.cs
using System;
using System.Collections.Generic;
public struct EventProxyContainer<T>
{
private struct EventProxy
{
public Action<T> proxy;
public int count;
}
@JohannesMP
JohannesMP / EditorContextMenuCopySerialized.cs
Last active May 29, 2019
Unity Editor Context Menu Extensions
View EditorContextMenuCopySerialized.cs
using UnityEngine;
using UnityEditor;
namespace UnityEditorExtensions
{
public static class EditorContextMenuCopySerialized
{
static SerializedObject sourceValues;
static System.Type sourceType;
View UnityShadersCheatSheet.shader
Shader "Name" {
Properties {
_Name ("display name", Range (min, max)) = number
_Name ("display name", Float) = number
_Name ("display name", Int) = number
_Name ("display name", Color) = (number,number,number,number)
_Name ("display name", Vector) = (number,number,number,number)
@JohannesMP
JohannesMP / UIBlur.shader
Last active Jan 19, 2020
UI.Image Blur Shader with layering and masking support
View UIBlur.shader
Shader "Custom/UIBlur"
{
Properties
{
[Toggle(IS_BLUR_ALPHA_MASKED)] _IsAlphaMasked("Image Alpha Masks Blur", Float) = 1
[Toggle(IS_SPRITE_VISIBLE)] _IsSpriteVisible("Show Image", Float) = 1
// Internally enforced by MAX_RADIUS
_Radius("Blur Radius", Range(0, 64)) = 1
@JohannesMP
JohannesMP / LICENSE
Last active Feb 18, 2020
[Unity3D] A Reliable, user-friendly way to reference SceneAssets by script.
View LICENSE
/*******************************************************************************
* Don't Be a Jerk: The Open Source Software License.
* Adapted from: https://github.com/evantahler/Dont-be-a-Jerk
*******************************************************************************
* _I_ am the software author - JohannesMP on Github.
* _You_ are the user of this software. You might be a _we_, and that's OK!
*
* This is free, open source software. I will never charge you to use,
* license, or obtain this software. Doing so would make me a jerk.
*
@JohannesMP
JohannesMP / InspectorButtonsTest.cs
Created Jul 31, 2018 — forked from LotteMakesStuff/InspectorButtonsTest.cs
Code running pack! two property drawing scripts that make it super easy to trigger code via buttons in the inspector, and get feedback! [TestButton] draws you little buttons that call a method on your MonoBehaviour, and [ProgressBar] give you a great way to show feedback from long running methods. These are *super* helpful for things like proced…
View InspectorButtonsTest.cs
using UnityEngine;
using System.Collections;
public class InspectorButtonsTest : MonoBehaviour
{
[TestButton("Generate world", "DoProcGen", isActiveInEditor = false)]
[TestButton("Clear world", "ClearWorld", 2, isActiveInEditor = false)]
[ProgressBar(hideWhenZero = true, label = "procGenFeedback")]
public float procgenProgress = -1;
@JohannesMP
JohannesMP / EditorCoroutineRunner.cs
Created Jul 31, 2018 — forked from LotteMakesStuff/EditorCoroutineRunner.cs
Run stuff in the editor with all the convenience of co-routines! Add a status UI super easily to see readouts what your long running code is actually doing! nice~ There is a short API demo at the top of the class. This is a prefect companion for my inspector buttons https://gist.github.com/LotteMakesStuff/dd785ff49b2a5048bb60333a6a125187
View EditorCoroutineRunner.cs
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
public class EditorCoroutineRunner
{
[MenuItem("Window/Lotte's Coroutine Runner: Demo")]
@JohannesMP
JohannesMP / EditorExtensionMethods.cs
Created Jul 31, 2018 — forked from LotteMakesStuff/EditorExtensionMethods.cs
A reimplementation of the logic in the Unity Editor that draws an inspector for a component. We can use this to learn how unity actually draws the inspector. for more info see https://www.patreon.com/posts/16724128
View EditorExtensionMethods.cs
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.Reflection;
public static class EditorExtensionMethods
{
// Public reimplmentation of extention methods and helpers that are marked internal in UnityEditor.dll
@JohannesMP
JohannesMP / FileStreamReadLineExtension.cs
Last active Nov 7, 2019
A ReadLine extension for FileStream objects
View FileStreamReadLineExtension.cs
using System.IO;
using System.Collections.Generic;
public static class FileStreamReadLineExtension
{
public static string ReadLine(this FileStream fs)
{
int curChar;
// EOF - return null
if ((curChar = fs.ReadByte()) == -1)
@JohannesMP
JohannesMP / Texture2DTGAExtension.cs
Last active Nov 7, 2019
[Unity3d] Add TGA Encoding to Texture2D
View Texture2DTGAExtension.cs
using UnityEngine;
// References:
// Quick and Dirty Writeable Bitmap as TGA image: http://nokola.com/blog/post/2010/01/21/Quick-and-Dirty-Output-of-WriteableBitmap-as-TGA-Image.aspx
// TGLoader: https://gist.github.com/mikezila/10557162
// Truevision TGA Specification on Wikipedia: https://en.wikipedia.org/wiki/Truevision_TGA#Technical_details
public static class Texture2DTGAExtension
{
public enum Channel { R, G, B, A, White, Black, Gray }
You can’t perform that action at this time.