Skip to content

Instantly share code, notes, and snippets.

Avatar

Marc Jacob majstudio

View GitHub Profile
@majstudio
majstudio / Reactive.tsx
Last active Jul 16, 2018
React Component Automatic HTML Injection
View Reactive.tsx
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 Jun 28, 2018
Java-style enum in C# workaround
View EnumExtension.cs
public class EnumFieldAttribute : Attribute
{
private object value{get; set;}
public EnumFieldAttribute(object val)
{
value = val;
}
public T GetValue<T>()
@majstudio
majstudio / Example.cs
Created Jan 26, 2018
Fancy Vector3 Range in Unity Inspector
View Example.cs
using UnitEngine;
public class Example : MonoBehaviour
{
//As easy as this !
//You can adjust the slider limits in the inspector as well
public Vector3Range v3Range;
//...