Search Unity

First Person Controller Not Working in Editor When Switched to iOS Build Mode

Discussion in 'macOS' started by Excit0n, May 4, 2018.

  1. Excit0n

    Excit0n

    Joined:
    Jun 3, 2017
    Posts:
    3
    Hi there,

    When I switch my project to iOS build, my First Person Character controller stops responding to keyboard and mouse inputs in the editor. This means that prototyping the project and building it for iOS requires switching target builds and reimporting all of the assets (a time consuming pain in the butt). Any thoughts about how to retain FPC functionality in Editor with in iOS build mode? Thanks in advance! :)
     
  2. Excit0n

    Excit0n

    Joined:
    Jun 3, 2017
    Posts:
    3
    Okay, figured it out. FirstPersonController.cs references CrossPlatformInputManager.cs. This CrossPlatformInputManager script controls the inputs gets sent to FPC under various build types. In the constructor function static CrossPlatformInputManager(), there are two types of inputs - Mobile and Standalone. If you want the FPC to work with keyboard and mouse in the editor with a mobile target platform, just change activeInput = s_TouchInput to activeInput = s_HardwareInput under the #if MOBILE_INPUT statement. Then change it back when you are ready to build.
     
    hungrybelome likes this.
  3. AlharbiSunds

    AlharbiSunds

    Joined:
    Jul 17, 2018
    Posts:
    5
    Thank you so much !!
    Your comment is really helpful
    Many thanks
     
  4. hungrybelome

    hungrybelome

    Joined:
    Dec 31, 2014
    Posts:
    336
    Also you can just change the compile flag code to:

    Code (CSharp):
    1. #if MOBILE_INPUT && !UNITY_EDITOR
    2.             activeInput = s_TouchInput;
    3. #else
    4.             activeInput = s_HardwareInput;
    5. #endif
    so that you don't use touch input if playing from the editor.
     
  5. Excit0n

    Excit0n

    Joined:
    Jun 3, 2017
    Posts:
    3
    Yes!! That works great. I was getting really tired of forgetting to change the code after a build. Thanks!
     
  6. Turkm

    Turkm

    Joined:
    Feb 1, 2015
    Posts:
    7