unity获取脚本组件 您所在的位置:网站首页 unity获取组件脚本 unity获取脚本组件

unity获取脚本组件

2023-10-01 22:43| 来源: 网络整理| 查看: 265

GameObject.GetComponent 获取组件

function GetComponent (type : Type) : Component

Description描述

Returns the component of Type type if the game object has one attached, null if it doesn't. You can access both builtin components or scripts with this function.

如果这个游戏物体包含一个类型为type的组件,则返回它。如果没有则为空。通过这个函数,你可以访问内建的组件或者脚本的组件。

GetComponent is the primary way of accessing other components. From javascript the type of a script is always the name of the script as seen in the project view.

GetComponent是访问别的组件的原始方法,对javascript来说,脚本的类型就是项目视图里面看到的脚本名称。

using UnityEngine;

using System.Collections;

public class example : MonoBehaviour {

void Start() {

Transform curTransform;

curTransform = gameObject.GetComponent();

curTransform = gameObject.transform;

}

void Update() {



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有