portals and dash. Also a bit of terrain building and level design
This commit is contained in:
BIN
Assets/Rotary Heart/SerializableDictionaryLite/Documentation.pdf
Normal file
BIN
Assets/Rotary Heart/SerializableDictionaryLite/Documentation.pdf
Normal file
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbf98b49d6e815c4183c8b61dba47f69
|
||||
timeCreated: 1517921167
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// Attribute used to force drawing a key as a property
|
||||
/// </summary>
|
||||
[System.AttributeUsage(System.AttributeTargets.Field)]
|
||||
public class DrawKeyAsPropertyAttribute : System.Attribute { }
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00639d477664ffc42bc48acded7cc5b2
|
||||
timeCreated: 1531259031
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Rotary Heart/SerializableDictionaryLite/Editor.meta
Normal file
10
Assets/Rotary Heart/SerializableDictionaryLite/Editor.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2acf2fe79d0c0d248895ed3b92135bf1
|
||||
folderAsset: yes
|
||||
timeCreated: 1517433775
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
public sealed class Constants
|
||||
{
|
||||
private const bool DEF_SHOW_PAGES = false;
|
||||
private const bool DEF_SHOW_SIZE = true;
|
||||
private const int DEF_PAGE_COUNT = 15;
|
||||
|
||||
private const string ID_SHOW_PAGES = "RHSD_ShowPages";
|
||||
private const string ID_SHOW_SIZE = "RHSD_ShowSize";
|
||||
private const string ID_PAGE_COUNT = "RHSD_PageCount";
|
||||
|
||||
public static bool ShowPages
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(ID_SHOW_PAGES, DEF_SHOW_PAGES);
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(ID_SHOW_PAGES, value);
|
||||
}
|
||||
}
|
||||
public static bool ShowSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetBool(ID_SHOW_SIZE, DEF_SHOW_SIZE);
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetBool(ID_SHOW_SIZE, value);
|
||||
}
|
||||
}
|
||||
public static int PageCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return EditorPrefs.GetInt(ID_PAGE_COUNT, DEF_PAGE_COUNT);
|
||||
}
|
||||
set
|
||||
{
|
||||
EditorPrefs.SetInt(ID_PAGE_COUNT, value);
|
||||
}
|
||||
}
|
||||
|
||||
public static void RestoreDefaults()
|
||||
{
|
||||
ShowPages = DEF_SHOW_PAGES;
|
||||
ShowSize = DEF_SHOW_SIZE;
|
||||
PageCount = DEF_PAGE_COUNT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e8f7fab786cd2c04194e604600b27211
|
||||
timeCreated: 1538180000
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class Definer
|
||||
{
|
||||
static Definer()
|
||||
{
|
||||
List<string> defines = new List<string>(1)
|
||||
{
|
||||
"RH_SerializedDictionary"
|
||||
};
|
||||
|
||||
RotaryHeart.Lib.Definer.ApplyDefines(defines);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db381ff7b4ec4384d8ec4f8cf79d7398
|
||||
timeCreated: 1539019300
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 535421d7cb5b6b943a76e5f0c855d5d3
|
||||
timeCreated: 1517621586
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
public class PreferencesWindow
|
||||
{
|
||||
#region GUIContent
|
||||
static readonly GUIContent gui_pagesTitle = new GUIContent("Pages", "Section that has all the pages settings for the drawer");
|
||||
static readonly GUIContent gui_showPages = new GUIContent("Show Pages", "Should the drawer be divided in pages?");
|
||||
static readonly GUIContent gui_showSizes = new GUIContent("Show Sizes", "Should the dictionary show the size on the title bar?");
|
||||
static readonly GUIContent gui_pageCount = new GUIContent("Page Count", "How many elements per page are going to be drawn");
|
||||
#endregion
|
||||
|
||||
// Have we loaded the prefs yet
|
||||
private static bool prefsLoaded = false;
|
||||
|
||||
//Default values
|
||||
private static bool showPages;
|
||||
private static bool showSize;
|
||||
private static int pageCount;
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
private class MyPrefSettingsProvider : SettingsProvider
|
||||
{
|
||||
public MyPrefSettingsProvider(string path, SettingsScope scopes = SettingsScope.Project)
|
||||
: base(path, scopes)
|
||||
{ }
|
||||
|
||||
public override void OnGUI(string searchContext)
|
||||
{
|
||||
PreferencesGUI();
|
||||
}
|
||||
}
|
||||
|
||||
[SettingsProvider]
|
||||
static SettingsProvider MyNewPrefCode()
|
||||
{
|
||||
return new MyPrefSettingsProvider("Preferences/RHSD");
|
||||
}
|
||||
#else
|
||||
// Add preferences section named "My Preferences" to the Preferences Window
|
||||
[PreferenceItem("RHSD")]
|
||||
#endif
|
||||
public static void PreferencesGUI()
|
||||
{
|
||||
if (!prefsLoaded)
|
||||
{
|
||||
showPages = Constants.ShowPages;
|
||||
showSize = Constants.ShowSize;
|
||||
pageCount = Constants.PageCount;
|
||||
|
||||
prefsLoaded = true;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField(gui_pagesTitle, EditorStyles.boldLabel);
|
||||
EditorGUILayout.Space();
|
||||
|
||||
showSize = EditorGUILayout.Toggle(gui_showSizes, showSize);
|
||||
showPages = EditorGUILayout.Toggle(gui_showPages, showPages);
|
||||
|
||||
GUI.enabled = showPages;
|
||||
|
||||
pageCount = Mathf.Clamp(EditorGUILayout.IntField(gui_pageCount, pageCount), 5, int.MaxValue);
|
||||
|
||||
GUI.enabled = true;
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
Constants.ShowPages = showPages;
|
||||
Constants.ShowSize = showSize;
|
||||
Constants.PageCount = pageCount;
|
||||
}
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
if (GUILayout.Button("Restore Default"))
|
||||
{
|
||||
Constants.RestoreDefaults();
|
||||
|
||||
prefsLoaded = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28956686d1e55594b904610e0b1614d5
|
||||
timeCreated: 1538179311
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using UnityEditor;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
public class SupportWindow : BaseSupportWindow
|
||||
{
|
||||
const string SUPPORT_FORUM = "https://forum.unity.com/threads/released-serializable-dictionary.518178/";
|
||||
const string STORE_LINK = "https://assetstore.unity.com/packages/tools/utilities/serialized-dictionary-110992";
|
||||
const string ASSET_NAME = "Serializable Dictionary Lite";
|
||||
const string VERSION = "2.6.9.4";
|
||||
|
||||
protected override string SupportForum
|
||||
{
|
||||
get { return SUPPORT_FORUM; }
|
||||
}
|
||||
protected override string StoreLink
|
||||
{
|
||||
get { return STORE_LINK; }
|
||||
}
|
||||
protected override string AssetName
|
||||
{
|
||||
get { return ASSET_NAME; }
|
||||
}
|
||||
protected override string Version
|
||||
{
|
||||
get { return VERSION; }
|
||||
}
|
||||
|
||||
[MenuItem("Tools/Rotary Heart/Serializable Dictionary/About")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
ShowWindow<SupportWindow>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c148ddc40f9a15d4dbbbd484dbdec41a
|
||||
timeCreated: 1526321196
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Rotary Heart/SerializableDictionaryLite/Example.meta
Normal file
10
Assets/Rotary Heart/SerializableDictionaryLite/Example.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 599e14707315eaa4e846aa00126a0d33
|
||||
folderAsset: yes
|
||||
timeCreated: 1517722512
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de7597505a523bb4a86a54abc48464a6
|
||||
timeCreated: 1524545395
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
using RotaryHeart.Lib.SerializableDictionary;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RotaryHeart.Lib
|
||||
{
|
||||
[CreateAssetMenu(fileName = "DataBase.asset", menuName = "Data Base")]
|
||||
public class DataBaseExample : ScriptableObject
|
||||
{
|
||||
public enum EnumExample
|
||||
{
|
||||
None,
|
||||
Value1,
|
||||
Value2,
|
||||
Value3,
|
||||
Value4,
|
||||
Value5,
|
||||
Value6
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ChildTest
|
||||
{
|
||||
public Color myChildColor;
|
||||
public bool myChildBool;
|
||||
public Gradient test;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ClassTest
|
||||
{
|
||||
public string id;
|
||||
public float test;
|
||||
public string test2;
|
||||
public Quaternion quat;
|
||||
public ChildTest[] childTest;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ArrayTest
|
||||
{
|
||||
public int[] myArray;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class AdvancedGenericClass
|
||||
{
|
||||
[Range(0, 100)]
|
||||
public float value;
|
||||
|
||||
public bool Equals(AdvancedGenericClass other)
|
||||
{
|
||||
if (ReferenceEquals(null, other)) return false;
|
||||
if (ReferenceEquals(this, other)) return true;
|
||||
return other.value == value;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != typeof(AdvancedGenericClass)) return false;
|
||||
return Equals((AdvancedGenericClass)obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked
|
||||
{
|
||||
return value.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField]
|
||||
public Generic_String _genericString;
|
||||
|
||||
[SerializeField]
|
||||
public Generic_Generic _genericGeneric;
|
||||
|
||||
[SerializeField, ID("id")]
|
||||
private S_GenericDictionary _stringGeneric;
|
||||
|
||||
[SerializeField]
|
||||
private I_GenericDictionary _intGeneric;
|
||||
|
||||
[SerializeField]
|
||||
private I_GO _intGameobject;
|
||||
[SerializeField]
|
||||
private GO_I _gameobjectInt;
|
||||
|
||||
[SerializeField]
|
||||
private S_GO _stringGameobject;
|
||||
[SerializeField]
|
||||
private GO_S _gameobjectString;
|
||||
|
||||
[SerializeField]
|
||||
private S_Mat _stringMaterial;
|
||||
[SerializeField]
|
||||
private Mat_S _materialString;
|
||||
|
||||
[SerializeField]
|
||||
private V3_Q _vector3Quaternion;
|
||||
[SerializeField]
|
||||
private Q_V3 _quaternionVector3;
|
||||
|
||||
[SerializeField]
|
||||
private S_AC _stringAudioClip;
|
||||
[SerializeField]
|
||||
private AC_S _audioClipString;
|
||||
|
||||
[SerializeField]
|
||||
private C_Int _charInt;
|
||||
[SerializeField]
|
||||
private G_Int _gradientInt;
|
||||
|
||||
[SerializeField]
|
||||
private Int_IntArray _intArray;
|
||||
|
||||
[SerializeField]
|
||||
private Enum_String _enumString;
|
||||
|
||||
[SerializeField, DrawKeyAsProperty]
|
||||
private AdvanGeneric_String _advancedGenericKey;
|
||||
|
||||
[System.Serializable]
|
||||
public class Generic_String : SerializableDictionaryBase<ClassTest, string> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class Generic_Generic : SerializableDictionaryBase<ClassTest, ClassTest> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class C_Int : SerializableDictionaryBase<char, int> { }
|
||||
[System.Serializable]
|
||||
public class G_Int : SerializableDictionaryBase<Gradient, int> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class I_GO : SerializableDictionaryBase<int, GameObject> { }
|
||||
[System.Serializable]
|
||||
public class GO_I : SerializableDictionaryBase<GameObject, int> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class S_GO : SerializableDictionaryBase<string, GameObject> { }
|
||||
[System.Serializable]
|
||||
public class GO_S : SerializableDictionaryBase<GameObject, string> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class S_Mat : SerializableDictionaryBase<string, Material> { }
|
||||
[System.Serializable]
|
||||
public class Mat_S : SerializableDictionaryBase<Material, string> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class S_AC : SerializableDictionaryBase<string, AudioClip> { }
|
||||
[System.Serializable]
|
||||
public class AC_S : SerializableDictionaryBase<AudioClip, string> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class S_Sprite : SerializableDictionaryBase<string, Sprite> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class V3_Q : SerializableDictionaryBase<Vector3, Quaternion> { }
|
||||
[System.Serializable]
|
||||
public class Q_V3 : SerializableDictionaryBase<Quaternion, Vector3> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class S_GenericDictionary : SerializableDictionaryBase<string, ClassTest> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class I_GenericDictionary : SerializableDictionaryBase<int, ClassTest> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class Int_IntArray : SerializableDictionaryBase<int, ArrayTest> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class Enum_String : SerializableDictionaryBase<EnumExample, string> { };
|
||||
|
||||
[System.Serializable]
|
||||
public class AdvanGeneric_String : SerializableDictionaryBase<AdvancedGenericClass, string> { };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01676c610da230d44bf354f89a960a84
|
||||
timeCreated: 1517432900
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 423983ee7ab789d4c9d70b1256e20c19
|
||||
timeCreated: 1525053065
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,40 @@
|
||||
using RotaryHeart.Lib.SerializableDictionary;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RotaryHeart.Lib
|
||||
{
|
||||
[CreateAssetMenu(fileName = "NestedDB.asset", menuName = "Nested DB")]
|
||||
public class NestedDB : ScriptableObject
|
||||
{
|
||||
[SerializeField, ID("id")]
|
||||
public MainDict nested;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class Example
|
||||
{
|
||||
public string id;
|
||||
public QueryTriggerInteraction enumVal;
|
||||
public NestedDict nestedData;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class NestedExample
|
||||
{
|
||||
public GameObject prefab;
|
||||
public float speed;
|
||||
public Color color;
|
||||
public Nested2Dict deepNested;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MainDict : SerializableDictionaryBase<string, Example> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class NestedDict : SerializableDictionaryBase<int, NestedExample> { }
|
||||
|
||||
[System.Serializable]
|
||||
public class Nested2Dict : SerializableDictionaryBase<QueryTriggerInteraction, string> { }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86c2746ac6d3d924bb04108285ea0aff
|
||||
timeCreated: 1524685484
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
[System.AttributeUsage(System.AttributeTargets.Field)]
|
||||
public class IDAttribute : System.Attribute
|
||||
{
|
||||
private string _id;
|
||||
|
||||
public string Id
|
||||
{
|
||||
get { return _id; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serializable field name for the property id
|
||||
/// </summary>
|
||||
/// <param name="id">Field name</param>
|
||||
public IDAttribute(string id)
|
||||
{
|
||||
_id = id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 553c4210c29c1884fbce9652dafeea9e
|
||||
timeCreated: 1517646601
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecd16c576c7d3b74797783bb42638043
|
||||
folderAsset: yes
|
||||
timeCreated: 1517843997
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: ef11afdbd8a2f34448943ffdea9943ac, type: 3}
|
||||
m_Name: References
|
||||
m_EditorClassIdentifier:
|
||||
_gameObject: {fileID: 0}
|
||||
_material: {fileID: 0}
|
||||
_audioClip: {fileID: 0}
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d6785e46e940b843aa5fbe4ca729d60
|
||||
timeCreated: 1517844080
|
||||
licenseType: Store
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is used so that the dictionary keys can have a default value, unity editor will give the default value, because it can't be null.
|
||||
/// This should only be used for UnityEngine.Object inherited classes
|
||||
/// </summary>
|
||||
public class RequiredReferences : ScriptableObject
|
||||
{
|
||||
//Important note, the fields need to be private so that the reflection code can find them.
|
||||
//Use [SerializeField] so that the editor draws the property field and sets a default value
|
||||
[SerializeField]
|
||||
private GameObject _gameObject;
|
||||
[SerializeField]
|
||||
private Material _material;
|
||||
[SerializeField]
|
||||
private AudioClip _audioClip;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ef11afdbd8a2f34448943ffdea9943ac
|
||||
timeCreated: 1517843975
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d8bc9729cfff8f45b6769b3a800ecbf
|
||||
folderAsset: yes
|
||||
timeCreated: 1524512821
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a912a08eeace5594fa91c48e23c7b920
|
||||
timeCreated: 1434688391
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,489 @@
|
||||
//Based of the following thread https://forum.unity.com/threads/finally-a-serializable-dictionary-for-unity-extracted-from-system-collections-generic.335797/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RotaryHeart.Lib.SerializableDictionary
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is only used to be able to draw the custom property drawer
|
||||
/// </summary>
|
||||
public abstract class DrawableDictionary
|
||||
{
|
||||
[UnityEngine.HideInInspector]
|
||||
public ReorderableList reorderableList = null;
|
||||
[UnityEngine.HideInInspector]
|
||||
public RequiredReferences reqReferences;
|
||||
public bool isExpanded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Base class that most be used for any dictionary that wants to be implemented
|
||||
/// </summary>
|
||||
/// <typeparam name="TKey">Key type</typeparam>
|
||||
/// <typeparam name="TValue">Value type</typeparam>
|
||||
[System.Serializable]
|
||||
public class SerializableDictionaryBase<TKey, TValue> : DrawableDictionary, IDictionary<TKey, TValue>, UnityEngine.ISerializationCallbackReceiver
|
||||
{
|
||||
Dictionary<TKey, TValue> _dict;
|
||||
static readonly Dictionary<TKey, TValue> _staticEmptyDict = new Dictionary<TKey, TValue>(0);
|
||||
|
||||
/// <summary>
|
||||
/// Copies the data from a dictionary. If an entry with the same key is found it replaces the value
|
||||
/// </summary>
|
||||
/// <param name="src">Dictionary to copy the data from</param>
|
||||
public void CopyFrom(IDictionary<TKey, TValue> src)
|
||||
{
|
||||
foreach (KeyValuePair<TKey, TValue> data in src)
|
||||
{
|
||||
if (ContainsKey(data.Key))
|
||||
{
|
||||
this[data.Key] = data.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
Add(data.Key, data.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the data from a dictionary. If an entry with the same key is found it replaces the value. Note that if the <paramref name="src"/> is not a dictionary of the same type it will not be copied
|
||||
/// </summary>
|
||||
/// <param name="src">Dictionary to copy the data from</param>
|
||||
public void CopyFrom(object src)
|
||||
{
|
||||
Dictionary<TKey, TValue> dictionary = src as Dictionary<TKey, TValue>;
|
||||
if (dictionary != null)
|
||||
{
|
||||
CopyFrom(dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the data to a dictionary. If an entry with the same key is found it replaces the value
|
||||
/// </summary>
|
||||
/// <param name="dest">Dictionary to copy the data to</param>
|
||||
public void CopyTo(IDictionary<TKey, TValue> dest)
|
||||
{
|
||||
foreach (KeyValuePair<TKey, TValue> data in this)
|
||||
{
|
||||
if (dest.ContainsKey(data.Key))
|
||||
{
|
||||
dest[data.Key] = data.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
dest.Add(data.Key, data.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a copy of the dictionary.
|
||||
/// </summary>
|
||||
public Dictionary<TKey, TValue> Clone()
|
||||
{
|
||||
Dictionary<TKey, TValue> dest = new Dictionary<TKey, TValue>(Count);
|
||||
|
||||
foreach (KeyValuePair<TKey, TValue> data in this)
|
||||
{
|
||||
dest.Add(data.Key, data.Value);
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the value exists; otherwise, false
|
||||
/// </summary>
|
||||
/// <param name="value">Value to check</param>
|
||||
public bool ContainsValue(TValue value)
|
||||
{
|
||||
if (_dict == null)
|
||||
return false;
|
||||
|
||||
return _dict.ContainsValue(value);
|
||||
}
|
||||
|
||||
#region IDictionary Interface
|
||||
|
||||
#region Properties
|
||||
|
||||
public TValue this[TKey key]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dict == null) throw new KeyNotFoundException();
|
||||
return _dict[key];
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_dict == null) _dict = new Dictionary<TKey, TValue>();
|
||||
_dict[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<TKey> Keys
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>();
|
||||
|
||||
return _dict.Keys;
|
||||
}
|
||||
}
|
||||
|
||||
public ICollection<TValue> Values
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>();
|
||||
|
||||
return _dict.Values;
|
||||
}
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
{
|
||||
return (_dict != null) ? _dict.Count : 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion Properties
|
||||
|
||||
|
||||
public bool ContainsKey(TKey key)
|
||||
{
|
||||
if (_dict == null)
|
||||
return false;
|
||||
|
||||
return _dict.ContainsKey(key);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>();
|
||||
|
||||
_dict.Add(key, value);
|
||||
|
||||
if (_keyValues == null)
|
||||
_keyValues = new List<TKey>();
|
||||
if (_keys == null)
|
||||
_keys = new List<TKey>();
|
||||
if (_values == null)
|
||||
_values = new List<TValue>();
|
||||
|
||||
_keyValues.Add(key);
|
||||
_keys.Add(key);
|
||||
_values.Add(value);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_dict != null)
|
||||
_dict.Clear();
|
||||
|
||||
if (_keyValues != null)
|
||||
_keyValues.Clear();
|
||||
if (_keys != null)
|
||||
_keys.Clear();
|
||||
if (_values != null)
|
||||
_values.Clear();
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
if (_dict == null)
|
||||
return false;
|
||||
|
||||
int index = -1;
|
||||
|
||||
if (_keys != null)
|
||||
{
|
||||
index = _keys.IndexOf(key);
|
||||
|
||||
if (index != -1)
|
||||
_keys.RemoveAt(index);
|
||||
}
|
||||
|
||||
if (index != -1)
|
||||
{
|
||||
if (_keyValues != null)
|
||||
_keyValues.RemoveAt(index);
|
||||
|
||||
if (_values != null)
|
||||
_values.RemoveAt(index);
|
||||
}
|
||||
|
||||
return _dict.Remove(key);
|
||||
}
|
||||
#else
|
||||
|
||||
public void Add(TKey key, TValue value)
|
||||
{
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>();
|
||||
|
||||
_dict.Add(key, value);
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
if (_dict != null)
|
||||
_dict.Clear();
|
||||
}
|
||||
|
||||
public bool Remove(TKey key)
|
||||
{
|
||||
if (_dict == null)
|
||||
return false;
|
||||
|
||||
return _dict.Remove(key);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
public bool TryGetValue(TKey key, out TValue value)
|
||||
{
|
||||
if (_dict == null)
|
||||
{
|
||||
value = default(TValue);
|
||||
return false;
|
||||
}
|
||||
|
||||
return _dict.TryGetValue(key, out value);
|
||||
}
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (_dict == null) _dict = new Dictionary<TKey, TValue>();
|
||||
(_dict as ICollection<KeyValuePair<TKey, TValue>>).Add(item);
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (_dict == null) return false;
|
||||
return (_dict as ICollection<KeyValuePair<TKey, TValue>>).Contains(item);
|
||||
}
|
||||
|
||||
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
|
||||
{
|
||||
if (_dict == null) return;
|
||||
(_dict as ICollection<KeyValuePair<TKey, TValue>>).CopyTo(array, arrayIndex);
|
||||
}
|
||||
|
||||
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
|
||||
{
|
||||
if (_dict == null) return false;
|
||||
return (_dict as ICollection<KeyValuePair<TKey, TValue>>).Remove(item);
|
||||
}
|
||||
|
||||
public Dictionary<TKey, TValue>.Enumerator GetEnumerator()
|
||||
{
|
||||
if (_dict == null) return _staticEmptyDict.GetEnumerator();
|
||||
return _dict.GetEnumerator();
|
||||
}
|
||||
|
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ISerializationCallbackReceiver
|
||||
|
||||
[SerializeField]
|
||||
List<TKey> _keyValues;
|
||||
|
||||
[SerializeField]
|
||||
List<TKey> _keys;
|
||||
[SerializeField]
|
||||
List<TValue> _values;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (_keys != null && _values != null)
|
||||
{
|
||||
//Need to clear the dictionary
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>(_keys.Count);
|
||||
else
|
||||
_dict.Clear();
|
||||
|
||||
for (int i = 0; i < _keys.Count; i++)
|
||||
{
|
||||
//This should only happen with reference type keys (Generic, Object, etc)
|
||||
if (_keys[i] == null)
|
||||
{
|
||||
//Special case for UnityEngine.Object classes
|
||||
if (typeof(Object).IsAssignableFrom(typeof(TKey)))
|
||||
{
|
||||
//Key type
|
||||
string tKeyType = typeof(TKey).ToString();
|
||||
|
||||
//We need the reference to the reference holder class
|
||||
if (reqReferences == null)
|
||||
{
|
||||
Debug.LogError("A key of type: " + tKeyType + " requires to have a valid RequiredReferences reference");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Use reflection to check all the fields included on the class
|
||||
foreach (FieldInfo field in typeof(RequiredReferences).GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
|
||||
{
|
||||
//Only set the value if the type is the same
|
||||
if (field.FieldType.ToString().Equals(tKeyType))
|
||||
{
|
||||
_keys[i] = (TKey)(field.GetValue(reqReferences));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//References class is missing the field, skip the element
|
||||
if (_keys[i] == null)
|
||||
{
|
||||
Debug.LogError("Couldn't find " + tKeyType + " reference.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Create a instance for the key
|
||||
_keys[i] = System.Activator.CreateInstance<TKey>();
|
||||
}
|
||||
}
|
||||
|
||||
//Add the data to the dictionary. Value can be null so no special step is required
|
||||
if (i < _values.Count)
|
||||
_dict[_keys[i]] = _values[i];
|
||||
else
|
||||
_dict[_keys[i]] = default(TValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
void ISerializationCallbackReceiver.OnAfterDeserialize()
|
||||
{
|
||||
if (_keys != null && _values != null)
|
||||
{
|
||||
//Need to clear the dictionary
|
||||
if (_dict == null)
|
||||
_dict = new Dictionary<TKey, TValue>(_keys.Count);
|
||||
else
|
||||
_dict.Clear();
|
||||
|
||||
for (int i = 0; i < _keys.Count; i++)
|
||||
{
|
||||
//This should only happen with reference type keys (Generic, Object, etc)
|
||||
if (_keys[i] == null)
|
||||
{
|
||||
//Special case for UnityEngine.Object classes
|
||||
if (typeof(Object).IsAssignableFrom(typeof(TKey)))
|
||||
{
|
||||
//Key type
|
||||
string tKeyType = typeof(TKey).ToString();
|
||||
|
||||
//We need the reference to the reference holder class
|
||||
if (reqReferences == null)
|
||||
{
|
||||
Debug.LogError("A key of type: " + tKeyType + " requires to have a valid RequiredReferences reference");
|
||||
continue;
|
||||
}
|
||||
|
||||
//Use reflection to check all the fields included on the class
|
||||
foreach (FieldInfo field in typeof(RequiredReferences).GetFields(BindingFlags.Instance | BindingFlags.NonPublic))
|
||||
{
|
||||
//Only set the value if the type is the same
|
||||
if (field.FieldType.ToString().Equals(tKeyType))
|
||||
{
|
||||
_keys[i] = (TKey)(field.GetValue(reqReferences));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//References class is missing the field, skip the element
|
||||
if (_keys[i] == null)
|
||||
{
|
||||
Debug.LogError("Couldn't find " + tKeyType + " reference.");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Create a instance for the key
|
||||
_keys[i] = System.Activator.CreateInstance<TKey>();
|
||||
}
|
||||
}
|
||||
|
||||
//Add the data to the dictionary. Value can be null so no special step is required
|
||||
if (i < _values.Count)
|
||||
_dict[_keys[i]] = _values[i];
|
||||
else
|
||||
_dict[_keys[i]] = default(TValue);
|
||||
}
|
||||
}
|
||||
|
||||
_keyValues = null;
|
||||
_keys = null;
|
||||
_values = null;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void ISerializationCallbackReceiver.OnBeforeSerialize()
|
||||
{
|
||||
if (_dict == null || _dict.Count == 0)
|
||||
{
|
||||
//Dictionary is empty, erase data
|
||||
_keyValues = null;
|
||||
_keys = null;
|
||||
_values = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
//Initialize arrays
|
||||
int cnt = _dict.Count;
|
||||
_keyValues = new List<TKey>(cnt);
|
||||
_keys = new List<TKey>(cnt);
|
||||
_values = new List<TValue>(cnt);
|
||||
|
||||
using (Dictionary<TKey, TValue>.Enumerator e = _dict.GetEnumerator())
|
||||
{
|
||||
while (e.MoveNext())
|
||||
{
|
||||
//Set the respective data from the dictionary
|
||||
_keyValues.Add(e.Current.Key);
|
||||
_keys.Add(e.Current.Key);
|
||||
_values.Add(e.Current.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e6b03a8ca9bd434fae7398312521818
|
||||
timeCreated: 1517621578
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user