How to Event tigger when drag and drop complete
instantiate objects drag and drop system is implemented for collectibile card game ..i want when drag and drop is successfull done into relevant places ..some event ,(method) running
player can drag and drop what ever the card (object ) to given places ..order can be vary ,but how ever the each 4 slots fill with one card event should be trigger
Answer by Pengocat · Feb 24, 2017 at 06:45 PM
If you use Unity UI and an Eventsystem you could have a script on each item that implements IDropHandler and IDragHandler. Here is an example that simply drag and drop a colour.
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class MyDrag : MonoBehaviour, IDropHandler, IDragHandler
{
Image myImage;
void Awake()
{
myImage = GetComponent<Image>();
}
public void OnDrop(PointerEventData eventData)
{
if (eventData.pointerDrag != null)
{
myImage.color = eventData.pointerDrag.GetComponent<Image>().color;
}
}
public void OnDrag(PointerEventData eventData)
{
}
}
i have place holderslist ..once the child object is loaded ..i have to start the game so how can i check is the place holders are filled with cards?
What is place holerslist? Sorry I don't understand any of that.
there is gameobject list each 1,2,3...panels ..i have put it to that list..when player drag and drop give card to that panel..it takes as a ..child object.. now i wants to check whether the above listed game object has child or not?
@Pengocat i want to implement this kind of a game ..could you please go through the game and get the idea..i'm trying say.. http://www.transformersgames.co/game/transformers_action_pack.html