The previous project implemented an information function that builds skills through IDs, and this issue starts with a list of role skills.
Demand:
After selecting a role, click on the feel skill bar to pop up all of the characters ' skills.
Analysis:
First you need to get all the skills of the character, then add it through Nguitools.addchild (), and finally manage the sort through the grid.
How to get: Set up an array, store the ID group of the skill, and batch add through foreach;
How to add: The parent class is Grid.gameobject, the subclass is Skillitem, and the requirement will skillitem through its setid to set the information before adding;
How to sort: use a grid in a grid. Addchlid () to implement management.
Based on the above analysis, the following code is written:
Class Skillui
{
Public int[] Sowrdskillidlist;
Public int[] Magicianskilllist;
Private Playerstatus Playerstatus;
Public Gameobject Skillitemprefab;
public grid grid;
void Start ()
{
int[] list = null;
Playerstaus = Gameobject.findgameobjectwithtag (Tags.player). Getcompnent<playerstatus> ();
Switch (playerstatus.herotype)
{
Case Herotype.magicina:
list = Magicianskilllist;
Break
Case Herotype.swordman:
list = Swordmanskilllist;
Break
}
foreach (int id in list)
{
Gameobject Goitem = Nguitools.addchild (Grid.gameobject,skillitemprefab);
Grid. AddChild (Goitem.transform);
Goitem.getcompnent<skillitem> (). SetId (ID);
}
}
}
This implements the ability to display the skill list at the beginning of the game.
UNITY3D-RPG Project Study notes (28)