Line with Vector4UnityEngine in codegen appears sometimes and is causing errors

Hey :slightly_smiling_face:
I wrote a ts-script and sometimes (but not always) in the cs-codegen version of this script appears a line (it replaces another line), which is causing errors.

Instead of…

public UnityEngine.EventSystems.PointerEventData @onPointerClick;

this line appears and is causing errors:

public UnityEngine.Vector4UnityEngine.EventSystems.PointerEventData @onPointerClick;

When I revert this change, everything is working fine, till this line appears again next day, or if somebody else opens the project :slightly_smiling_face:

That is how the ts-script starts with:

export class PlaceOnClick extends Behaviour implements IPointerClickHandler {

    @serializable(Object3D)
    parent?: Object3D;
    
    @serializable(AudioRandomizer)
    audioRandomizer?: AudioRandomizer;
    
    onPointerClick = async (_args: PointerEventData) => {

Do you have an idea, how to get rid of this behavior? Thank you!

Original Post on Discord

by user 743203108271816774

Hello there – we have an experimental AI bot :robot: that might be able to help you with your question. Would you like to try this out?

How it works:
Reply to the messages of the bot that end with a thread_id to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.

Help requested: please wait a moment…

Here is what I found for you :brain: Discord

Hello Krempel,

It looks like the TS to C# Component Compiler is not correctly resolving the type for onPointerClick. The issue arises from TypeScript to C# translation where the compiler mistakenly combines Vector4 with PointerEventData into an invalid type.

To fix this, I recommend explicitly annotating the type by adding a comment at the top of the class. This instructs the compiler on the correct type to use.

//@type UnityEngine.EventSystems.PointerEventData
export class PlaceOnClick extends Behaviour implements IPointerClickHandler {

    @serializable(Object3D)
    parent?: Object3D;
    
    @serializable(AudioRandomizer)
    audioRandomizer?: AudioRandomizer;
    
    onPointerClick = async (_args: PointerEventData) => {
        // ...
    }
    // ...
}

Adding the //@type comment should help the compiler correctly resolve the type for onPointerClick. If the problem persists, check for any updates to Needle Engine or contact the Needle Engine support for further assistance.

1 messages left GPT 4
thread_0GuLlxYEifAb7Ke2Zi39XizW

Adding //@nonSerialized above the method might help as well: Editor Component Generator | Needle Engine Documentation

@marcel :cactus: do I have to import @nonSerialized from somethere, as I import @serializable?

It seems not to be a part of “@needle-tools/engine” moduel

by user 743203108271816774

its just a comment

oh sorry, i missed the // :slightly_smiling_face: it works! thank you

by user 743203108271816774