Skip to content

Instantly share code, notes, and snippets.

🛠
Making stuff!

Keenan Woodall keenanwoodall

🛠
Making stuff!
Block or report user

Report or block keenanwoodall

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
@keenanwoodall
keenanwoodall / BoundedBendDeformer.cs
Created Dec 10, 2019
A modified bend deformer that only modifies vertices within a defined bounding box
View BoundedBendDeformer.cs
using UnityEngine;
using Unity.Jobs;
using Unity.Burst;
using Unity.Collections;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using Beans.Unity.Mathematics;
namespace Deform
{
@keenanwoodall
keenanwoodall / UnityObjectOperatorOverloadTest.cs
Last active Nov 9, 2019
Test if the equality operator for anything that derives from Unity.Object is still overridden. Just put the script in your project and press play in any scene to test.
View UnityObjectOperatorOverloadTest.cs
// read this article for more info: https://blogs.unity3d.com/2014/05/16/custom-operator-should-we-keep-it/
using UnityEngine;
public class UnityObjectOperatorOverloadTest : MonoBehaviour
{
[RuntimeInitializeOnLoadMethod]
public static void Test()
{
var gameObject = new GameObject("UnityEngine.Object Operator Overload Test");
View Editor Scripting - No Scopes vs Scopes.md

I think using scopes greatly improves readability. Here's an example of converting a larger section of code. The indenting makes it immediately clear when a scopes begins and ends. Both snippets of code draw the exact same controls.

Before:

EditorGUILayout.BeginVertical("box");
disable = EditorGUILayout.Toggle("Disable Sliders", disable);
indent = EditorGUILayout.IntSlider("Indent Sliders", indent, 1, 4);
@keenanwoodall
keenanwoodall / PrefabUtilityMenuItems.cs
Created Aug 3, 2019
Makes creating more than one prefab at once possible
View PrefabUtilityMenuItems.cs
using UnityEngine;
using UnityEditor;
public static class PrefabUtilityMenuItems
{
[MenuItem("Tools/Prefab Utility/Create Prefabs From Selection")]
public static void CreateFromSelection()
{
var selections = Selection.gameObjects;
if (selections == null || selections.Length == 0)
@keenanwoodall
keenanwoodall / Automated Deformation Test
Created Aug 1, 2019
A test for deforming meshes without using a deformable component
View Automated Deformation Test
using UnityEngine;
using UnityEditor;
using Unity.Jobs;
using Deform;
public class AutomatedDeformationTestWindow : EditorWindow
{
private Mesh mesh;
[MenuItem("Tools/Automated Deformation Window")]
@keenanwoodall
keenanwoodall / CustomFloatField.cs
Last active Mar 13, 2019
A helper class that lets you draw a float field with more control. You can define a rect where the value is drawn/set and another rect where you can drag to scroll the value.
View CustomFloatField.cs
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
public static class CustomFloatField
{
private static readonly int Hint = "EditorTextField".GetHashCode ();
private static readonly Type EditorGUIType = typeof (EditorGUI);
private static readonly Type RecycledTextEditorType = Assembly.GetAssembly (EditorGUIType).GetType ("UnityEditor.EditorGUI+RecycledTextEditor");
@keenanwoodall
keenanwoodall / Transform Rotation GUI
Last active Mar 5, 2019
A helper class for drawing a transform's rotation field in the same way as the Transform editor in Unity.
View Transform Rotation GUI
using System;
using System.Reflection;
using UnityEngine;
using UnityEditor;
/// <summary>
/// Abstracts the reflection required to use the internal TransformRotationGUI class.
/// </summary>
public class TransformRotationGUI
{
@keenanwoodall
keenanwoodall / CurveTest
Created Dec 29, 2018
Example script showing how to deform a mesh using a NativeCurve.
View CurveTest
using UnityEngine;
using Unity.Jobs;
using Unity.Burst;
using Unity.Collections;
public class CurveTest : MonoBehaviour
{
public AnimationCurve curve;
private Mesh mesh;
@keenanwoodall
keenanwoodall / NativeCurve
Last active Dec 31, 2019
A struct that makes using animation curves with the job system easy.
View NativeCurve
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
using Unity.Collections;
using static Unity.Mathematics.math;
public struct NativeCurve : IDisposable
{
public bool IsCreated => values.IsCreated;
You can’t perform that action at this time.