Search Unity

Question Dropdown property in custom node

Discussion in 'Shader Graph' started by rsodre, Apr 6, 2019.

  1. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    Hi!

    How can I add a dropdown property to my custom node, like we see in the Position node?
    I need exactly that, to be able to select the output coordinate space of my node.

    Screen Shot 2019-04-06 at 17.44.05.png

    Unity 2018.3.11 / HDRP 4.10.0
     
  2. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    The CodeFunctionNode API that's in 2018.3 isn't available in higher versions of Shader Graph (2019 and up). Instead we have the Custom Function Node to inject custom code into your graph either by writing directly into the text box or referencing an HLSL file. Please keep that in mind when working with custom nodes in 2018.3, as any node you write will break when upgrading the project.

    To get the control you're looking for, I'd recommend looking at the code for the Blend node in your package cache source. The drop down you're looking for is called the EnumControl, and the Blend node is a fairly readable example of using that drop down to change the injected HLSL in the graph.
     
    P_Jong, rsodre and ph_ like this.
  3. ph_

    ph_

    Joined:
    Sep 5, 2013
    Posts:
    232
    So what you're saying is that having a dropdown like this was doable in 2018.x, but isn't in 2019.x ?
     
  4. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    Correct, the drop down menu is not available on the new Custom Function Node in 2019.x currently.
     
    ph_ likes this.
  5. rsodre

    rsodre

    Joined:
    May 9, 2012
    Posts:
    229
    Hmm, that feels bad to me.
    We have less functionality?

    Looking at the Custom Function node, we have to enter the function name, inputs and outputs in the node.
    What if I want to reuse or share a custom function?
    Should I enter all the inputs manually again? Can I define that in the HLSL file?
     
  6. alexandral_unity

    alexandral_unity

    Unity Technologies

    Joined:
    Jun 18, 2018
    Posts:
    163
    If you want to share the node, you can wrap it in a subgraph and share the subgraph file or reuse the same custom function within the same project.
     
    rsodre likes this.