本文整理汇总了C#中PlayerController.resetControllerCache方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerController.resetControllerCache方法的具体用法?C# PlayerController.resetControllerCache怎么用?C# PlayerController.resetControllerCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerController
的用法示例。
在下文中一共展示了PlayerController.resetControllerCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: mapController
private static void mapController(PlayerController playerController)
{
/* constructs a specific string for every axis the controller type has
* these strings can be used to acces Unity input directly later
* the strins are stored in the given mapping container
* we also set invert flags for each axis here
* ToDo test and adjust all invert flags
*/
// we also reset all cached button states
playerController.resetControllerCache();
// convert the player enum into an integer
int player = (int)playerController.player;
// construct axis name for the controller type and player number
// the generic axis are different for Android ports and other platforms (Editor)
// the inversed encoding for axis values is also cared for here
// this is solved by precompile makros
switch (playerController.mapType)
{
#if !UNITY_EDITOR && UNITY_ANDROID
case OuyaMapType.Generic_ANDROID:
// tested mapping for OuyaGameController connected to HTCOne
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false;
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true;
playerController.map_RX = string.Format("Joy{0} Axis 4", player); playerController.invert_RX = false;
playerController.map_RY = string.Format("Joy{0} Axis 5", player); playerController.invert_RY = true;
playerController.map_LT = string.Format("Joy{0} Axis 6", player); playerController.invert_LT = false;
playerController.map_RT = string.Format("Joy{0} Axis 3", player); playerController.invert_RT = false;
// the dpad is not analog and therefore not mapped as an axis
playerController.map_DX = null; playerController.invert_DX = false;
playerController.map_DY = null; playerController.invert_DY = false;
break;
case OuyaMapType.Broadcom_ANDROID:
// tested mapping for OuyaGameController connected to Nexus7
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false;
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true;
playerController.map_RX = string.Format("Joy{0} Axis 4", player); playerController.invert_RX = false;
playerController.map_RY = string.Format("Joy{0} Axis 5", player); playerController.invert_RY = true;
playerController.map_LT = string.Format("Joy{0} Axis 3", player); playerController.invert_LT = false;
playerController.map_RT = string.Format("Joy{0} Axis 6", player); playerController.invert_RT = false;
// the dpad is not analog and therefore not mapped as an axis
playerController.map_DX = null; playerController.invert_DX = false;
playerController.map_DY = null; playerController.invert_DY = false;
break;
case OuyaMapType.MogaPro_ANDROID:
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false;
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true;
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false;
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = false;
playerController.map_LT = string.Format("Joy{0} Axis 8", player); playerController.invert_LT = false;
playerController.map_RT = string.Format("Joy{0} Axis 7", player); playerController.invert_RT = false;
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false;
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = false;
break;
case OuyaMapType.GameStick_CONSOLE:
// tested mapping for GameStick console with native controller
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false; // checked
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = true; // checked
// the GameStick controller has no triggers at all
playerController.map_LT = null; playerController.invert_LT = false;
playerController.map_RT = null; playerController.invert_RT = false;
break;
case OuyaMapType.PS3_ANDROID:
case OuyaMapType.Ouya_CONSOLE:
// tested mapping for OUYA console with native controller
// tested mapping for PS3 controller connected to the OUYA console
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 5", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 6", player); playerController.invert_RT = false; // checked
// the dpad is not analog and therefore not mapped as an axis
playerController.map_DX = null; playerController.invert_DX = false;
playerController.map_DY = null; playerController.invert_DY = false;
break;
case OuyaMapType.XBOX360_ANDROID:
// tested mapping for XBOX360 USB controller connected to the OUYA console
// tested mapping for XBOX360 USB controller connected to the OUYA console
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 7", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 8", player); playerController.invert_RT = false; // checked
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false; // checked
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = true; // checked
break;
case OuyaMapType.XBOX360_ANDROID_wireless:
//.........这里部分代码省略.........
示例2: mapController
private static void mapController(PlayerController playerController)
{
/* constructs a specific string for every axis the controller type has
* these strings can be used to acces Unity input directly later
* the strins are stored in the given mapping container
* we also set invert flags for each axis here
* ToDo test and adjust all invert flags
*/
// this is a good point to reset the input in Unity
Input.ResetInputAxes();
// we also reset all cached button states
playerController.resetControllerCache();
// convert the player enum into an integer
int player = (int)playerController.player;
// construct axis name for the controller type and player number
// the generic axis are different for Android ports and other platforms (Editor)
// the inversed encoding for axis values is also cared for here
// this is solved by precompile makros
switch (playerController.controllerType)
{
#if !UNITY_EDITOR && UNITY_ANDROID
case OuyaControllerType.Broadcom:
case OuyaControllerType.MogaPro:
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false;
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true;
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false;
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = false;
playerController.map_LT = string.Format("Joy{0} Axis 8", player); playerController.invert_LT = false;
playerController.map_RT = string.Format("Joy{0} Axis 7", player); playerController.invert_RT = false;
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false;
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = false;
break;
case OuyaControllerType.GameStick:
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false; // checked
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = true; // checked
// the GameStick controller has no triggers at all
playerController.map_LT = null; playerController.invert_LT = false;
playerController.map_RT = null; playerController.invert_RT = false;
break;
#endif
case OuyaControllerType.Ouya:
#if !UNITY_EDITOR && UNITY_ANDROID
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 5", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 6", player); playerController.invert_RT = false; // checked
// the dpad is not analog and therefore not mapped as an axis
playerController.map_DX = null; playerController.invert_DX = false;
playerController.map_DY = null; playerController.invert_DY = false;
#else
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 4", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 5", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 3", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 6", player); playerController.invert_RT = false; // checked
// the dpad is not analog and therefore not mapped as an axis
playerController.map_DX = null; playerController.invert_DX = false;
playerController.map_DY = null; playerController.invert_DY = false;
#endif
break;
case OuyaControllerType.XBox360:
#if !UNITY_EDITOR && UNITY_ANDROID
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 7", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 8", player); playerController.invert_RT = false; // checked
playerController.map_DX = string.Format("Joy{0} Axis 5", player); playerController.invert_DX = false; // checked
playerController.map_DY = string.Format("Joy{0} Axis 6", player); playerController.invert_DY = true; // checked
#else
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 4", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 5", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 9", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 10", player); playerController.invert_RT = false; // checked
playerController.map_DX = string.Format("Joy{0} Axis 6", player); playerController.invert_DX = false; // checked
playerController.map_DY = string.Format("Joy{0} Axis 7", player); playerController.invert_DY = false; // checked
#endif
break;
case OuyaControllerType.PS3:
#if !UNITY_EDITOR && UNITY_ANDROID
playerController.map_LX = string.Format("Joy{0} Axis 1", player); playerController.invert_LX = false; // checked
playerController.map_LY = string.Format("Joy{0} Axis 2", player); playerController.invert_LY = true; // checked
playerController.map_RX = string.Format("Joy{0} Axis 3", player); playerController.invert_RX = false; // checked
playerController.map_RY = string.Format("Joy{0} Axis 4", player); playerController.invert_RY = true; // checked
playerController.map_LT = string.Format("Joy{0} Axis 5", player); playerController.invert_LT = false; // checked
playerController.map_RT = string.Format("Joy{0} Axis 6", player); playerController.invert_RT = false; // checked
// the dpad is not analog and therefore not mapped as an axis
//.........这里部分代码省略.........