Skip to content

Instantly share code, notes, and snippets.

@gfsl
gfsl / RXDivider.cs
Created September 25, 2013 04:00 — forked from MattRix/RXDivider.cs
//Based on a brilliant idea by Matthew Wegner - https://twitter.com/mwegner/status/355147544818495488
//Code for drawing the base PropertyDrawers is from here: http://forum.unity3d.com/threads/173401-Getting-Default-SerializedProperty-Drawing-within-a-PropertyDrawer?p=1186347&viewfull=1#post1186347
//My implementation is super lazy with magic numbers everywhere! :D
#if UNITY_EDITOR
using System;
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
@gfsl
gfsl / RegexAttribute.cs
Created August 3, 2013 06:21
[Regex(regex, "Error text")] Validates a String input against a regexp. Lifted directly from here: http://blogs.unity3d.com/2012/09/07/property-drawers-in-unity-4/. Attribute in \Attributes, Drawer in \Editor.
using UnityEngine;
using UnityEditor;
public class RegexAttribute : PropertyAttribute {
public readonly string pattern;
public readonly string helpMessage;
public RegexAttribute (string pattern, string helpMessage) {
this.pattern = pattern;
@gfsl
gfsl / DynamicRangeAttribute.cs
Created August 3, 2013 06:20
[DynamicRange] Like [Range], but pulls Min and Max from introspected VarName_min and VarName_max variables. Floats and Ints. Attribute in \Attributes, Drawer in \Editor.
using UnityEngine;
using UnityEditor;
public class DynamicRangeAttribute : PropertyAttribute {
public DynamicRangeAttribute() { }
public float GetMin(SerializedProperty prop){
var minProp = prop.serializedObject.FindProperty(prop.name + "_min");
@gfsl
gfsl / PopupAttribute.cs
Created August 3, 2013 06:19
[Popup("String1", "String2", ...] Creates an Enum-style dropdown list of Strings. Attribute in \Attributes, Drawer in \Editor.
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
public class PopupAttribute : PropertyAttribute {
public List<string> optionsList;
public PopupAttribute(params string[] args) {
this.optionsList = new List<string>(args);
@gfsl
gfsl / CompactAttribute.cs
Created August 3, 2013 06:17
[Compact] PropertyDrawer. Makes Vector2, Vector3 and Quaternion display as non-foldouts, like in the default Transform inspector. Attribute in \Attributes, Drawer in \Editor.
using UnityEngine;
using UnityEditor;
public class CompactAttribute : PropertyAttribute {
public CompactAttribute() {}
}
@gfsl
gfsl / .gitignore
Last active December 20, 2015 14:19
.gitignore for Unity projects.
# Unity
Temp/
Library/
*.userprefs
*.csproj
*.sln