Skip to content

Instantly share code, notes, and snippets.

@immrsv
immrsv / DynamicTag.cs
Created November 3, 2020 01:45
Custom multi-tag for Unity
[DisallowMultipleComponent]
public class DynamicTag : MonoBehaviour
{
private static Dictionary<string, List<GameObject>> Collection = new Dictionary<string, List<GameObject>>();
private static string KeyFromTag(DynamicTagItem tag) {
return tag.name;
}
public static void Register(DynamicTagItem tag, GameObject item) {
@immrsv
immrsv / StateMachineEventReceiver.cs
Last active August 30, 2019 08:25
Unity Animator as a scene controller
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using Sirenix.OdinInspector;
// Add this to the object that holds the Animator
public class StateMachineEventReceiver : MonoBehaviour
{
[System.Serializable]
@immrsv
immrsv / UnityLayerDrawer.cs
Created May 20, 2018 04:31
Display Unity Layers as drop-down in Inspector
using UnityEngine;
using System.Collections;
using UnityEditor;
// This defines how the TagList should be drawn
// in the inspector, when inspecting a GameObject with
// a MonoBehaviour which uses the TagList attribute
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
/// <summary>
@immrsv
immrsv / EntityStats.cs
Created August 4, 2017 02:02
Indexing compound stat values
#region " Stat collection "
[System.Serializable]
public class Stat {
public float Base;
public float Modifier;
public float Value { get { return Base + Base * Modifier; } }
}