码迷,mamicode.com
首页 > 编程语言 > 详细

Unity 游戏对象的组件列表

时间:2018-04-11 21:51:39      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:lis   cal   info   obj   img   start   call   list   collect   

描述:

   1 个游戏对象,上面有 4 个组件, 如图:

  技术分享图片

 

 脚本 Test_01 的内容,如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test_01 : MonoBehaviour {

    public List<Component> componentsList = new List<Component>();

    // Use this for initialization
    void Start () {
        Component[] componments = gameObject.GetComponents<Component>();
        componentsList = new  List<Component>(componments);
    }
    
    // Update is called once per frame
    void Update () {
        
    }
}

 

第一种情况: 运行Unity,List 里的顺序跟游戏对象的组件从上到下顺序一样.

 技术分享图片

第二种情况: 拖动任意一个组件,变化它的顺序,再运行,顺序还是一样.

 技术分享图片

  

Unity 游戏对象的组件列表

标签:lis   cal   info   obj   img   start   call   list   collect   

原文地址:https://www.cnblogs.com/Peng18233754457/p/8798571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!