Search Unity

Resolved Can I generate the Input Action Asset C# class from code?

Discussion in 'Input System' started by dlorre, Jun 13, 2022.

  1. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    699
    I would like to ship a package with an input action asset. However if the target project does not have the input system installed, the c# file will trigger errors that I could fix by adding conditional defines (but it wouldn't be good practice because it is auto generated). So I was thinking of removing the C# file from the package and have it generated automatically or from editor code if the input system is installed. Is there a way to do that or a better way to achieve the same result?
     
  2. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    699
    I guess I can open the meta file, set generateWrapperCode to 1 and eventually reimport the asset, is it bad practice to edit meta files?
     
  3. dlorre

    dlorre

    Joined:
    Apr 12, 2020
    Posts:
    699
    Actually it turns out that if generate is true and the script does not exist, when the user imports the InputSystem the script will be created, so there is no need to edit the meta file.