当前位置:网站首页>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
}
}
边栏推荐
- Unity脚本API—GameObject游戏对象、Object 对象
- PXE network
- LeetCode 58. Length of the last word
- LeetCode 35. Search the insertion position - vector traversal (O (logn) and O (n) - binary search)
- Quelles sont les perspectives de l'Internet intelligent des objets (aiot) qui a explosé ces dernières années?
- 一篇文章学会GO语言中的变量
- Live broadcast preview | PostgreSQL kernel Interpretation Series II: PostgreSQL architecture
- Deep learning network regularization
- 暑期复习,一定要避免踩这些坑!
- Dialogue with ye Yanxiu, senior consultant of Longzhi and atlassian certification expert: where should Chinese users go when atlassian products enter the post server era?
猜你喜欢

lnx 高效搜索引擎、FastDeploy 推理部署工具箱、AI前沿论文 | ShowMeAI资讯日报 #07.04

.Net 应用考虑x64生成

MySQL learning notes - data type (numeric type)

MySQL学习笔记——数据类型(数值类型)

对话龙智高级咨询顾问、Atlassian认证专家叶燕秀:Atlassian产品进入后Server时代,中国用户应当何去何从?

Redis publish and subscribe

在芯片高度集成的今天,绝大多数都是CMOS器件

Data Lake Governance: advantages, challenges and entry

Quelles sont les perspectives de l'Internet intelligent des objets (aiot) qui a explosé ces dernières années?

UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks
随机推荐
Preliminary exploration of flask: WSGI
压力、焦虑还是抑郁? 正确诊断再治疗
Width accuracy
数据湖治理:优势、挑战和入门
Width and alignment
UFO: Microsoft scholars have proposed a unified transformer for visual language representation learning to achieve SOTA performance on multiple multimodal tasks
How did the beyond concert 31 years ago get super clean and repaired?
C1 certification learning notes 3 -- Web Foundation
AI做题水平已超过CS博士?
音视频技术开发周刊 | 252
Solve the error of JSON module in PHP compilation and installation under CentOS 6.3
%f格式符
Luo Gu - some interesting questions
selenium 浏览器(2)
[local differential privacy and random response code implementation] differential privacy code implementation series (13)
hexadecimal
. Net applications consider x64 generation
They are all talking about Devops. Do you really understand it?
Numpy notes
Unity脚本API—Time类