Search Unity

something about the C# script in Unity live session

Discussion in 'Scripting' started by GinsoneWin, Dec 21, 2014.

  1. GinsoneWin

    GinsoneWin

    Joined:
    Dec 15, 2014
    Posts:
    36
    hi everyone , i just downloaded the sample assets from the asset store ,and there is a 2D character in it and the tutorials video "2D chracter controller" has used before,here the script whthin the 2D character prefab:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [RequireComponent(typeof(PlatformerCharacter2D))]
    4. public class Platformer2DUserControl : MonoBehaviour
    5. {
    6.     private PlatformerCharacter2D character;
    7.     private bool jump;
    8.  
    9.  
    10.     void Awake()
    11.     {
    12.         character = GetComponent<PlatformerCharacter2D>();
    13.     }
    14.  
    15.     void Update ()
    16.     {
    17.         // Read the jump input in Update so button presses aren't missed.
    18. #if CROSS_PLATFORM_INPUT
    19.         if (CrossPlatformInput.GetButtonDown("Jump")) jump = true;
    20. #else
    21.         if (Input.GetButtonDown("Jump")) jump = true;
    22. #endif
    23.  
    24.     }
    25.  
    26.     void FixedUpdate()
    27.     {
    28.         // Read the inputs.
    29.         bool crouch = Input.GetKey(KeyCode.LeftControl);
    30.         #if CROSS_PLATFORM_INPUT
    31.         float h = CrossPlatformInput.GetAxis("Horizontal");
    32.         #else
    33.         float h = Input.GetAxis("Horizontal");
    34.         #endif
    35.  
    36.         // Pass all parameters to the character control script.
    37.         character.Move( h, crouch , jump );
    38.  
    39.         // Reset the jump input once it has been used.
    40.         jump = false;
    41.     }
    42. }
    43.  
    and my question is : where is the CrossPlatformInput? i cant find it in the assets package and Unity Scripting API neither:(