Files
FORT-BO/Assets/Plugins/VolumetricLightBeam/Samples/Scripts/LightGenerator.cs
T
AsanoRema ffa1064063 Squashed commit of the following:
commit 428243f4a6
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Sat Aug 29 13:43:13 2026 +0300

    Squashed commit of the following:

    commit 68e78fa464
    Author: AsanoRema <asanorema2036@gmail.com>
    Date:   Sat Aug 29 13:41:49 2026 +0300

        Updated .gitignore

commit 9f87122a34
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Sat Aug 29 13:34:57 2026 +0300

    Added Dohya

commit f6a7547e84
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Fri Aug 21 17:59:13 2026 +0300

    Fixed

commit b98901c366
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 17:37:22 2026 +0300

    Added new particle Package

commit bb2f4a3b16
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 17:17:48 2026 +0300

    Map mehanic ready to multiplayer

commit c01ff800f6
Author: AsanoRema <asanorema2036@gmail.com>
Date:   Tue Aug 18 16:16:19 2026 +0300

    Squashed commit of the following:

    commit 173bbb165c
    Author: henjkey <henjkey@gmail.com>
    Date:   Fri Aug 14 18:51:23 2026 +0500

        Mappp

    commit d559ab338a
    Author: henjkey <henjkey@gmail.com>
    Date:   Thu Aug 13 18:42:41 2026 +0500

        Map

        Controller
        Coordinates
        Target System
        Crosshair System
        Radar System
2026-08-29 13:45:55 +03:00

88 lines
3.3 KiB
C#

using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace VLB_Samples
{
public class LightGenerator : MonoBehaviour
{
[Range(1, 100)]
[SerializeField] int CountX = 10;
[Range(1, 100)]
[SerializeField] int CountY = 10;
[SerializeField] float OffsetUnits = 1;
[SerializeField] float PositionY = 1;
[SerializeField] bool NoiseEnabled = false;
[SerializeField] bool AddLight = true;
public void Generate()
{
for (int i = 0; i < CountX; ++i)
{
for (int j = 0; j < CountY; ++j)
{
GameObject gao = null;
if(AddLight)
gao = new GameObject("Light_" + i + "_" + j, typeof(Light), typeof(VLB.VolumetricLightBeam), typeof(Rotater));
else
gao = new GameObject("Light_" + i + "_" + j, typeof(VLB.VolumetricLightBeam), typeof(Rotater));
gao.transform.SetPositionAndRotation( new Vector3(i * OffsetUnits, PositionY, j * OffsetUnits),
Quaternion.Euler(Random.Range(-45, 45) + 90f, Random.Range(0, 360), 0));
var beam = gao.GetComponent<VLB.VolumetricLightBeam>();
if (AddLight)
{
var light = gao.GetComponent<Light>();
light.type = LightType.Spot;
light.color = new Color(Random.value, Random.value, Random.value, 1.0f);
light.range = Random.Range(3f, 8f);
light.intensity = Random.Range(0.2f, 5f);
light.spotAngle = Random.Range(10f, 90f);
if(VLB.Config.Instance.geometryOverrideLayer)
{
// remove the layer of the beams from the light's culling mask to prevent from breaking GPU Instancing
light.cullingMask = ~(1 << VLB.Config.Instance.geometryLayerID);
}
}
else
{
beam.color = new Color(Random.value, Random.value, Random.value, 1.0f);
beam.fallOffEnd = Random.Range(3f, 8f);
beam.spotAngle = Random.Range(10f, 90f);
}
beam.coneRadiusStart = Random.Range(0f, 0.1f);
beam.geomCustomSides = Random.Range(12, 36);
beam.fresnelPow = Random.Range(1, 7.5f);
beam.noiseMode = NoiseEnabled ? VLB.NoiseMode.WorldSpace : VLB.NoiseMode.Disabled;
var rotater = gao.GetComponent<Rotater>();
rotater.EulerSpeed = new Vector3(0, Random.Range(-500, 500), 0);
}
}
}
}
#if UNITY_EDITOR
[CustomEditor(typeof(LightGenerator))]
public class LightGeneratorEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
if (Application.isPlaying) return;
if (GUILayout.Button("Generate"))
{
(target as LightGenerator).Generate();
}
}
}
#endif
}