Search Unity

Accessing HDRP libraries in another C# Script

Discussion in 'High Definition Render Pipeline' started by NotTimTam, Sep 17, 2019.

  1. NotTimTam

    NotTimTam

    Joined:
    Sep 24, 2015
    Posts:
    20
    I am creating a game with a detection ring that changes sizes when you do certain things, similar to in assassin's creed games.

    I am using the HDRP decal projector to project the ring. But I want to edit the projection size during runtime from a C# script. How can I access the HDRP libraries in the script so I can grab the decal projector and its properties through a GetComponent<>() script.
     
  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    We don't have proper API documentation yet, but you can easily get the decal projector component and change the size using
    GetComponent<DecalProjector>().size = new Vector3(X, Y, Z);
     
  3. NotTimTam

    NotTimTam

    Joined:
    Sep 24, 2015
    Posts:
    20
    I am only using these libraries:
    using UnityEngine;
    using UnityEngine.AI;

    If I type in
    Code (CSharp):
    1. GetComponent<DecalProjector>()
    I get this error
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    704
    Last edited: Sep 19, 2019
    DavidMiranda and NotTimTam like this.
  5. NotTimTam

    NotTimTam

    Joined:
    Sep 24, 2015
    Posts:
    20
  6. NotTimTam

    NotTimTam

    Joined:
    Sep 24, 2015
    Posts:
    20
    Now I just get an error that HighDefinition does not exist in that namespace. I have the HDRP package installed and up to date, as well as all its dependencies.
     
  7. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    Which version of Unity, which version of HDRP?

    HDRP only comes out of experimental in 2019.3 (HDRP 7.x). Assuming you are using an earlier Unity version, and for example HDRP 6.x, you should use the following instead, but keep in mind that you will need to change it again once you start using versions 7 and higher of HDRP:

    UnityEngine.Experimental.Rendering.HDPipeline
     
  8. rastlin

    rastlin

    Joined:
    Jun 5, 2017
    Posts:
    127
    You just need to add HDRP package as a dependency to your asmdef file.

    upload_2019-9-23_22-6-14.png

    I'm not entirely sure how to reference this Assembly-CSharp though.