Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Accessing HDRP light parameters via script

Discussion in 'High Definition Render Pipeline' started by supaworst, May 19, 2019.

  1. supaworst

    supaworst

    Joined:
    Mar 26, 2012
    Posts:
    45
    Hello,

    as the title says i'd like to understand how to access to HDRP light parameters through code.

    In my specific case, i want to modify via script the length of a tube light but i can't find any documentation about it. In fact, all the current API refers to the standard lighting that has no tube shape.

    I have no clues about it, could somebody help me please?

    Thanks in advance
     
    CortiWins likes this.
  2. supaworst

    supaworst

    Joined:
    Mar 26, 2012
    Posts:
    45
    Ok, no problem, i've figured out how to do it.
    Just take the light as a normal game object and get the component "HDadditionalLightData".

    I hope it could be useful for somebody.
     
    Slock20969, xeniaeo, Ne0mega and 5 others like this.
  3. CortiWins

    CortiWins

    Joined:
    Sep 24, 2018
    Posts:
    145
    Like for sharing the solution.
     
  4. newmonuments

    newmonuments

    Joined:
    Oct 21, 2014
    Posts:
    15
    This gives me the following error:
    The type or namespace name 'HDAdditionalLightData' could not be found
    I also tried HDadditionalLightData (what you wrote) and get the same error

    my c#:

    lightObj.GetComponent<HDAdditionalLightData>();

    Can you post a sample of your c#? The lack of HDRIP documentation is killing me. changing any light related components via script is totally different now.
     
  5. supaworst

    supaworst

    Joined:
    Mar 26, 2012
    Posts:
    45
    Hi! Have you imported the hd pipeline library? If not, make sure to add at the top of your script also this:


    using UnityEngine.Experimental.Rendering.HDPipeline;

    Let me know if it works.
    Have a nice day!
     
    Ne0mega likes this.
  6. mb28

    mb28

    Joined:
    Oct 7, 2012
    Posts:
    27
  7. DSilvandoBlade

    DSilvandoBlade

    Joined:
    Dec 22, 2020
    Posts:
    9
    Just for people who this didn't work for, I'm using the latest 2019 version of unity and
    using UnityEngine.Rendering.HighDefinition; is what worked for me.
     
    ryo_sakakura and xeniaeo like this.