Page 1 of 1
CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 2:17 pm
by lgarczyn
Hi, and thanks for the wonderful product
I want to add a dialog entry field type that holds the name of specific GameObjects in a scene.
Ideally, I want to have a dropdown where you can select the gameobject in question.
I've overriden the CustomFieldType class like so:
Code: Select all
namespace Dialogs.AssemblyExtensions.Editor
{
[CustomFieldTypeService.Name(FieldName)]
public class CustomFieldTypeButtonParent : CustomFieldType
{
public const string FieldName = "ButtonParent";
This works fine without asmdefs, but with them, the type is never displayed as a possible option.
If I try to simply put it in an extension of the dialog editor assembly defined like so
Code: Select all
{
"reference": "DialogSystemEditor"
}
It kinda works? I can select the custom field type in the template editor
But it uses the default text drawer. Sometimes I get warnings from the dialog system that it cannot find the extension type, but I cannot reproduce it at the moment.
Should I just add the type to the pixel crushers folder?
Re: CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 2:41 pm
by lgarczyn
I've managed to get the warning again
Code: Select all
Can't find type: Dialogs.AssemblyExtensions.Editor.CustomFieldTypeButtonParent. Define a class with this type inside an Editor folder.
UnityEngine.Debug:Log (object)
PixelCrushers.DialogueSystem.CustomFieldTypeService:GetFieldCustomType (string) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Fields/CustomFieldTypeService.cs:262)
PixelCrushers.DialogueSystem.CustomFieldTypeService:DrawField (PixelCrushers.DialogueSystem.Field,PixelCrushers.DialogueSystem.DialogueDatabase) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Fields/CustomFieldTypeService.cs:52)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawField (PixelCrushers.DialogueSystem.Field,bool,bool) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueEditorWindowFieldsSection.cs:285)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawFieldsContent (System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Field>,System.Collections.Generic.List`1<string>) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueEditorWindowFieldsSection.cs:72)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawFieldsSection (System.Collections.Generic.List`1<PixelCrushers.DialogueSystem.Field>,System.Collections.Generic.List`1<string>) (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueEditorWindowFieldsSection.cs:34)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawDialogueEntryFieldContents () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueEditorWindowDialogueTreeSection.cs:778)
PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow:DrawDialogueEntryInspector () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueEditorWindowDialogueTreeSection.cs:1096)
PixelCrushers.DialogueSystem.DialogueDatabaseEditor:DrawInspectorSelection () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueDatabaseEditor.cs:264)
PixelCrushers.DialogueSystem.DialogueDatabaseEditor:OnInspectorGUI () (at Assets/Plugins/Pixel Crushers/Dialogue System/Scripts/Editor/Dialogue Editor/DialogueDatabaseEditor.cs:94)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Re: CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 2:51 pm
by lgarczyn
Well it looks like changing the namespace to "PixelCrushers.DialogueSystem"
I shall tell Rider to eat its shoes for one, and accept an inconsistent namespace
Re: CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 3:21 pm
by Tony Li
Hi,
Yes, the class should be in the PixelCrushers.DialogueSystem namespace. This helps performance because the Dialogue System only needs to look in specific namespaces for field drawers, not in every single script in the project.
Re: CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 3:57 pm
by lgarczyn
Well, looks like the error is back.
This time, only in the inspector when selecting specific dialogue options with the custom field, and opening the "All Fields" toggle
Re: CustomFieldType + asmdef
Posted: Wed Jun 07, 2023 6:25 pm
by Tony Li
It may have been caused by changing the namespace. But you can fix it manually.
1. Close the Dialogue Editor window.
2. Inspect the dialogue database.
3. Tick Show Default Inspector.
4. Inspect the offending field. Change the Type String value to "CustomFieldTypeButtonParent".
The screenshot below shows the Show Default Inspector checkbox and a Type String field:
- customFieldType.png (47.99 KiB) Viewed 796 times
When you create new fields of this type, they should automatically be correct.
Re: CustomFieldType + asmdef
Posted: Thu Jun 08, 2023 5:16 pm
by lgarczyn
It works!
Went from
to
I've then updated the template from assets, then synced the assets to the template
Re: CustomFieldType + asmdef
Posted: Thu Jun 08, 2023 7:23 pm
by Tony Li
Great! I'm glad it's working now.