UNITY3D-RPG Project Study notes (28)

Source: Internet
Author: User
Tags addchild

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.