2016-02-13 29 views
0

因此,我正在一個項目中工作,這突然出現。控制檯錯誤是`CrossPlatformInputManager'在當前上下文中不存在'

資產/ StandardAssets /汽車/飛機/腳本/ AeroplaneUserControl2Axis.cs(29,27):錯誤CS0103:名稱'CrossPlatformInputManager「不會在目前情況下」

存在

以下是腳本,它是指:我覺得你沒有StandardAssets模塊

using System; 
using UnityEngine; 
using UnityStandardAssets.CrossPlatformInput; 

namespace UnityStandardAssets.Vehicles.Aeroplane 
{ 
    [RequireComponent(typeof (AeroplaneController))] 
    public class AeroplaneUserControl2Axis : MonoBehaviour 
    { 
     // these max angles are only used on mobile, due to the way pitch and roll input are handled 
     public float maxRollAngle = 80; 
     public float maxPitchAngle = 80; 

     // reference to the aeroplane that we're controlling 
     private AeroplaneController m_Aeroplane; 


     private void Awake() 
     { 
      // Set up the reference to the aeroplane controller. 
      m_Aeroplane = GetComponent<AeroplaneController>(); 
     } 


     private void FixedUpdate() 
     { 
      // Read input for the pitch, yaw, roll and throttle of the aeroplane. 
      float roll = CrossPlatformInputManager.GetAxis("Horizontal"); 
      float pitch = CrossPlatformInputManager.GetAxis("Vertical"); 
      bool airBrakes = CrossPlatformInputManager.GetButton("Fire1"); 

      // auto throttle up, or down if braking. 
      float throttle = airBrakes ? -1 : 1; 
#if MOBILE_INPUT 
      AdjustInputForMobileControls(ref roll, ref pitch, ref throttle); 
#endif 
      // Pass the input to the aeroplane 
      m_Aeroplane.Move(roll, pitch, 0, throttle, airBrakes); 
     } 


     private void AdjustInputForMobileControls(ref float roll, ref float  pitch, ref float throttle) 
     { 
      // because mobile tilt is used for roll and pitch, we help out by 
      // assuming that a centered level device means the user 
      // wants to fly straight and level! 

      // this means on mobile, the input represents the *desired* roll angle of the aeroplane, 
      // and the roll input is calculated to achieve that. 
      // whereas on non-mobile, the input directly controls the roll of the aeroplane. 

      float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad; 
      float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad; 
      roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle),  -1, 1); 
      pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1); 

      // similarly, the throttle axis input is considered to be the  desired absolute value, not a relative change to current throttle. 
      float intendedThrottle = throttle*0.5f + 0.5f; 
      throttle = Mathf.Clamp(intendedThrottle - m_Aeroplane.Throttle,  -1, 1); 
     } 
    } 
} 

回答

0

。運行統一安裝程序並安裝StandardAssets軟件包。

+0

這並未解決問題。我仍然有同樣的錯誤 – BrookDaCow

0

展開標準資產文件夾,右鍵單擊crossplatforminput文件夾並選擇導入包,然後安裝包。轉到腳本並在頂部添加using UnityStandardAssets;

相關問題