Skip to content

Instantly share code, notes, and snippets.

@majstudio
majstudio / Example.cs
Created January 26, 2018 04:50
Fancy Vector3 Range in Unity Inspector
using UnitEngine;
public class Example : MonoBehaviour
{
//As easy as this !
//You can adjust the slider limits in the inspector as well
public Vector3Range v3Range;
//...
@majstudio
majstudio / Reactive.tsx
Last active July 16, 2018 18:13
React Component Automatic HTML Injection
import * as React from 'react'
import * as ReactDOM from 'react-dom'
type ReactComp<T> = React.StatelessComponent<T> | React.ComponentClass<T>
const enum RenderType { Replace, Append }
/// Used to automagically inject React component for custom tags in a HTML file
// Where P is your component Prop type, C is your react component type
export function injectCustomElement<P, C extends ReactComp<P>>(tagName: string, propType: new () => P, comp: C, renderType = RenderType.Replace): React.Component[]
{
@majstudio
majstudio / EnumExtension.cs
Created June 28, 2018 15:21
Java-style enum in C# workaround
public class EnumFieldAttribute : Attribute
{
private object value{get; set;}
public EnumFieldAttribute(object val)
{
value = val;
}
public T GetValue<T>()