How to Parse actions with OnKeyDownTrigger and parameter

I need to ActionManager.Parse an action with a OnKeyDownTrigger. I can serealize and parse an action if no parameter is provided with the trigger. e.g.

            var action = new BABYLON.SetValueAction(
                    BABYLON.ActionManager.OnKeyDownTrigger,
                    scene,
                    'clearColor',
                    BABYLON.Color3.White()
                )

if a parameter is provided:

            var action = new BABYLON.SetValueAction(
                    {
                        trigger: BABYLON.ActionManager.OnKeyDownTrigger,
                        parameter: 'r'
                    },
                    scene,
                    'clearColor',
                    BABYLON.Color3.White()
                )

the parsed action doesn’t work.

Is there an option to parse an action with paramter?

It feels like trigger serialization is incorrect in this case. i’ll ask others from @GeneralQuestions to maybe chip in here.

The error I see here is that the trigger is being serialized to:

"name": "OnKeyUpTrigger",
                            "properties": [
                                {
                                    "name": "parameter",
                                    "targetType": null,
                                    "value": {
                                        "0": "r",
                                        "length": 1
                                    }
                                }
                            ]

instead of

{
                        trigger: BABYLON.ActionManager.OnKeyDownTrigger,
                        parameter: 'r'
                    },

. A different solution would be the way we are parsing a trigger, but there are many edge cases we need to take into account before fixing it.

I agree there’s something wrong with the serialization and/or the parsing…

1 Like

will be fixed by Fix Action Deserialization by sebavan · Pull Request #13436 · BabylonJS/Babylon.js · GitHub

2 Likes