- Home /
Make an Instanced List Drag and Droppable
I am building a football manager sim. I have a List of Players and when the game starts the Players are instanced into the SquadList using PlayerDisplayPrefabs. I would like this SquadList to be drag and droppable with the ability to swap players and their stats in and out of the first team.
I have added the drag functionality to the Prefab but in order to add the drop functionality I need to have each Prefab instance onto its own Panel rather than the SquadList Panel.
But if I put landing Panels onto the SquadList Panel my list is instanced below these Panels and not on top. This is what it looks like at the moment. I would like each item to be instanced into its own landing spot rather than below them as it is at the moment. The script is below.
Any ideas? Thanks very much.
(to the moderator...I have already posted a similar question but it wasn't very clear and I do not know how to delete it and swap it with this one? thanks)

This is the code I am using to instantiate the list to the SquadDisplay Panel
using System.Collections;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.UI;
public class SquadDisplay : MonoBehaviour
{
public Transform targetTransform;
public PlayerDisplay playerDisplayPrefab;
public List<Player> items = new List<Player>();
// Start is called before the first frame update
void Start()
{
foreach (Player item in items)
{
PlayerDisplay display = (PlayerDisplay)Instantiate(playerDisplayPrefab);
display.transform.SetParent(targetTransform, false);
display.Prime(item);
}
}
// Update is called once per frame
void Update()
{
}
}
Your answer
Follow this Question
Related Questions
Error in raycast using with drag drop of objects 0 Answers
Can no longer drag in images/sprites into and within my project folder 2 Answers
How to drag and drop an UI Image on a 2D GameObject? 0 Answers
PhotonNetwork.Instantiate() doesn't instantiate the prefab. Only Instantiate() works. Why? 0 Answers
How to fix the problem of object instantiating partially? 0 Answers