Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does component's field not support enum? #6

Open
vkensou opened this issue Nov 27, 2024 · 3 comments
Open

Does component's field not support enum? #6

vkensou opened this issue Nov 27, 2024 · 3 comments

Comments

@vkensou
Copy link

vkensou commented Nov 27, 2024

entityConverter.DataEntityToEntityPreserve report error message, if a component contain a enum field.

@friflo
Copy link
Owner

friflo commented Nov 27, 2024

Sure, component fields using an enum are supported.

You are using an EntityConverter. So your question is is more specific.
"Can component field's with an enum type serialized to JSON?"

This is also supported.

Made a small example see:
https://github.com/friflo/Friflo.Engine.ECS/blob/main/src/Tests/ECS/Serialize/Test_Serialize_enum.cs

  • Please paste the error
  • Can you create a test case like above?
  • Are you using Unity?

@vkensou
Copy link
Author

vkensou commented Nov 29, 2024

Sure, component fields using an enum are supported.

You are using an EntityConverter. So your question is is more specific. "Can component field's with an enum type serialized to JSON?"

This is also supported.

Made a small example see: https://github.com/friflo/Friflo.Engine.ECS/blob/main/src/Tests/ECS/Serialize/Test_Serialize_enum.cs

  • Please paste the error
  • Can you create a test case like above?
  • Are you using Unity?

I am using unity. my code like:

    public enum TestEnum
    {
        None = 1,
        Foo = 2,
    }

    public struct ComponentUseEnum: IComponent
    {
        public TestEnum testEnum;
        public int num;
    }

There are 2 issues:

  1. unity inspector not show the testEnum.
    image

  2. when load scene(or press play button), there is a error report, then components are all lost.

'components' element must be an object. was Error. id: 1, component: 'testEnum'
UnityEngine.Debug:LogError (object)
Friflo.Engine.UnityEditor.ECSEntitySerializer:WriteLinkComponentsToEntity (Friflo.Engine.Unity.ECSEntity) (at ./Packages/friflo-ecs-unity/Scripts/Runtime/Internal/ECSEntitySerializer.cs:48)
Friflo.Engine.Unity.ECSEntity:CreateEntity () (at ./Packages/friflo-ecs-unity/Scripts/Runtime/Components/ECSEntity.cs:135)
Friflo.Engine.Unity.ECSStore:CreateEntities () (at ./Packages/friflo-ecs-unity/Scripts/Runtime/Components/ECSStore.cs:73)
Friflo.Engine.Unity.Internal.SceneExtension:CreateEntities () (at ./Packages/friflo-ecs-unity/Scripts/Runtime/Internal/SceneExtension.cs:45)
Friflo.Engine.Unity.Internal.SceneExtension:.cctor () (at ./Packages/friflo-ecs-unity/Scripts/Runtime/Internal/SceneExtension.cs:33)
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[])

@friflo friflo transferred this issue from friflo/Friflo.Engine.ECS Nov 29, 2024
@friflo
Copy link
Owner

friflo commented Nov 29, 2024

Transferred issue to https://github.com/friflo/friflo-ecs-unity
as it is specific to Unity Editor integration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants