Skip to content

Instantly share code, notes, and snippets.

@urahimono
Created July 25, 2016 07:54
Embed
What would you like to do?
UnityのCrossPlatformInputを使う その5 MobileSingleStickControl編
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class Test : MonoBehaviour
{
[SerializeField]
private float m_speedScale = 5.0f;
void Update()
{
float vertical = CrossPlatformInputManager.GetAxis( "Vertical" );
float horizontal = CrossPlatformInputManager.GetAxis( "Horizontal" );
Vector3 addPos = new Vector3( horizontal, vertical, 0.0f ) * m_speedScale;
transform.position += addPos * Time.deltaTime;
if( CrossPlatformInputManager.GetButton( "Jump" ) )
{
GetComponent<Renderer>().material.color = Color.red;
}
else
{
GetComponent<Renderer>().material.color = Color.white;
}
}
} // class Test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment