Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved Converting c# function into a uvs node works automatically... sometimes.

Discussion in 'Visual Scripting' started by Marou1, Jan 12, 2023.

  1. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    Hi,

    I have a script with these 2 functions:
    1:
    Code (CSharp):
    1.  public static void DeleteFile(string filename)
    2.         {
    3.             string fullpath = Application.persistentDataPath + "/" + filename;
    4. ...
    2:
    Code (CSharp):
    1. public static void SaveFile<T>(string filename, T data) where T : class
    2.         {
    3.             if (IsValidFilename(filename))
    4.             {
    5.                 FileStream file = null;
    6.                 try
    7.                 {...
    After adding the scripting in the uvs section in project settings, why can I see the first function and not the second?
    (ps: this is just an example, I don't need to save or load anything, I just to want to understand what are the requirements so uvs recognizes a c# function.)

    Thanks
    upload_2023-1-12_15-7-6.png
     

    Attached Files:

  2. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,050
    Second one is generic, UVS does not support generics.

    Edit: But you can always wrap a generic method into a regular one for UVS purposes.
     
    Last edited: Jan 13, 2023
    Marou1 likes this.
  3. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    Thanks
     
  4. Marou1

    Marou1

    Joined:
    Dec 13, 2021
    Posts:
    161
    Performance-wise, do you know if a c# function takes longer to execute when called from a UVS script?

    I'd say no...
     
  5. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,050
    C# executes like it always does with or without UVS. The only overhead is for the initial UVS call so overall performance loss is minimal when calling C# methods.
     
    Marou1 likes this.