当前位置:网站首页>Unity script API - GameObject game object, object object
Unity script API - GameObject game object, object object
2022-07-04 15:22:00 【@Night Charm】
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// GameObject The game object
/// </summary>
public class GameObjectDemo : MonoBehaviour
{
private void OnGUI()
{
// In the scene, the object is active ( The actual active state of the object )
//this.gameObject.activeInHierarchy;
// The active state of the object itself ( The object is in Inspector Status in the panel )
//this.gameObject.activeSelf
// Set the object to enable / Ban
//this.gameObject.SetActive();
if (GUILayout.Button(" Add light source "))
{
//this.gameObject.AddComponent<Light>();
// Create objects
GameObject lightGO= new GameObject();
// Add the component
Light light = lightGO.AddComponent<Light>();
light.color = Color.red;
light.type = LightType.Point;
}
// Find objects in the scene by name ( Use with caution )
//GameObject.Find(" Game object name ");
// Get all objects using this tag
GameObject[] allEnemy = GameObject.FindGameObjectsWithTag("Enemy");
foreach (GameObject enemy in allEnemy)
{
Debug.Log("Enemy"+enemy.name);
}
// Get the object using the tag ( Single )
GameObject playerGo = GameObject.FindWithTag("Player");
Debug.Log("Player"+playerGo.name);
//Object
// Find objects by type
Object.FindObjectOfType<MeshRenderer>();
FindObjectsOfType<MeshRenderer>();
// Destroy object
//Object.Destroy
// practice : Find the enemy with the lowest HP
}
}
边栏推荐
- Introduction to modern control theory + understanding
- 【学习笔记】拟阵
- Preliminary exploration of flask: WSGI
- Redis 解决事务冲突之乐观锁和悲观锁
- 在芯片高度集成的今天,绝大多数都是CMOS器件
- Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
- Go zero micro service practical series (IX. ultimate optimization of seckill performance)
- Redis publish and subscribe
- When synchronized encounters this thing, there is a big hole, pay attention!
- How to handle exceptions in multithreading?
猜你喜欢
每周招聘|高级DBA年薪49+,机会越多,成功越近!
Weekly recruitment | senior DBA annual salary 49+, the more opportunities, the closer success!
flutter 报错 No MediaQuery widget ancestor found.
Lombok使用引发的血案
力扣刷题01(反转链表+滑动窗口+LRU缓存机制)
Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
Unity脚本常用API Day03
. Net applications consider x64 generation
压力、焦虑还是抑郁? 正确诊断再治疗
Preliminary exploration of flask: WSGI
随机推荐
深入JS中几种数据类型的解构赋值细节
怎么判断外盘期货平台正规,资金安全?
Halcon knowledge: NCC_ Model template matching
Redis 發布和訂閱
LeetCode 1184. Distance between bus stops -- vector clockwise and counterclockwise
从0到1建设智能灰度数据体系:以vivo游戏中心为例
Deep learning neural network case (handwritten digit recognition)
lnx 高效搜索引擎、FastDeploy 推理部署工具箱、AI前沿论文 | ShowMeAI资讯日报 #07.04
力扣刷题01(反转链表+滑动窗口+LRU缓存机制)
深度学习 神经网络案例(手写数字识别)
%f格式符
一篇文章学会GO语言中的变量
MySQL learning notes - data type (numeric type)
Unity脚本API—GameObject游戏对象、Object 对象
LeetCode 35. Search the insertion position - vector traversal (O (logn) and O (n) - binary search)
对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?
Usage of database functions "recommended collection"
When synchronized encounters this thing, there is a big hole, pay attention!
中国主要城市人均存款出炉,你达标了吗?
hexadecimal