我可以在 Unity 中通过脚本创建光源吗?

Can I create a light source via script in Unity?

我正在尝试为 Kerbal mod 写一点 Space 编写一个使用 Unity 的游戏。我有一个 class 是 MonoBehaviour 的子项,它可以正确加载所有内容。 mod 的一部分涉及在当前场景中创建新光源。我的问题如下:我是否可以使用脚本而不是 unity 引擎场景编辑器在当前场景中创建一个新的 Unity 光源(作为 modder 我显然没有访问权限).

我正在寻找的那种东西的例子(我知道它实际上看起来不是这样的,只是为了让你了解我需要什么)

UnityEngine.getCurrentScene().createObject(new Light(pos, direction, color, strength));

创建游戏对象并添加灯光组件:

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour {
    void Start() {
        GameObject lightGameObject = new GameObject("The Light");
        Light lightComp = lightGameObject.AddComponent<Light>();
        lightComp.color = Color.blue;
        lightGameObject.transform.position = new Vector3(0, 5, 0);
    }
}