forked from Unity-Technologies/uGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philip Cosgrave
committed
Dec 6, 2016
1 parent
1ed41c6
commit e859ace
Showing
2 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
namespace UnityEngine.EventSystems | ||
{ | ||
public class BaseInput : UIBehaviour | ||
{ | ||
public virtual string compositionString | ||
{ | ||
get { return Input.compositionString; } | ||
} | ||
|
||
public virtual IMECompositionMode imeCompositionMode | ||
{ | ||
get { return Input.imeCompositionMode; } | ||
set { Input.imeCompositionMode = value; } | ||
} | ||
|
||
public virtual Vector2 compositionCursorPos | ||
{ | ||
get { return Input.compositionCursorPos; } | ||
set { Input.compositionCursorPos = value; } | ||
} | ||
|
||
public virtual bool mousePresent | ||
{ | ||
get { return Input.mousePresent; } | ||
} | ||
|
||
public virtual bool GetMouseButtonDown(int button) | ||
{ | ||
return Input.GetMouseButtonDown(button); | ||
} | ||
|
||
public virtual bool GetMouseButtonUp(int button) | ||
{ | ||
return Input.GetMouseButtonUp(button); | ||
} | ||
|
||
public virtual bool GetMouseButton(int button) | ||
{ | ||
return Input.GetMouseButton(button); | ||
} | ||
|
||
public virtual Vector2 mousePosition | ||
{ | ||
get { return Input.mousePosition; } | ||
} | ||
|
||
public virtual Vector2 mouseScrollDelta | ||
{ | ||
get { return Input.mouseScrollDelta; } | ||
} | ||
|
||
public virtual bool touchSupported | ||
{ | ||
get { return Input.touchSupported; } | ||
} | ||
|
||
public virtual int touchCount | ||
{ | ||
get { return Input.touchCount; } | ||
} | ||
|
||
public virtual Touch GetTouch(int index) | ||
{ | ||
return Input.GetTouch(index); | ||
} | ||
|
||
public virtual float GetAxisRaw(string axisName) | ||
{ | ||
return Input.GetAxisRaw(axisName); | ||
} | ||
|
||
public virtual bool GetButtonDown(string buttonName) | ||
{ | ||
return Input.GetButtonDown(buttonName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
|
||
namespace UnityEngine.UI | ||
{ | ||
internal class ReflectionMethodsCache | ||
{ | ||
public delegate bool Raycast3DCallback (Ray r, out RaycastHit hit, float f, int i); | ||
public delegate RaycastHit2D Raycast2DCallback (Vector2 p1, Vector2 p2, float f, int i); | ||
public delegate RaycastHit[] RaycastAllCallback (Ray r, float f, int i); | ||
public delegate RaycastHit2D[] GetRayIntersectionAllCallback (Ray r, float f, int i); | ||
|
||
// We call Physics.Raycast and Physics2D.Raycast through reflection to avoid creating a hard dependency from | ||
// this class to the Physics/Physics2D modules, which would otherwise make it impossible to make content with UI | ||
// without force-including both modules. | ||
public ReflectionMethodsCache() | ||
{ | ||
var raycast3DMethodInfo = typeof(Physics).GetMethod("Raycast", new[] {typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int)}); | ||
if (raycast3DMethodInfo != null) | ||
raycast3D = (Raycast3DCallback)UnityEngineInternal.ScriptingUtils.CreateDelegate(typeof(Raycast3DCallback), raycast3DMethodInfo); | ||
|
||
var raycast2DMethodInfo = typeof(Physics2D).GetMethod("Raycast", new[] {typeof(Vector2), typeof(Vector2), typeof(float), typeof(int)}); | ||
if (raycast2DMethodInfo != null) | ||
raycast2D = (Raycast2DCallback)UnityEngineInternal.ScriptingUtils.CreateDelegate(typeof(Raycast2DCallback), raycast2DMethodInfo); | ||
|
||
var raycastAllMethodInfo = typeof(Physics).GetMethod("RaycastAll", new[] {typeof(Ray), typeof(float), typeof(int)}); | ||
if (raycastAllMethodInfo != null) | ||
raycast3DAll = (RaycastAllCallback)UnityEngineInternal.ScriptingUtils.CreateDelegate(typeof(RaycastAllCallback), raycastAllMethodInfo); | ||
|
||
var getRayIntersectionAllMethodInfo = typeof(Physics2D).GetMethod("GetRayIntersectionAll", new[] {typeof(Ray), typeof(float), typeof(int)}); | ||
if (getRayIntersectionAllMethodInfo != null) | ||
getRayIntersectionAll = (GetRayIntersectionAllCallback)UnityEngineInternal.ScriptingUtils.CreateDelegate(typeof(GetRayIntersectionAllCallback), getRayIntersectionAllMethodInfo); | ||
} | ||
|
||
public Raycast3DCallback raycast3D = null; | ||
public RaycastAllCallback raycast3DAll = null; | ||
public Raycast2DCallback raycast2D = null; | ||
public GetRayIntersectionAllCallback getRayIntersectionAll = null; | ||
|
||
private static ReflectionMethodsCache s_ReflectionMethodsCache = null; | ||
|
||
public static ReflectionMethodsCache Singleton | ||
{ | ||
get | ||
{ | ||
if (s_ReflectionMethodsCache == null) | ||
s_ReflectionMethodsCache = new ReflectionMethodsCache(); | ||
return s_ReflectionMethodsCache; | ||
} | ||
} | ||
}; | ||
} |