rabidus-test/Assets/Amazing Assets/Advanced Dissolve/Scripts/Helper/AdvancedDissolveSpotLightTo...

39 lines
1.2 KiB
C#
Raw Normal View History

2023-09-18 20:09:22 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AmazingAssets.AdvancedDissolve;
namespace AmazingAssets.AdvancedDissolve
{
[ExecuteAlways]
[RequireComponent(typeof(Light))]
public class AdvancedDissolveSpotLightToConeSmooth : MonoBehaviour
{
public AdvancedDissolveGeometricCutoutController geometricCutoutController;
public AdvancedDissolve.AdvancedDissolveKeywords.CutoutGeometricCount countID;
public float radiusOffset;
Light spotLight;
private void Start()
{
spotLight = GetComponent<Light>();
}
// Update is called once per frame
void Update()
{
Vector3 startPoint = transform.position;
Vector3 endPoint = transform.position + transform.forward * spotLight.range;
float radius = spotLight.range * Mathf.Tan((spotLight.spotAngle / 2) * Mathf.Deg2Rad);
geometricCutoutController.SetTargetStartPointPosition(countID, startPoint);
geometricCutoutController.SetTargetEndPointPosition(countID, endPoint);
geometricCutoutController.SetTargetRadius(countID, radius - radiusOffset);
}
}
}