Unity3D学习记录——关灯

来源:互联网 发布:linux查看磁盘使用情况 编辑:程序博客网 时间:2024/03/28 23:13

1.获取的是Point light的Light组件属性

2..注意other是谁,脚本放在谁上

using System.Collections;using System.Collections.Generic;using UnityEngine;public class OffLight : MonoBehaviour {    private Light m_light;// Use this for initializationvoid Start () {        m_light = GameObject.Find("Point light").GetComponent<Light>();}// Update is called once per framevoid Update () {}    void OnCollisionEnter(Collision other) {        if (other.gameObject.name == "Switch")        {            Debug.Log("碰撞");            m_light.gameObject.SetActive(false);        }            }}



原创粉丝点击