Chipmunk
8dabc472f7
Previously, to check if touch input should be used, the game checked if the runtime platform was Android or iOS. As such, using a mouse on these platforms (well, Android, did not test iOS) does not work. On other platforms, touch input appeared to work, however since it was technically mouse input features, some things, such as zooming in and out of levels did not work. This commit should fix that for all platforms. Instead of checking the runtime platform, now, it checks if the device supports touchscreen (regardless of platform), and if there is at least one current touch. As such, both types of input should now be supported on all platforms. (this was tested on a windows 8.1 tablet pc)
39 lines
809 B
C#
39 lines
809 B
C#
using UnityEngine;
|
|
|
|
public class DeviceInfo
|
|
{
|
|
public static bool UsesTouchInput
|
|
{
|
|
get
|
|
{
|
|
return Input.touchSupported && Input.touchCount != 0; // * Input.touchCount is checked so that if there are no touches, mouse input will be used (this is assummed to be called on every update)
|
|
}
|
|
}
|
|
|
|
public static DeviceFamily ActiveDeviceFamily
|
|
{
|
|
get
|
|
{
|
|
return DeviceInfo.DeviceFamily.Android;
|
|
}
|
|
}
|
|
|
|
public static bool IsDesktop
|
|
{
|
|
get
|
|
{
|
|
RuntimePlatform runtimePlatform = Application.platform;
|
|
return runtimePlatform == RuntimePlatform.OSXEditor || runtimePlatform == RuntimePlatform.OSXPlayer || runtimePlatform == RuntimePlatform.WindowsPlayer || runtimePlatform == RuntimePlatform.WindowsEditor;
|
|
}
|
|
}
|
|
|
|
public enum DeviceFamily
|
|
{
|
|
Ios,
|
|
Android,
|
|
Pc,
|
|
Osx,
|
|
BB10,
|
|
WP8
|
|
}
|
|
}
|