草庐IT

【Unity学习笔记】掌握MoneBehavior中的重要属性、方法

一、重要属性1-1.获取自己依附的GameObjectusingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassLesson3:MonoBehaviour{privatevoidStart(){//Mono里已经封装好了属性gameObject//可以通过gameObject属性来获取//(this.是可以省略的,为了便于理解在前面加上this)//打印出它的名字print(this.gameObject.name);}}1-2.获取自己依附的GameObject的位置信息usingS

【Unity学习笔记】基础游戏单位GameObject中常用的属性和API

一、GameObject中的成员变量主要思想:得到该脚本依附的GameObject的相关信息现有:Lesson4的代码:usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassLesson4:MonoBehaviour{voidStart(){//1.得到名字print(this.gameObject.name);//2.更改名字this.gameObject.name="Lesson4的新名字";print(this.gameObject.name);//3.得到是否激活print