diff options
Diffstat (limited to 'Assets/SerializableDictionary/Example')
9 files changed, 358 insertions, 0 deletions
diff --git a/Assets/SerializableDictionary/Example/Editor.meta b/Assets/SerializableDictionary/Example/Editor.meta new file mode 100644 index 00000000..f3048e56 --- /dev/null +++ b/Assets/SerializableDictionary/Example/Editor.meta @@ -0,0 +1,5 @@ +fileFormatVersion: 2 +guid: b9e966b834ddb48d0815c494d4f511da +folderAsset: yes +DefaultImporter: + userData: diff --git a/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs b/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs new file mode 100644 index 00000000..5c63f1ea --- /dev/null +++ b/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +[CustomPropertyDrawer(typeof(StringStringDictionary))] +[CustomPropertyDrawer(typeof(ObjectColorDictionary))] +[CustomPropertyDrawer(typeof(StringColorArrayDictionary))] +public class AnySerializableDictionaryPropertyDrawer : SerializableDictionaryPropertyDrawer {} + +[CustomPropertyDrawer(typeof(ColorArrayStorage))] +public class AnySerializableDictionaryStoragePropertyDrawer: SerializableDictionaryStoragePropertyDrawer {} diff --git a/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs.meta b/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs.meta new file mode 100644 index 00000000..0c101e13 --- /dev/null +++ b/Assets/SerializableDictionary/Example/Editor/UserSerializableDictionaryPropertyDrawers.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3089b6c771301cc44ba23b7f8f469e14 +timeCreated: 1493639898 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity b/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity new file mode 100644 index 00000000..ce09708d --- /dev/null +++ b/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity @@ -0,0 +1,251 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 1 + m_BakeResolution: 50 + m_AtlasSize: 1024 + m_AO: 1 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 0 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666666 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &714127983 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 714127989} + - component: {fileID: 714127988} + - component: {fileID: 714127987} + - component: {fileID: 714127986} + - component: {fileID: 714127985} + - component: {fileID: 714127984} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &714127984 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d5ff00a74ccb984498070d9930a7944c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_stringStringDictionary: + m_keys: + - first key + - second key + - third key + m_values: + - value A + - value B + - value C + m_objectColorDictionary: + m_keys: + - {fileID: 714127983} + - {fileID: 714127984} + m_values: + - {r: 0, g: 0, b: 1, a: 1} + - {r: 1, g: 0, b: 0, a: 1} + m_objectColorArrayDictionary: + m_keys: + - rainbow + - grayscale + m_values: + - data: + - {r: 1, g: 0, b: 0, a: 1} + - {r: 1, g: 0.40000004, b: 0, a: 1} + - {r: 1, g: 0.9333334, b: 0, a: 1} + - {r: 0, g: 1, b: 0, a: 1} + - {r: 0, g: 0.6, b: 1, a: 1} + - {r: 0.26666668, g: 0, b: 1, a: 1} + - {r: 0.6, g: 0, b: 1, a: 1} + - data: + - {r: 0, g: 0, b: 0, a: 0} + - {r: 0.2509804, g: 0.2509804, b: 0.2509804, a: 0.2509804} + - {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0.5019608} + - {r: 0.7529412, g: 0.7529412, b: 0.7529412, a: 0.7529412} + - {r: 1, g: 1, b: 1, a: 1} +--- !u!81 &714127985 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_Enabled: 1 +--- !u!124 &714127986 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_Enabled: 1 +--- !u!92 &714127987 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_Enabled: 1 +--- !u!20 &714127988 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0.019607844} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &714127989 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 714127983} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity.meta b/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity.meta new file mode 100644 index 00000000..25ff160d --- /dev/null +++ b/Assets/SerializableDictionary/Example/SerializableDicitonary Example.unity.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 6c0758ade4ba74b7493ce3806fa2f38b +DefaultImporter: + userData: diff --git a/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs b/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs new file mode 100644 index 00000000..f47a8923 --- /dev/null +++ b/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs @@ -0,0 +1,24 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SerializableDictionaryExample : MonoBehaviour { + // The dictionaries can be accessed throught a property + [SerializeField] + StringStringDictionary m_stringStringDictionary; + public IDictionary<string, string> StringStringDictionary + { + get { return m_stringStringDictionary; } + set { m_stringStringDictionary.CopyFrom (value); } + } + + public ObjectColorDictionary m_objectColorDictionary; + public StringColorArrayDictionary m_objectColorArrayDictionary; + + void Reset () + { + // access by property + StringStringDictionary = new Dictionary<string, string>() { {"first key", "value A"}, {"second key", "value B"}, {"third key", "value C"} }; + m_objectColorDictionary = new ObjectColorDictionary() { {gameObject, Color.blue}, {this, Color.red} }; + } +} diff --git a/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs.meta b/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs.meta new file mode 100644 index 00000000..84a0fd47 --- /dev/null +++ b/Assets/SerializableDictionary/Example/SerializableDictionaryExample.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d5ff00a74ccb984498070d9930a7944c +timeCreated: 1492868873 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs b/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs new file mode 100644 index 00000000..b20b24bd --- /dev/null +++ b/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using System; +using UnityEngine; + +[Serializable] +public class StringStringDictionary : SerializableDictionary<string, string> {} + +[Serializable] +public class ObjectColorDictionary : SerializableDictionary<UnityEngine.Object, Color> {} + +[Serializable] +public class ColorArrayStorage : SerializableDictionary.Storage<Color[]> {} + +[Serializable] +public class StringColorArrayDictionary : SerializableDictionary<string, Color[], ColorArrayStorage> {} + +[Serializable] +public class MyClass +{ + public int i; + public string str; +} + +[Serializable] +public class QuaternionMyClassDictionary : SerializableDictionary<Quaternion, MyClass> {}
\ No newline at end of file diff --git a/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs.meta b/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs.meta new file mode 100644 index 00000000..0a39089b --- /dev/null +++ b/Assets/SerializableDictionary/Example/UserSerializableDictionaries.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bd910530dd8f6b5429c65a494644ed09 +timeCreated: 1493639913 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |