Search Unity

Change displayed connection value of custom type during runtime

Discussion in 'Visual Scripting' started by psychpen, Aug 30, 2022.

  1. psychpen

    psychpen

    Joined:
    Dec 3, 2020
    Posts:
    2
    Hi,

    Does anyone know a way to change the way a custom type is displayed over the graph connections during play mode? I wanted to know if there was an attribute or something I could add to the custom type variable to have it display a value instead of the generic icon during playmode.

    It might not be something like this, maybe it's a method/property but you get the point:

    Code (CSharp):
    1. public class MyCustomType
    2. {
    3.     [VisualScripting.DisplayThisAttribute] // display this attribute on connection line
    4.     public float value;
    5.     ...
    6.     ...
    7. }
    Here's a picture of what the system looks like now. I'd like the last connection line to show the value of MyCustomType (which in this case would be 0).

    ForumPost.png


    It's interesting to note that the Transform object gets its own connection line description (albeit not useful). Is there a way to customize it for my own types?

    Thanks!
     
  2. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    396
    You're outputting the class which has no value. Output a float and it will show a value ie. MyCustomType.value.

    As for naming the type, there might be a unit attribute but not sure on a reflected type which is just code? Also its better to wrap inside a unit, as reflected types are about 10x slower, if its going to have alot of usage that is.
     
  3. psychpen

    psychpen

    Joined:
    Dec 3, 2020
    Posts:
    2
    To clarify, what I'm asking is if there's a way to implement the type so that if I'm passing the MyClassType object around, I can set up the text on the connection as some overridden property. As an example, when the Transform object is passed it has that "Bolt Flow Graph" text written the green connector. I wonder if there is a way to get a similar text (or property) to show up on the MyCustomType object.

    I don't quite understand what you mean by wrapping the type inside a unit. Do you mean creating a custom C# node? The only resource I can dig up on implementing custom types within Bolt is in the documentation and I got the type to show up via the steps there.
     
  4. Trindenberg

    Trindenberg

    Joined:
    Dec 3, 2017
    Posts:
    396
    [Description("Demonstrates DisplayNameAttribute.")]
    [DisplayName("RenamedProperty")]
    public bool MisnamedProperty

    This is part of C#, you can see if this works?