-
using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; /// <summary> /// 个人信息 /// </summary> public class PersonInfo { public int ID; public int Age; public string Names; public PersonInfo(int id, int age, string name, List<PersonInfo> temp = null) { this.ID = id; this.Age = age; this.Names = name; temp?.Add(this); } } public class ListTools : MonoBehaviour { private List<PersonInfo> Persons = new List<PersonInfo>(); void Start () { //一种添加方法 var a = new PersonInfo(1001, 10, "小东", Persons); //正常添加方法 Persons.Add(new PersonInfo(1002, 15, "小马")); Persons.Add(new PersonInfo(1003, 20, "小牛")); Persons.Add(new PersonInfo(1004, 25, "小洗")); this.SortType(); } public void SortType() { //
Unity中常用 : List排序
最新推荐文章于 2025-03-10 17:08:04 发布