Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Engine Stripping

Discussion in 'Input System' started by sniffle63, Jan 25, 2020.

  1. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    I can't get the input system to work in WebGL after performing engine stripping on medium or high


    I tried adding the
    [assembly: Preserve]

    to the top of the auto-generated class, but it still strips it and not sure what else to try :)
     
  2. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    Just to make sure I follow: the problem is that the C# class that is auto-generated for an .inputactions asset is getting stripped? If so, do you have code actually referencing the generated class? If not, stripping sounds like expected behavior.
     
  3. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    I am using the auto-generated, PlayerInputActions class, in my player's input controller script to move my player using


    Code (CSharp):
    1.  
    2.     public PlayerInputActions InputActions { get; set; }
    3.  
    4.     private void UpdateAxisWithInput(InputAction.CallbackContext context)
    5.     {
    6.         var value = context.ReadValue<Vector2>();
    7.  
    8.         //bad code for checking if pressing x movement and y movement key
    9.         if (Math.Abs(value.x) >= 0.1f && Math.Abs(value.y) >= 0.1f)
    10.         {
    11.             value = new Vector2(0, 1);//just setting x to 0 and y to 1
    12.         }//help
    13.  
    14.         _axis = value != Vector2.zero ? value : Axis;
    15.     }
    16.  
    17.     public void OnEnable()
    18.     {
    19.         InputActions.Pacman.Move.performed += UpdateAxisWithInput;
    20.         InputActions.Enable();
    21.     }
    22.  
    23.     public void OnDisable()
    24.     {
    25.         InputActions.Pacman.Move.performed -= UpdateAxisWithInput;
    26.         InputActions.Disable();
    27.     }
    Stipping on low, everything works
    Stripping above low, everything works but my input
     
  4. Rene-Damm

    Rene-Damm

    Joined:
    Sep 15, 2012
    Posts:
    1,779
    I see. Thank you for the details. Opened a ticket and we'll have a look. Would expect those references there to keep everything relevant in the build but looks like that isn't happening.
     
    sniffle63 likes this.
  5. Malevskii

    Malevskii

    Joined:
    Sep 23, 2013
    Posts:
    3
    @Rene-Damm
    Same here, Unity 2019.2.17f1 + iOS + DualShock4 + stripping=high

    Code (CSharp):
    1. Could not create a device for 'DUALSHOCK 4 Wireless Controller (iOS)' (exception: System.ArgumentException: Cannot find input control 'touchpadButton'
    2. Parameter name: path
    3.   at UnityEngine.InputSystem.InputControl.GetChildControl (System.String path) [0x00000] in <00000000000000000000000000000000>:0
    4.   at UnityEngine.InputSystem.InputControl.GetChildControl[TControl] (System.String path) [0x00000] in <00000000000000000000000000000000>:0
    5.   at UnityEngine.InputSystem.DualShock.DualShockGamepad.FinishSetup () [0x00000] in <00000000000000000000000000000000>:0
    6.   at UnityEngine.InputSystem.InputControl.CallFinishSetupRecursive () [0x00000] in <00000000000000000000000000000000>:0
    7.   at UnityEngine.InputSystem.InputDevice.Build[TDevice] (System.String layoutName, System.String layoutVariants, UnityEngine.InputSystem.Layouts.InputDeviceDescription deviceDescription) [0x00000] in <00000000000000000000000000000000>:0
    8.   at UnityEngine.InputSystem.InputManager.AddDevice (UnityEngine.InputSystem.Utilities.InternedString layout, System.Int32 deviceId, System.String deviceName, UnityEngine.InputSystem.Layouts.InputDeviceDescription deviceDescription, UnityEngine.InputSystem.InputDevice+DeviceFlags deviceFlags, UnityEngine.InputSystem.Utilities.InternedString variants) [0x00000] in <00000000000000000000000000000000>:0
    9.   at UnityEngine.InputSystem.InputManager.AddDevice (UnityEngine.InputSystem.Layouts.InputDeviceDescription description, System.Boolean throwIfNoLayoutFound, System.String deviceName, System.Int32 deviceId, UnityEngine.InputSystem.InputDevice+DeviceFlags deviceFlags) [0x00000] in <00000000000000000000000000000000>:0
    10.   at UnityEngine.InputSystem.InputManager.OnNativeDeviceDiscovered (System.Int32 deviceId, System.String deviceDescriptor) [0x00000] in <00000000000000000000000000000000>:0
    11.   at System.Action`2[T1,T2].Invoke (T1 arg1, T2 arg2) [0x00000] in <00000000000000000000000000000000>:0 )
    12. UnityEngine.InputSystem.InputManager:OnNativeDeviceDiscovered(Int32, String)
    13. System.Action`2:Invoke(T1, T2)
     
    Last edited: Jan 30, 2020