Page 1 of 1

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

Posted: Fri Mar 01, 2024 2:21 am
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??

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

Posted: Fri Mar 01, 2024 9:04 am
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);

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

Posted: Fri Mar 15, 2024 8:01 am
by Luphan
Thank you for the reply!

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

Posted: Fri Mar 15, 2024 8:26 am
by Tony Li
Glad to help!