How to check whether field type is your custom field type?

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Luphan
Posts: 13
Joined: Wed Jun 07, 2023 5:39 am

How to check whether field type is your custom field type?

Post by Luphan »

Hi, I just add my own custom field type and it has shown in the dialogue editor as expected.

now I need to check whether the field I'm getting is having the same field type.

The Field class has a member 'type' which will give me the information of target field's type.

It is an Enum, and of course the enum list dose not contain my custom field type, unless I add one into the list.

Base on my understanding, It would be unwise to modify any of the code within Dialogue System, otherwise in the future update all my modification will lost.

So...what will be the best way to check whether the target type is my custom field type??
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to check whether field type is your custom field type?

Post by Tony Li »

Hi,

If you have a Field object, its typeString property will be the name of your custom field type class.

For example, the Dialogue System Extras page has a custom field type named "CustomFieldType_Asset" that lets you assign assets (sprites, audio clips, etc.) to a field. To check if a field is this type:

Code: Select all

bool isAssetFieldType = someField.typeString == nameof(CustomFieldType_Asset);
Luphan
Posts: 13
Joined: Wed Jun 07, 2023 5:39 am

Re: How to check whether field type is your custom field type?

Post by Luphan »

Thank you for the reply!
User avatar
Tony Li
Posts: 22112
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to check whether field type is your custom field type?

Post by Tony Li »

Glad to help!
Post Reply