本文整理汇总了C#中UnityEngine.EventSystems.PointerEventData类的典型用法代码示例。如果您正苦于以下问题:C# PointerEventData类的具体用法?C# PointerEventData怎么用?C# PointerEventData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PointerEventData类属于UnityEngine.EventSystems命名空间,在下文中一共展示了PointerEventData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnDrag
public void OnDrag(PointerEventData eventData)
{
Vector3 newPosition;
newPosition = mainCam.ScreenToWorldPoint(eventData.position);
newPosition.z = 0f;
dragObject.transform.position = newPosition;
}
示例2: OnEndDrag
public void OnEndDrag(PointerEventData eventData)
{
try
{
if (inv.DragAndDropEnabled)
{
GetComponent<CanvasGroup>().blocksRaycasts = true;
transform.GetComponent<RectTransform>().anchoredPosition3D = startPosition;
bool foundParent = false;
for (int i = 0; i < inv.SlotList.Count; i++)
{
if (transform.parent == inv.SlotList[i])
{
foundParent = true;
}
}
if (foundParent == false)
{
transform.SetParent(startParent);
transform.GetComponent<RectTransform>().anchoredPosition3D = startPosition;
}
}
}
catch (Exception ex)
{
}
}
示例3: OnDrag
public void OnDrag(PointerEventData eventData) {
//Debug.Log ("OnDrag");
this.transform.position = eventData.position;
if(placeholder.transform.parent != placeholderParent)
placeholder.transform.SetParent(placeholderParent);
int newSiblingIndex = placeholderParent.childCount;
for(int i=0; i < placeholderParent.childCount; i++) {
if(this.transform.position.x < placeholderParent.GetChild(i).position.x) {
newSiblingIndex = i;
if(placeholder.transform.GetSiblingIndex() < newSiblingIndex)
newSiblingIndex--;
break;
}
}
placeholder.transform.SetSiblingIndex(newSiblingIndex);
}
示例4: OnPointerEnter
public void OnPointerEnter(PointerEventData eventData)
{
if(OnPointerEnterButton != null)
{
OnPointerEnterButton(this);
}
}
示例5: OnUp
void OnUp( PointerEventData eventData , GameObject go , string[] args )
{
if (enabled)
{
UI_TweenScale.Begin(tweenTarget.gameObject , duration , mScale).from = pressed;
}
}
示例6: OnEndDrag
public void OnEndDrag(PointerEventData eventData)
{
DroppingBirds sling = null;
//We could look up hovered[0] for the sling, the loop is just a safety measure in case something obstructs the sling
foreach (GameObject i in eventData.hovered)
{
if (i.name == "Sling")
{
sling = i.GetComponent<DroppingBirds>();
}
}
//if (eventData.pointerEnter && eventData.pointerEnter.CompareTag("SlingCanvas"))
//{
// sling = eventData.pointerEnter.GetComponent<DroppingBirds>();
//}
//If no sling was found in the hovered objects, delete the dragged bird sprite and end the function
if (!sling)
{
Instantiate(explosion, dragObject.transform.position + explosionOffset, Quaternion.identity);
Destroy(dragObject);
return;
}
//We add one bird of type X to the slingshot. After that we destroy the dragged sprite.
sling.birdList.Add(info.GetComponent<Bird>().prefab);
Destroy(dragObject);
//Now we update the canvas attached to the sling
sling.UpdateCanvas();
}
示例7: OnDrag
//拖动
public void OnDrag(PointerEventData evt)
{
if (listView != null)
{
// listView.OnScroll(evt);
}
}
示例8: OnBeginDrag
public void OnBeginDrag(PointerEventData eventData)
{
if (isSelectable) {
attackController.SpawnMarker ();
isDragging = true;
}
}
示例9: OnPointerDown
public void OnPointerDown(PointerEventData eventData){
if(!touched){
touched = true;
pointerID = eventData.pointerId;
origin = eventData.position;
}
}
示例10: OnDrag
public void OnDrag(PointerEventData eventData)
{
if (!cardIsMine) return;
this.transform.position = eventData.position;
if (placeholder.transform.parent != placeholderParent)
{
placeholder.transform.SetParent(placeholderParent);
}
int newSiblingIndex = placeholderParent.childCount;
for(int i = 0; i < placeholderParent.childCount; i++)
{
if(this.transform.position.x < placeholderParent.GetChild(i).position.x)
{
newSiblingIndex = i;
if(placeholder.transform.GetSiblingIndex() < newSiblingIndex)
{
newSiblingIndex--;
}
break;
}
}
placeholder.transform.SetSiblingIndex(newSiblingIndex);
}
示例11: Raycast
public override void Raycast(PointerEventData eventData, List<RaycastResult> resultAppendList)
{
if (eventCamera == null)
return;
var ray = eventCamera.ScreenPointToRay(eventData.position);
float dist = eventCamera.farClipPlane - eventCamera.nearClipPlane;
var hits = Physics2D.RaycastAll(ray.origin, ray.direction, dist, finalEventMask);
if (hits.Length != 0)
{
eventData.worldPosition = hits[0].point;
eventData.worldNormal = hits[0].normal;
for (int b = 0, bmax = hits.Length; b < bmax; ++b)
{
SpriteRenderer sr = hits[b].collider.gameObject.GetComponent<SpriteRenderer>();
var result = new RaycastResult
{
gameObject = hits[b].collider.gameObject,
module = this,
distance = Vector3.Distance(eventCamera.transform.position, hits[b].transform.position),
index = resultAppendList.Count,
sortingLayer = sr != null ? sr.sortingLayerID : 0,
sortingOrder = sr != null ? sr.sortingOrder : 0
};
resultAppendList.Add(result);
}
}
}
示例12: OnBeginDrag
public void OnBeginDrag(PointerEventData eventData)
{
itemBeingDragged = gameObject;
startPosition = transform.position;
startParent = transform.parent;
GetComponent<CanvasGroup> ().blocksRaycasts = false;
}
示例13: OnPointerEnter
public void OnPointerEnter(PointerEventData e)
{
if (!isActive) return;
tooltipController.SetTextsActive(title.Length > 0, desc.Length > 0);
tooltipController.OnActivate(title, desc);
}
示例14: OnPointerUp
public void OnPointerUp(PointerEventData eventData)
{
foreach (var dpadAxis in DpadAxis)
{
dpadAxis.TryRelease(eventData.pointerId);
}
}
示例15: OnPointerExit
public void OnPointerExit(PointerEventData data)
{
if (containerImage == null)
return;
containerImage.color = normalColor;
}