当前位置:网站首页>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
}
}
边栏推荐
- Intelligent customer service track: Netease Qiyu and Weier technology play different ways
- 重排数组
- Redis shares four cache modes
- 力扣刷题01(反转链表+滑动窗口+LRU缓存机制)
- Huawei cloud database DDS products are deeply enabled
- TechSmith Camtasia studio 2022.0.2 screen recording software
- c# 实现定义一套中间SQL可以跨库执行的SQL语句
- 左右对齐!
- Temperature control system based on max31865
- What are the concepts of union, intersection, difference and complement?
猜你喜欢
[Dalian University of technology] information sharing of postgraduate entrance examination and re examination
AI做题水平已超过CS博士?
Flutter reports an error no mediaquery widget ancestor found
深度学习 神经网络的优化方法
Redis publier et s'abonner
科普达人丨一文看懂阿里云的秘密武器“神龙架构”
They are all talking about Devops. Do you really understand it?
中国主要城市人均存款出炉,你达标了吗?
Intelligent customer service track: Netease Qiyu and Weier technology play different ways
The per capita savings of major cities in China have been released. Have you reached the standard?
随机推荐
LeetCode 1184. 公交站间的距离 ---vector顺逆时针
03 storage system
MySQL学习笔记——数据类型(数值类型)
LeetCode 35. Search the insertion position - vector traversal (O (logn) and O (n) - binary search)
Ffprobe common commands
Unity预制件Prefab Day04
Width and alignment
小数,指数
Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
Redis publier et s'abonner
MySQL federated primary key_ MySQL creates a federated primary key [easy to understand]
微博、虎牙挺进兴趣社区:同行不同路
Unity脚本API—GameObject游戏对象、Object 对象
Optimization method of deep learning neural network
mysql 联合主键_Mysql 创建联合主键[通俗易懂]
宽度与对齐
Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
MySQL组合索引(多列索引)使用与优化案例详解
Deep learning network regularization
I plan to teach myself some programming and want to work as a part-time programmer. I want to ask which programmer has a simple part-time platform list and doesn't investigate the degree of the receiv