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 /
  • Help Room /
avatar image
0
Question by sandi397 · Feb 08, 2021 at 04:34 PM · inputpublicpublic variable

Public InputController class not showing on inspector

I have created an Input controller for my game and auto genereted a class for it. Now i try to include that class as a public variable on my PlayerController and subscribe move and jump actions to it, but the problem i have is my public variable doesnt show up. I am using Unity 2020.2.3 version of Unity.

Here is my PlayerController class:

 public class PlayerController : MonoBehaviour
 {
     //PRIVATE
     private Rigidbody2D Rb;
     private bool CanJump = true;
 
     //PUBLIC:
     public float Speed;
     public float JumpStrength;
     public InputController inputController;
 
     private void OnEnable()
     {
         inputController.Enable();
     }
     private void OnDisable()
     {
         inputController.Disable();
     }
 
     private void Awake()
     {
         inputController.Player.Jump.performed += _ => Jump();
         inputController.Player.Move.performed += ctx => Move(ctx.ReadValue<float>());
     }
 
     void Start()
     {
         Rb = GetComponent<Rigidbody2D>();
     }
 
     void Update()
     {
     }
 
     private void Jump()
     {
         //Debug.Log("jump");
         if (CanJump)
         {
             Rb.velocity = Vector2.up * JumpStrength;
         }
     }
 
     private void Move(float moveInput)
     {
         Rb.velocity = new Vector2(moveInput * Speed, Rb.velocity.y);
         //Debug.Log(moveInput);
     }
 }


And here is a picture where i only see the speed and jump height but not InputController: alt text

screenshot-5.png (12.4 kB)
Comment
Add comment · Show 3
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 Hellium · Feb 08, 2021 at 09:41 PM 0
Share

What is the InputController class?

If it's not a class inheriting from UnityEngine.Object, you need to add the [System.Serializable] attribute to the class definition.

  [System.Serializable]
  public class InputController
  {
        ...
  }
avatar image sandi397 Hellium · Feb 09, 2021 at 04:26 PM 0
Share

Unfortunately this does not solve my problem.

Here is my input class:

 // GENERATED AUTO$$anonymous$$ATICALLY FRO$$anonymous$$ 'Assets/Scripts/InputController.inputactions'
 
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.InputSystem;
 using UnityEngine.InputSystem.Utilities;
 
 public class @InputController : IInputActionCollection, IDisposable
 {
     public InputActionAsset asset { get; }
     public @InputController()
     {
         asset = InputActionAsset.FromJson("some json text i dint copy because it was too much characters....");
         // Player
         m_Player = asset.FindAction$$anonymous$$ap("Player", throwIfNotFound: true);
         m_Player_Jump = m_Player.FindAction("Jump", throwIfNotFound: true);
         m_Player_$$anonymous$$ove = m_Player.FindAction("$$anonymous$$ove", throwIfNotFound: true);
     }
 
     public void Dispose()
     {
         UnityEngine.Object.Destroy(asset);
     }
 
     public InputBinding? binding$$anonymous$$ask
     {
         get => asset.binding$$anonymous$$ask;
         set => asset.binding$$anonymous$$ask = value;
     }
 
     public ReadOnlyArray<InputDevice>? devices
     {
         get => asset.devices;
         set => asset.devices = value;
     }
 
     public ReadOnlyArray<InputControlScheme> controlSchemes => asset.controlSchemes;
 
     public bool Contains(InputAction action)
     {
         return asset.Contains(action);
     }
 
     public IEnumerator<InputAction> GetEnumerator()
     {
         return asset.GetEnumerator();
     }
 
     IEnumerator IEnumerable.GetEnumerator()
     {
         return GetEnumerator();
     }
 
     public void Enable()
     {
         asset.Enable();
     }
 
     public void Disable()
     {
         asset.Disable();
     }
 
     // Player
     private readonly InputAction$$anonymous$$ap m_Player;
     private IPlayerActions m_PlayerActionsCallbackInterface;
     private readonly InputAction m_Player_Jump;
     private readonly InputAction m_Player_$$anonymous$$ove;
     public struct PlayerActions
     {
         some player actions i did not copy...
     }
     public PlayerActions @Player => new PlayerActions(this);
     public interface IPlayerActions
     {
         void OnJump(InputAction.CallbackContext context);
         void On$$anonymous$$ove(InputAction.CallbackContext context);
     }
 }
 

avatar image sandi397 sandi397 · Feb 09, 2021 at 04:28 PM 0
Share

i was following this tutorial on youtube: NEW INPUT SYSTE$$anonymous$$ in Unity

0 Replies

· Add your reply
  • Sort: 

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

185 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 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 can I get gameObject from hirerchy to the public GameObject slot of a script attached to a prefab? 0 Answers

Is it possible to stop Unity from showing public Variables in the Inspector? 2 Answers

Public Arrays reset themselves 1 Answer

CS0103 and CS0246 with "public Text text;" 0 Answers

(Newbie's First Project) Object doesn't stop moving until long after I let go of the button 1 Answer


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