What is the current behavior?
I defined a Yarn Command taking a Vector2 parameter:
using System.Collections;
using UnityEngine;
using Yarn.Unity;
public class MoveCharacterCommand : MonoBehaviour
{
[YarnCommand("move_character")]
public static void MoveCharacter(string characterName, Vector2 to, float duration)
{
// do stuff
}
}
In the doc, Vector2 is not in the list of supported parameter types, so I would understand if it doesn't work.
The problem is that, whether I write in my script:
<<move_character CharacterName (1.0,1.0) 2.0>><<move_character CharacterName 1.0 2.0>>
or just
<<move_character CharacterName 2.0>>
I get error:
Can't call command move_character: incorrect number of parameters
UnityEngine.Debug:LogError (object)
Yarn.Unity.DialogueRunner:HandleCommand (Yarn.Command) (at ./Library/PackageCache/dev.yarnspinner.unity/Runtime/DialogueRunner.cs:862)
and that is not the error I'd expect.
Please provide the steps to reproduce, and if possible a minimal demo of the problem:
Copy-paste the command class above into some MoveCharacterCommand.cs script, and the script line above into some repro.yarn script.
What is the expected behavior?
I should have an error on parameter type Vector2 not being supported.
Or, if Vector2 is somewhat tolerated but skipped (defaults to (0, 0)) then passing 2 arguments instead of 3 should work.
Or, if Vector2 happens to be supported although not mentioned in doc, (1.0,1.0) should work.
Note: in the Yarn Spinner Commands preview window, I can see Vector2 listed in the parameter list, although it doesn't mean it's supported at runtime.
Or, if (1.0,1.0) is badly formatted, the error should be about bad format for conversion.
Ideally, the "incorrect number of parameters" error should mention the number of parameters passed vs expected. This would help me debug much more, and not just this Vector2 issue but even when all parameters are simple but I happened to miss one argument. I can open a feature request specifically to improve error messages if you want to tackle this separately.
Please tell us about your environment:
Yarn Spinner Version: 2.4.2
Unity Version: 6000.0.12f1
Other information
In my real project I actually use a coroutine, a command that returns IEnumerator, but it was easier to write a void return type for this issue.
I tried to look at source code returning Status CommandDispatchResult.StatusType.InvalidParameterCount in Actions.cs and I did find 2 different locations. In one, a custom error Message is set $"{this.Name} needs a target, but none was specified" but this is never shown in the console log so I cannot verify it. Maybe console should show the Message that is set along with Status?
What is the current behavior? I defined a Yarn Command taking a Vector2 parameter:
In the doc, Vector2 is not in the list of supported parameter types, so I would understand if it doesn't work.
The problem is that, whether I write in my script:
<<move_character CharacterName (1.0,1.0) 2.0>>
<<move_character CharacterName 1.0 2.0>>
or just<<move_character CharacterName 2.0>>
I get error:
and that is not the error I'd expect.
Please provide the steps to reproduce, and if possible a minimal demo of the problem: Copy-paste the command class above into some MoveCharacterCommand.cs script, and the script line above into some repro.yarn script.
What is the expected behavior? I should have an error on parameter type Vector2 not being supported.
Or, if Vector2 is somewhat tolerated but skipped (defaults to (0, 0)) then passing 2 arguments instead of 3 should work.
Or, if Vector2 happens to be supported although not mentioned in doc, (1.0,1.0) should work.
Note: in the Yarn Spinner Commands preview window, I can see Vector2 listed in the parameter list, although it doesn't mean it's supported at runtime.
Or, if (1.0,1.0) is badly formatted, the error should be about bad format for conversion.
Ideally, the "incorrect number of parameters" error should mention the number of parameters passed vs expected. This would help me debug much more, and not just this Vector2 issue but even when all parameters are simple but I happened to miss one argument. I can open a feature request specifically to improve error messages if you want to tackle this separately.
Please tell us about your environment:
Other information
In my real project I actually use a coroutine, a command that returns IEnumerator, but it was easier to write a void return type for this issue.
I tried to look at source code returning Status
CommandDispatchResult.StatusType.InvalidParameterCount
in Actions.cs and I did find 2 different locations. In one, a custom error Message is set$"{this.Name} needs a target, but none was specified"
but this is never shown in the console log so I cannot verify it. Maybe console should show the Message that is set along with Status?