- Home /
Instance a list into a number of panels
I am trying to create a drag and drop list of football players. I have created code to instantiate the list from a List and now I want to add the drag and drop functionality. At the moment the list is instanced onto a Squad List Panel using this code
using System.Collections; using UnityEngine; using System.Collections.Generic;
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);
}
}
Each Player is displayed, with all his stats, in his own PlayerDisplayPrefab on the SquadListPanel but in order to make it drag and droppable I need each PlayerDisplayPrefab to be instanced onto its own landing panel (or something). But if I add a landing panels to the SquadListPanel my list is instanced below them and not on top of them.
How can I get each PlayerDisplayPrefab to be instanced into its own little landing panel? thanks
Your answer
Follow this Question
Related Questions
Click and drag an object 3 Answers
drag and drop into other cells 1 Answer
Can we limit game object within specific Collider/Colliders? 0 Answers
Drag And Drop não funciona 1 Answer
Move UI image on top of other elements 0 Answers