예제 #1
0
    public SceneLight CreateLight()
    {
        SceneLight light = Instantiate(LightPrefab, LightHolder.transform).GetComponent <SceneLight>();

        light.name = $"Light {lightCount++}";

        Vector3 lookDirection = Camera.main.transform.forward;

        light.transform.position = Camera.main.transform.position + lookDirection.normalized * distance;
        light.transform.rotation = Quaternion.LookRotation(-lookDirection, Vector3.up);

        light.SetColor(light.light.color);
        lights.Add(light);
        LightAdded?.Invoke(light);
        return(light);
    }
예제 #2
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        _instance = this;

        lights = new List <SceneLight>();

        SceneLight light = Instantiate(LightPrefab, LightHolder.transform).GetComponent <SceneLight>();

        light.name = $"Main light";

        light.transform.position = new Vector3(0, 3, 0);
        light.transform.rotation = Quaternion.Euler(50, -30, 0);
        light.light.intensity    = 0.8f;

        light.SetColor(light.light.color);
        lights.Add(light);
    }
예제 #3
0
 public void AddLightChangeListener(ColorPicker picker, SceneLight light)
 {
     picker.onValueChanged.AddListener((c) => light.SetColor(c));
 }