Skip to content

Commit

Permalink
[ui] Adding missing files.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Cosgrave committed Dec 6, 2016
1 parent 1ed41c6 commit e859ace
Showing 2 changed files with 130 additions and 0 deletions.
77 changes: 77 additions & 0 deletions UnityEngine.UI/EventSystem/InputModules/BaseInput.cs
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);
}
}
}
53 changes: 53 additions & 0 deletions UnityEngine.UI/UI/Core/Utility/ReflectionMethodsCache.cs
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;
}
}
};
}

0 comments on commit e859ace

Please sign in to comment.