• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# EventSystems.PointerEventData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中UnityEngine.EventSystems.PointerEventData的典型用法代码示例。如果您正苦于以下问题:C# PointerEventData类的具体用法?C# PointerEventData怎么用?C# PointerEventData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PointerEventData类属于UnityEngine.EventSystems命名空间,在下文中一共展示了PointerEventData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnDrag

 public void OnDrag(PointerEventData eventData)
 {
     Vector3 newPosition;
     newPosition = mainCam.ScreenToWorldPoint(eventData.position);
     newPosition.z = 0f;
     dragObject.transform.position = newPosition;
 }
开发者ID:Schadek,项目名称:SlingShooter,代码行数:7,代码来源:DragBird.cs


示例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)
            {

            }
        }
开发者ID:Reaw,项目名称:InventoryLight,代码行数:30,代码来源:ItemData.cs


示例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);


	}
开发者ID:marcochiu2-c,项目名称:MainMenu_uFrame1.6,代码行数:26,代码来源:Draggable.cs


示例4: OnPointerEnter

 public void OnPointerEnter(PointerEventData eventData)
 {
     if(OnPointerEnterButton != null)
     {
         OnPointerEnterButton(this);
     }
 }
开发者ID:Barabicus,项目名称:ATOMFIACHRA,代码行数:7,代码来源:SpellButton.cs


示例5: OnUp

 void OnUp( PointerEventData eventData , GameObject go , string[] args )
 {
     if (enabled)
     {
         UI_TweenScale.Begin(tweenTarget.gameObject , duration , mScale).from = pressed;
     }
 }
开发者ID:dotlive,项目名称:Unity3DuGUI-Toolkit,代码行数:7,代码来源:UI_ButtonScale.cs


示例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();
    }
开发者ID:Schadek,项目名称:SlingShooter,代码行数:32,代码来源:DragBird.cs


示例7: OnDrag

 //拖动
 public void OnDrag(PointerEventData evt)
 {
         if (listView != null)
     {
        // listView.OnScroll(evt);
     }
 }
开发者ID:ideadreamDefy,项目名称:Defy,代码行数:8,代码来源:ScrollListener.cs


示例8: OnBeginDrag

 public void OnBeginDrag(PointerEventData eventData)
 {
     if (isSelectable) {
         attackController.SpawnMarker ();
         isDragging = true;
     }
 }
开发者ID:zanefisher,项目名称:castle,代码行数:7,代码来源:flingMenu.cs


示例9: OnPointerDown

	public void OnPointerDown(PointerEventData eventData){
		if(!touched){
			touched = true;
			pointerID = eventData.pointerId;
			origin = eventData.position;
		}
	}
开发者ID:BinaryLeeward,项目名称:demo4Unity,代码行数:7,代码来源:SimpleTouchPad.cs


示例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);
    }
开发者ID:guntarspolis,项目名称:BakalauraDarbsTest,代码行数:28,代码来源:DraggableCard.cs


示例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);
                }
            }
        }
开发者ID:602147629,项目名称:Unity-ugui,代码行数:32,代码来源:Physics2DRaycaster.cs


示例12: OnBeginDrag

 public void OnBeginDrag(PointerEventData eventData)
 {
     itemBeingDragged = gameObject;
     startPosition = transform.position;
     startParent = transform.parent;
     GetComponent<CanvasGroup> ().blocksRaycasts = false;
 }
开发者ID:mdefasqu,项目名称:Unity,代码行数:7,代码来源:dragHandeler.cs


示例13: OnPointerEnter

	public void OnPointerEnter(PointerEventData e)
	{
        if (!isActive) return;

        tooltipController.SetTextsActive(title.Length > 0, desc.Length > 0);
		tooltipController.OnActivate(title, desc);
	}
开发者ID:AntlerOwl,项目名称:GGJ-Demons,代码行数:7,代码来源:Tooltip.cs


示例14: OnPointerUp

 public void OnPointerUp(PointerEventData eventData)
 {
     foreach (var dpadAxis in DpadAxis)
     {
         dpadAxis.TryRelease(eventData.pointerId);
     }
 }
开发者ID:melanke,项目名称:First-Mobile-Platform-Unity-Game,代码行数:7,代码来源:Dpad.cs


示例15: OnPointerExit

    public void OnPointerExit(PointerEventData data)
    {
        if (containerImage == null)
            return;

        containerImage.color = normalColor;
    }
开发者ID:globularcluster,项目名称:MotivAcao,代码行数:7,代码来源:DropMeMenu.cs


示例16: OnDrop

    public void OnDrop(PointerEventData eventData)
    {
        if(!item) //Se o slot estiver vazio
        {
            if(!slotDescarte)
            {
                DragHandler.itemSendoArrastado.transform.SetParent(transform, false);

                //Se for slot de combinacao, adiciona ao vetor de ervilhas na pos especifica
                if(this.slotComb)
                    geneComb.vetorErvilhas[numSlotComb - 1] = DragHandler.itemSendoArrastado;

                if(!DragHandler.podeGerar)
                    Spawner.acabeiMover = true;

                //Se o slot do pai FOR de combinacao, apaga o antigo e sobrescreve o novo
                else
                {
                    geneComb.vetorErvilhas[numSlotComb - 1] = DragHandler.itemSendoArrastado;
                    geneComb.vetorErvilhas[numSlotCombPai - 1] = null;
                }
            }
            else
            {
                if(DragHandler.podeGerar)
                    Destroy(DragHandler.itemSendoArrastado);
            }
        }
    }
开发者ID:eryckpedro,项目名称:GNT-Cyst,代码行数:29,代码来源:SlotManager.cs


示例17: OnPointerDown

    private bool pressingButtonToSplit; //bool for pressing a item to split it

    #endregion Fields

    #region Methods

    //splitting the item now
    public void OnPointerDown(PointerEventData data)
    {
        inv = transform.parent.parent.parent.GetComponent<Inventory>();
        if (transform.parent.parent.parent.GetComponent<Hotbar>() == null && data.button == PointerEventData.InputButton.Left && pressingButtonToSplit && inv.stackable && (inv.ItemsInInventory.Count < (inv.height * inv.width))) //if you press leftclick and and keycode
        {
            ItemOnObject itemOnObject = GetComponent<ItemOnObject>();                                                   //we take the ItemOnObject script of the item in the slot

            if (itemOnObject.item.itemValue > 1)                                                                         //we split the item only when we have more than 1 in the stack
            {
                int splitPart = itemOnObject.item.itemValue;                                                           //we take the value and store it in there
                itemOnObject.item.itemValue = (int)itemOnObject.item.itemValue / 2;                                     //calculate the new value for the splitted item
                splitPart = splitPart - itemOnObject.item.itemValue;                                                   //take the different

                inv.addItemToInventory(itemOnObject.item.itemID, splitPart);                                            //and add a new item to the inventory
                inv.stackableSettings();

                if (GetComponent<ConsumeItem>().duplication != null)
                {
                    GameObject dup = GetComponent<ConsumeItem>().duplication;
                    dup.GetComponent<ItemOnObject>().item.itemValue = itemOnObject.item.itemValue;
                    dup.GetComponent<SplitItem>().inv.stackableSettings();
                }
                inv.updateItemList();

            }
        }
    }
开发者ID:tiagomms,项目名称:Unity_Rush01,代码行数:34,代码来源:SplitItem.cs


示例18: OnPointerUp

	public void OnPointerUp(PointerEventData eventData){
		if(pointerID == eventData.pointerId){
			touched = false;
			direction = Vector2.zero;
			smoothDirection = Vector2.zero;
		}
	}
开发者ID:BinaryLeeward,项目名称:demo4Unity,代码行数:7,代码来源:SimpleTouchPad.cs


示例19: OnEndDrag

 public void OnEndDrag(PointerEventData eventData)
 {
     if (isSelectable) {
         Vector3 pointerPos = eventData.pointerCurrentRaycast.worldPosition;
         attackController.FlingMarker (pointerPos);
     }
 }
开发者ID:zanefisher,项目名称:castle,代码行数:7,代码来源:flingMenu.cs


示例20: OnBeginDrag

	public void OnBeginDrag (PointerEventData eventData)
	{
		//Debug.Log("begin dragging");
		currentParent = this.transform.parent;
		this.transform.SetParent(transferTransform);
		GetComponent<CanvasGroup>().blocksRaycasts = false;
	}
开发者ID:ryanhaglund,项目名称:Stoichiometry,代码行数:7,代码来源:Dragable.cs



注:本文中的UnityEngine.EventSystems.PointerEventData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Networking.NetworkConnection类代码示例发布时间:2022-05-26
下一篇:
C# EventSystems.BaseEventData类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap