Search Unity

Bug Custom Input Processor cannot serialize String value

Discussion in 'Input System' started by MathiasYde, Jan 30, 2023.

  1. MathiasYde

    MathiasYde

    Joined:
    Oct 8, 2017
    Posts:
    1
    I am trying to write a custom processor for a mouse & keyboard-only control scheme for my 2D game. I'm planning to use this custom processor in a 'Look' input value that points in the direction the player wants to look towards, this is simple for a gamepad-only control scheme (just the joystick value). However, I want the player to have to move their mouse to look around - therefore I thought a custom processor for this mouse & keyboard-only control scheme would be ideal. But it seems that Unity is unable to serialize my String value for this custom processor.

    I followed this article on the documentation: https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/manual/Processors.html

    Code (CSharp):
    1.  
    2. using System;
    3. using UnityEditor;
    4. using UnityEngine;
    5. using UnityEngine.InputSystem;
    6.  
    7. #if UNITY_EDITOR
    8. [InitializeOnLoad]
    9. #endif
    10. public class PointTowardsCursorInputProcessor  : InputProcessor<Vector2> {
    11. [Tooltip("Target GameObject with this tag")]
    12. public String Tag = "Player";
    13.  
    14. #if UNITY_EDITOR
    15. static PointTowardsCursorInputProcessor () {
    16.   Initialize();
    17. }
    18. #endif
    19.  
    20. [RuntimeInitializeOnLoadMethod]
    21. static void Initialize() {
    22.   InputSystem.RegisterProcessor<PointTowardsCursorInputProcessor >();
    23. }
    24.  
    25. public override Vector2 Process(Vector2 value, InputControl control) {
    26.   return value;
    27. }
    28. }
    29.  
    Error code:
    upload_2023-1-30_23-38-50.png

    Version info:
    InputSystem version: 1.4.4
    Unity version: 2021.3.16f1[/B]
     

    Attached Files:

  2. rdjadu

    rdjadu

    Joined:
    May 9, 2022
    Posts:
    116
    String parameters are not currently supported.