Unity3D学习记录——开关灯

来源:互联网 发布:网络经济犯罪的特点有 编辑:程序博客网 时间:2024/04/25 02:52

1.这是完整的开关灯逻辑,之前为关灯

using System.Collections;using System.Collections.Generic;using UnityEngine;public class OnOffLight : 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") {            m_light.enabled = !m_light.enabled;        }    }}


原创粉丝点击