CustomFieldType + asmdef

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
lgarczyn
Posts: 30
Joined: Fri May 05, 2023 5:28 am

CustomFieldType + asmdef

Post 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

Image

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?
lgarczyn
Posts: 30
Joined: Fri May 05, 2023 5:28 am

Re: CustomFieldType + asmdef

Post 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&)

lgarczyn
Posts: 30
Joined: Fri May 05, 2023 5:28 am

Re: CustomFieldType + asmdef

Post 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
Last edited by lgarczyn on Wed Jun 07, 2023 3:57 pm, edited 1 time in total.
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

Re: CustomFieldType + asmdef

Post 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.
lgarczyn
Posts: 30
Joined: Fri May 05, 2023 5:28 am

Re: CustomFieldType + asmdef

Post 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
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

Re: CustomFieldType + asmdef

Post 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
customFieldType.png (47.99 KiB) Viewed 787 times

When you create new fields of this type, they should automatically be correct.
lgarczyn
Posts: 30
Joined: Fri May 05, 2023 5:28 am

Re: CustomFieldType + asmdef

Post by lgarczyn »

It works!

Went from

Image

to

Image

I've then updated the template from assets, then synced the assets to the template
User avatar
Tony Li
Posts: 22129
Joined: Thu Jul 18, 2013 1:27 pm

Re: CustomFieldType + asmdef

Post by Tony Li »

Great! I'm glad it's working now.
Post Reply