No, you can use that code in your editor window and it will draw the appropriate inspector in your window.

No, you can use that code in your editor window and it will draw the appropriate inspector in your window.

Sorry I am still very new to this but I am having difficulty getting the dictionary to show in the editor. For a basic example, I am trying to create a dictionary in a monobehaivor script attached to a game object.
using UnityEngine;
using RotaryHeart.Lib.SerializableDictionary;
public class Dictionaryscript : MonoBehaviour
{
[System.Serializable]
public class DialogueVCamRigDictionary : SerializableDictionaryBase<string, GameObject> { }
}
I looked through the database example but I am not following the process very well. Do these have to be created in their own class to generate a database object like in the database example?
You will need to provide more to see what your issue is, how are you using your DialogueVCamRigDictionary? Here you are just showing how yo declared your class, not how you use it.
I am attempting to create a serialized dictionary storing string names and cinemachine vcams. My thought is to pass in a string to a public function in a script attached to a gameobject, reference the dictionary to get the corresponding vcam, and then change the vcam priority. I am limited to strings in the events on the dialogue system I am using.
Something along these lines:
public class DialogueVCamController : MonoBehaviour
{
[System.Serializable]
public class DialogueVCamRigDictionary1 : SerializableDictionaryBase<string, GameObject> { }
public void SetVCam(string cameraName)
{
//use cameraName to get serialized vcam
vCam.Priority = 99;
}
public void DeselectVCam(string cameraName)
{
//use cameraName to get serialized vcam
vCam.Priority = 10;
}
Without seeing more of your script, itās hard to tell if you are having any kind of issue. All you need is to have a serialize field of your class for it to show in your inspector:
using UnityEngine;
using RotaryHeart.Lib.SerializableDictionary;
public class Dictionaryscript : MonoBehaviour
{
[System.Serializable]
public class DialogueVCamRigDictionary : SerializableDictionaryBase<string, GameObject> { }
[SerializeField]
DialogueVCamRigDictionary myDictionary;
}
I was missing the
[SerializeField]
DialogueVCamRigDictionary myDictionary;
Thank you for your help
Hi, just wanted to say, huge fan of this asset! Been using it for years, itās absolutely vital to me. Which is why itās so troubling that Iām now getting a strange error when a SerializableDictionary is visible in an inspector:
NullReferenceException: Object reference not set to an instance of an object
RotaryHeart.Lib.SerializableDictionary.DictionaryPropertyDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Unity Store Assets/Rotary Heart/SerializableDictionaryLite/Editor/DictionaryPropertyDrawer.cs:324)
To save you the time of looking it up, this is the line in the code that the error is pointing to:

Update: Iāve made some progress. The problem seems to be caused by me using a
SerializableDictionaryBase<string, List<[my object]>> . Making a dictionary of an object which holds the list does not cause the bug, but it does add an unneeded layer to my code. I tried making a class which inherits from List<[my object]> but then it doesnāt serialize at all, even though I put [Serializable] in front of all of the classes involved.
Currently, I can move forward, but if Iām just doing something wrong in how I tried to make a Dictionary of Lists, Iād love to know what that is so that I can do that directly, instead of having the wrapper object.
Hello,
Iām glad to know the asset is useful to you. You are not doing anything wrong, thatās just unfortunately how Unity serialization works. Youāll have to use a wrapper class for arrays/lists, since unity does not serialize nested arrays/lists.
Hello,
First of all, thank your for making this plugin free.
Iāve been using it quite around one of my scripts, got no issues, until now for some reason.
When i create a dictionnary using SerializableDictionaryBase, whatever the key and value type is, when I try to create the first key&value in the inspector, i get a ton of errors.
The variable is not nested, its at the base of my script class.
here is the code
[System.Serializable] public class VerticalSpecificHeight : SerializableDictionaryBase<string, float> { }
public VerticalSpecificHeight specificHeight;
using 2022.3.4f1
also, when reloading, the error is fixed, the key i tried adding before the ācrashā appears, and I can add as many keys as I want with no problem.
Console:
Details about the first error to appear:
IndexOutOfRangeException: Index was outside the bounds of the array.
RotaryHeart.Lib.SerializableDictionary.ReorderableList.DoList (UnityEngine.Rect rect, UnityEngine.GUIContent label, System.Boolean enablePages, System.Int32 perPageCount) (at Assets/Rotary Heart/SerializableDictionaryLite/ReorderableList/ReorderableList.cs:324)
RotaryHeart.Lib.SerializableDictionary.DictionaryPropertyDrawer.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at Assets/Rotary Heart/SerializableDictionaryLite/Editor/DictionaryPropertyDrawer.cs:350)
UnityEditor.PropertyDrawer.OnGUISafe (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label) (at :0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.Rect visibleArea) (at :0)
UnityEditor.PropertyHandler.OnGUI (UnityEngine.Rect position, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at :0)
UnityEditor.PropertyHandler.OnGUILayout (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[ ] options) (at :0)
UnityEditor.EditorGUILayout.PropertyField (UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren, UnityEngine.GUILayoutOption[ ] options) (at :0)
NaughtyAttributes.Editor.NaughtyEditorGUI.DrawPropertyField_Layout (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, UnityEngine.GUIContent label, System.Boolean includeChildren) (at Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs:39)
NaughtyAttributes.Editor.NaughtyEditorGUI.PropertyField_Implementation (UnityEngine.Rect rect, UnityEditor.SerializedProperty property, System.Boolean includeChildren, NaughtyAttributes.Editor.NaughtyEditorGUI+PropertyFieldFunction propertyFieldFunction) (at Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs:71)
NaughtyAttributes.Editor.NaughtyEditorGUI.PropertyField_Layout (UnityEditor.SerializedProperty property, System.Boolean includeChildren) (at Assets/NaughtyAttributes/Scripts/Editor/Utility/NaughtyEditorGUI.cs:29)
NaughtyAttributes.Editor.NaughtyInspector.DrawSerializedProperties () (at Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs:87)
NaughtyAttributes.Editor.NaughtyInspector.OnInspectorGUI () (at Assets/NaughtyAttributes/Scripts/Editor/NaughtyInspector.cs:47)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass72_0.b__0 () (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
Hello,
Can you replicate it on an empty project and attach it here? Iām having trouble replicating the issue
It seems to be a bug related to the coexistence of two plugins: yours and NaughtyAttributes.
Iāll try fixing this alone since its not your problem.
thank your for your fast response.
EDIT: rebooting the project solved the issue, maybe because i removed the issue.
Iām glad the issue is resolved
Hello, I find your assets very useful.
When I build using AddressableAsset, an error message like that sometimes appears.
Even if an error occurs, there doesnāt seem to be a problem with the build, but itās difficult to find where it came from.
This doesnāt happen to everything.
I think Iām missing a link in the inspector⦠but I canāt find where the error occurred.
I am leaving an inquiry because I am curious to know if there is any speculation as to the cause.
It can be assumed that this is a problem that occurs when building with something missing when using Enum as a key value in the Unity Inspector. (Not accurate.)
This is the first time Iāve seen this report. I tried to replicate it but cannot make it happen. If you manage to make a small repro project feel free to attach it and I can investigate what might be happening
Thank you for your reply⦠I donāt think it will be easy to reproduce.
Because there is no problem with this right now
I will contact you again regarding this matter after I finish up my other urgent matters.
Hello, I am attaching a reproducible code that generates an error message when building.
I created a Template type for convenience in setting key values in the Unity Inspector. (In fact, it works fine if you ignore the error message.)
using UnityEngine;
public class MenuButtonGroupController : MenuButtonGroupBase<string> { }
public class MenuButtonGroupBase<T> : MonoBehaviour
{
[SerializeField] SerializableDictionaryBase<T, Button> _buttons = null;
}
Using āMenuButtonGroupControllerā in Unity Inspector
This seems like is not giving me the issue either. I can build both addressables or the project without problems