Skip to content

Instantly share code, notes, and snippets.

rodamn / !ComponentEmitter.Description
Last active April 26, 2017 04:34
Unity 3D Component Emitter - A Lightweight system of C# generics that support building and executing complex hierarchies within Unity's Editor
A common design challenge in building a game is that you, the game developer/
designer, need to have a hierarchy of Things that need to be displayed or to do
something. It could be a series of enemies that appear, events that occur over
time, cool items pulled from a loot table, or various sets of AI actions, some
of which might be semi-random, while others are serial. Anyway, we would like to
do cool stuff.
Having advanced beyond the naive approach of coding these directly into our
game, we would like the flexibility to quickly drag and drop new configurations,
adding or removing these Things from our gameplay. We would even like to modify
the hierarchy at run-time, allowing us to dynamically on-demand load our
rodamn / CompactGuiAttribute.cs
Last active August 5, 2017 03:43 — forked from gfsl/CompactAttribute.cs
Unity 3D Compact GUI Attribute for Vectors and Quaternions.
using UnityEngine;
public class CompactGuiAttribute : PropertyAttribute {}
rodamn / description.markdown
Last active September 11, 2016 21:23 — forked from runemadsen/description.markdown
Reverse polymorphic associations in Rails

Rails 4 Composite Model using Polymorphism

WARNING: This is my attempt to brain-storm/puzzle this out. It may not (and likely does not) work out of the box. Feel free to add, patch, and comment. For now, it is untested so use this at your own peril.

In Rails, a polymorphic association allows a model with a foreign key to switch (select) between various other models that can be its owner through a has_one or has_many relationship. At the database level, this is underpinned by storing a foreign key — an id, the same as any other foreign key — except here, the table for that foreign key is dynamic and is specified in an additional column, type.

So with this in mind, the goal here is to use rails polymorphism to achieve a