Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

AR light estimation Unity

using UnityEngine;
using UnityEngine.XR.ARFoundation;
using TMPro;

public class Estimate_light : MonoBehaviour
{
    public ARCameraManager arcamman;
    public TMP_Text brightness;
    public float? averageBrightness { get; set; }
    Light our_light;
    // Start is called before the first frame update
    void OnEnable()
    {
        arcamman.frameReceived+=getlight;
        brightness.text="Enabled";

    }
    void OnDisable()
    {
        arcamman.frameReceived-=getlight;
        brightness.text="Disabled";

    }

    void Start()
    {
        our_light=GetComponent<Light>();
    }

    void getlight(ARCameraFrameEventArgs args)
    {
        
        if(args.lightEstimation.mainLightColor.HasValue)
        {
            //brightness.text=$"Brightness: {args.lightEstimation.mainLightColor.Value}";
            our_light.color=args.lightEstimation.mainLightColor.Value;
            float y=0.2126f*our_light.color.r+0.7152f*our_light.color.b+0.0722f*our_light.color.g;
            brightness.text=$"Brightness: {y}";
        }
        else
        {
            brightness.text="No Value";
        }

        
    }

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: GetNetworkTime 
Csharp :: C# dictionnaries 
Csharp :: c# find the smallest string in an array of strings 
Csharp :: how to unfocus a richtextbox windows forms 
Csharp :: Unity Wait Time Fixed 
Csharp :: c# excel fix first row 
Csharp :: unity get refresh rate 
Csharp :: AutoMapper Add Assemblies 
Csharp :: c# enum variable set to nonthing 
Csharp :: worsening 
Csharp :: get current culture in controller asp.net core 
Csharp :: unity round image 
Csharp :: basic math functions in c# 
Csharp :: retrive the last record dynamics 365 by c# 
Csharp :: www.elking.net 
Csharp :: Accepts one of 1, 2, x or X, or nothing 
Csharp :: runner dotnet trace inside docker container 
Csharp :: c# generic type converter 
Csharp :: c# async rethrow exception 
Csharp :: split a datatable based on number of rows 
Csharp :: c# control datagridview null value 
Csharp :: Set database timeout in Entity Framework 
Csharp :: C# Blocks without statements 
Csharp :: new guid c# always returns 0 
Csharp :: epmty char c# 
Csharp :: MVC 5 identity SignOut Everywhere for specific user 
Csharp :: c# array does not contain a definition for cast 
Csharp :: filter collection viewbag 
Csharp :: struct 
Csharp :: ef core unique index 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =