UnityAPI—GameObject

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class API03GameObject : MonoBehaviour {

    public GameObject go;
    // Use this for initialization
    void Start () {
        //1,第一种创建方法 
        //GameObject go = new GameObject("Cube");
        //2,第二种
        //根据prefab 
        //根据另外一个游戏物体
        //GameObject.Instantiate(prefab);//可以根据prefab 或者 另外一个游戏物体克隆
        //3,第三种 创建原始的几何体
        //GameObject.CreatePrimitive(PrimitiveType.Plane);
        //GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
        //go.AddComponent<Rigidbody>();
         go.AddComponent<API01EventFunction>();

        //Debug.Log(go.activeInHierarchy);
        //go.SetActive(false);
        //Debug.Log(go.activeInHierarchy);
        //Debug.Log(go.tag);
        //Debug.Log(go.name);
        //Debug.Log(go.GetComponent<Transform>().name);


        //Light light = FindObjectOfType<Light>();
        //light.enabled = false;
        //Transform[] ts= FindObjectsOfType<Transform>();//不查找 未激活的游戏物体
        //foreach (Transform t in ts)
        //{
        //    Debug.Log(t);
        //}

        //GameObject go = GameObject.Find("Main Camera");
        //GameObject[] gos= GameObject.FindGameObjectsWithTag("MainCamera");
        GameObject go= GameObject.FindGameObjectWithTag("Finish");

        go.SetActive(false);
    }
    
   

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值