【发布时间】:2021-05-12 04:42:13
【问题描述】:
各位,我有小问题。我需要从脚本访问 2D 光强度。我试过用 GetComponent 来做,但没有用。也许,我在 GetComponent 上做错了,因为我是初学者。 Screenshot of what I want to control
【问题讨论】:
各位,我有小问题。我需要从脚本访问 2D 光强度。我试过用 GetComponent 来做,但没有用。也许,我在 GetComponent 上做错了,因为我是初学者。 Screenshot of what I want to control
【问题讨论】:
您可以拨打GetComponent<>(),但您可能做错了。
using UnityEngine;
using UnityEngine.Experimental.Rendering.Universal;
public class ControllingIntensity : MonoBehaviour
{
public float intensity;
void Start()
{
GetComponent<Light2D>().intensity = intensity;
}
}
【讨论】: