Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by detzt · Jun 22, 2020 at 09:11 PM · inputserializationsystem

Does SerializeField work when extending the Input System?

I am extending the new Input System with a custom Processor and Interaction.

Using a public field shows up in the Editor as expected:

 public float tweakableValue = 2.5f;

However, I prefer to use SerializeField to indicate that this is set in the Editor and prevent access from other classes:

 [SerializeField]
 private float tweakableValue = 2.5f;

While this works perfectly well for any MonoBehaviour, it does not show up in the Input Action Editor.

Am I missing something or is this simply not supported by the new Input System? If so, should I report a bug?


Edit: Here is an example where I extend the InputProcessor:

 using UnityEngine;
 using UnityEngine.InputSystem;
  
 #if UNITY_EDITOR
 using UnityEditor;
 #endif
 
 namespace dyco {
 
 /// <summary>
 /// Input processor to rotate a two dimensional input by the configured degrees
 /// </summary>
 #if UNITY_EDITOR
 [InitializeOnLoad]
 #endif
 public class RotateProcessor : InputProcessor<Vector2> {
     [Tooltip("The angle in degrees to rotate the vector by")]
     public float RotateDegrees = 45f;
 
 #if UNITY_EDITOR
     static RotateProcessor() {
         Initialize();
     }
 #endif
 
     [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
     private static void Initialize() {
         InputSystem.RegisterProcessor<RotateProcessor>();
     }
 
     /// <summary>Rotates the given vector <paramref name="value"/> by the configured <see cref="RotateDegrees"/></summary>
     public override Vector2 Process(Vector2 value, InputControl control) {
         return value.Rotate(RotateDegrees);
     }
 }
 }
 
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jun 23, 2020 at 04:13 AM

How do you extend the input system? Most of Unity's build-in classes have a dedicated custom editor created for that class. So if you derive your own class from one of them, you often have to create / extend the editor as well.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image detzt · Jun 23, 2020 at 11:27 AM 0
Share

I've edited my answer to include a complete example.

Since the posted version with a public field shows up fine in the Input Action Editor and the SerielizedField shows up fine within the general editor, I don't think I have to extend the Editor as well, but please correct me if that is indeed the issue.

avatar image Bunny83 detzt · Jun 23, 2020 at 11:56 AM 1
Share

Well in that case you can not use private fields. You do not really instantiate an InputProcessor yourself anywhere. You do not interact with this class anywhere. The input system should do that internally. So where and how would you actually inspect an instance of this class?


As you can read in the documentation, InputProcessors can not have "mutable state" (so no variables which are changed during runtime) but can have "parameters". Those parameters (which have to be public fields) can be set through a json config string or the InputControl attribute like this:

 [InputControl(layout = "Axis", processors = "rotate(RotateDegrees=4)"]
 public float axis;

Note, as you can read here, since you didn't specify a name for your processor, Unity will automatically take your class name and clips the suffix "Processor" if present. The processor name is not case sensitive.


ps: I haven't use the new input system yet, so I can't say much about it. However as far as I know it's mainly written in plain C#. So most of Unity's reflection serialization magic probably does not apply to those classes. They most likely are not serialized at all. Processors are probably just instantiated once by the system and the system changes the "parameters" as needed. Though that's just a guess ^^.

avatar image detzt Bunny83 · Jun 23, 2020 at 01:16 PM 0
Share

You can inspect the processor in the editor of an .inputactions asset. It looks like this:

Input Action Editor

Note: Uploading the file directly gave me an error "Error parsing the uploaded file." and I will remove the link from the cloud storage in the future.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

164 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to consume input when automatically switching control schemes through a Player Input Component 0 Answers

How to mimic Unity's Components based System 1 Answer

Class variable wont show up in inspector with new Unity Input System 1 Answer

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

New Input System 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges