Skip to content

Instantly share code, notes, and snippets.

@bellicapax
bellicapax / SerializableDictionary.cs
Last active February 23, 2023 21:35
Serializable Dictionary base for Unity
using UnityEngine;
namespace System.Collections.Generic
{
[Serializable]
public abstract class SerializableDictionary<TKey, TValue> : Dictionary<TKey, TValue>, ISerializationCallbackReceiver
{
protected abstract List<SerializableKeyValuePair<TKey, TValue>> _keyValuePairs { get; set; }
// save the dictionary to lists
@bellicapax
bellicapax / StringIntDictionary.cs
Created February 27, 2018 01:07
An example implementation of a serializable Dictionary<string, int>
using UnityEngine;
namespace System.Collections.Generic
{
[Serializable]
public class StringIntTuple : SerializableKeyValuePair<string, int>
{
public StringIntTuple(string item1, int item2) : base(item1, item2) { }
}
@bellicapax
bellicapax / SerializedPropertyExtensions.cs
Created August 10, 2018 17:06
This Editor extension class that I extended to include ScriptableObjects allows you to get and set fields on a Component or ScriptableObject that is contained within a SerializedProperty
// --------------------------------------------------------------------------------------------------------------------
// <author>
// HiddenMonk
// http://answers.unity3d.com/users/496850/hiddenmonk.html
//
// Johannes Deml
// send@johannesdeml.com
//
// Eris Koleszar
// me@eris.codes