Search Unity

[Released] uNode - Visual Scripting [Support C# Import/Export]

Discussion in 'Assets and Asset Store' started by wahid_rachmawan, Oct 18, 2017.

  1. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    Thank you, working with uNode is getting more and more enjoyable. :)

    But we still have some work... ;)
    Next ---> error when trying to compile:
    2018-12-06_01-46-08.png

    P.S.
    """............................Also after parsing, there are problems with nodes "Divine", changes the output to the object type <--------->
    Can you send me the script for i can test?..................."""
    Do you still want this file? have you already repaired?
     
    Mark_01 likes this.
  2. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    This bug also has been fixed ;).

    Yes i need a sample script to fix it.

    I'll upload new update on sunday.
     
  3. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    I have:
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class A_TEST1 : MonoBehaviour
    5. {
    6.     public int variable0 = 10;
    7.     public int variable1 = 0;
    8.  
    9.     public void NewFunction()
    10.     {
    11.         variable1 = (variable0 / 2);
    12.     }
    13. }
    parsing... --->
    2018-12-06_10-10-36.png

    And the compilation back to the C # code... --->
    2018-12-06_10-16-36.png
    (Despite the errors the code is OK, although the "(int)" part is unneeded.)
     
    Last edited: Dec 6, 2018
    Mark_01 likes this.
  4. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan

    Performance ---> 2018-12-06_18-30-07.png
    I think the loopObject variable is unnecessary, because tempVar can be used directly.

    2018-12-06_18-41-26.png
    Also I think it's better to define the loop variable inside the for loop, instead of using a class variable.

    And... parsing error --->

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3.  
    4. namespace test
    5. {
    6.     public struct S_Human
    7.     {
    8.         public string Name;
    9.         public int Age;
    10.         public Vector2 Position;
    11.     }
    12.     public class A_TEST3 : MonoBehaviour
    13.     {
    14.         public S_Human Create_Human(string name, int age, Vector2 position)
    15.         {
    16.             return new S_Human() { Name = name, Age = age, Position = position };
    17.         }
    18.     }
    19.    
    20.    
    21. }
    2018-12-06_18-55-17.png

    I also can not use initializers at all for such defined structures.
     
  5. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed, will available in next update.

    This is a bug, previously it use tempVar when you use 'Value' on the next flow.
    Will be fixed soon.
    I'll investigate and fix it ASAP.
    Edit: It likely reflection can't obtain a parameterless constructor of a struct because it does not exist. I'll find another way to fix it.
    Edit2: fixed in the next update;).

    Thanks for report it.
     
    Last edited: Dec 7, 2018
  6. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    Thank You very much. :)

    Suggestion:
    There should be a possibility to assign a starting value to a variable (both class and local), which isn't always possible now - for example in case of custom structs. And there should be a possibility not to assign it when it's not needed, which would produce cleaner C# code.
     
  7. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    You can assign starting value for both class and local variable.
    For assign starting value for local variable just double click on variable and it will show popup window which you can assign a starting value:
    Screenshot (254).png

    For struct the only way to have starting value is by auto creating default constructor which assign variable value, this will available soon.
     
  8. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    Yes, I know, apparently I was wrong and it was all about my own structures. ;)
    (But... there should be a possibility not to assign value when it's not needed, which would produce cleaner C# code.)

    Meanwhile, my current node reduction record:
    2018-12-07_20-52-50a.png

    The King is dead, long live the King! :cool::):cool:
     
    Last edited: Dec 7, 2018
  9. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Ah sure, for local variable you can leave it not assigned by destroying the instance value but on generate only struct type will leave empty and for class type will have null assigned to it (because to prevent error when you're generating code: get variable that is not assigned, i know it useful for newbie but assigning start value to null not have impact on performance).
    For not assign value for classes will available soon.

    Cool reduction, you can also reduce more by using Action nodes. With you current graphs i think using Action node reduce up to 4 more nodes.
    Action node can be used to invoke or set value of a variable just like flow node do but the limitation is it's not supported interact with value node.

    Thanks for your suggestion.
     
    AthrunVLokiz likes this.
  10. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    For now, I'm learning basic things... ;)

    next --->
    2018-12-08_14-15-21.png

    And... --->
    2018-12-08_14-58-29.png
    In general, there is something wrong with parsing scripts with enumerators. All of my C # scripts worked correctly, so ...

    P.S.
    Anyway, I will wait patiently for better and better uNode. :cool:
     
    Last edited: Dec 8, 2018
  11. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Can you send me the sample script for i can fix it....
    Hope i will fix it before launch new update.
     
  12. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    ok...
    I have two scrypts:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class A_test_enum : MonoBehaviour
    6. {
    7. }
    8. public enum Enum_0
    9. {
    10.     small = 0,
    11.     medium = 1,
    12.     large = 2,
    13. }
    and...
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3.  
    4. public class A_test : MonoBehaviour
    5. {
    6.     public Enum_0 variable0 = Enum_0.small;
    7. }
    8.  
    When I try to parse a second one, I have this error --->
    2018-12-09_15-58-58.png

    EDIT//
    If I have everything in one script - then parsing works correctly --->
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class A_test_plus : MonoBehaviour
    6. {
    7.     public Enum_1 variable0 = Enum_1.small;
    8. }
    9. public enum Enum_1
    10. {
    11.     small = 0,
    12.     medium = 1,
    13.     large = 2,
    14. }
     
    Last edited: Dec 9, 2018
  13. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    What the method do you use for parsing? (MonoScript, Source, or File)

    Edit: Fixed in next update, this cause when parsing enum outside of source the type name is included.

    Thanks.
     
    Last edited: Dec 10, 2018
  14. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    Always MonoScript.
     
    Last edited: Dec 10, 2018
  15. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    uNode v1.7.2 has been submitted for review!

    changelog v1.7.2:
    -New realtime C# Preview Windows.
    -Added PerSecond value node.
    -Improved CSharpGenerator
    -Improved CSharpPreviewWindow
    -Improved Editor
    -Improved ErrorChecker
    -Fixed bugs parsing property set accessor.
    -Fixed bugs error on parsing enum type outside of source.
    -Fixed bugs ErrorChecker error on check divide operator.
    -Fixed bugs ErrorChecker error on check SetValue node.
    -Fixed bugs error on generating property and constructor.
    -Fixed warning related to null texture on draw node.


    Download here : http://maxygames.com/download/

    The new realtime c# preview windows with syntax highlighter help you learn c# with uNode.

    Keep note that the c# output from preview window may have different with the final c# (this because final c# uses more options for make code more less and readable ex: remove type namespaces)

    How to enable syntax highlighter:
    • Need at least Unity 2018.1 or higher.
    • Import CSharpParser.
    • Syntax highlighter is now enabled.
     
    Last edited: Dec 10, 2018
  16. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    Thank You very much. :cool::)
    Where to get my invoice number? EDIT// i have it :)

    P.S.
    Error when using IF in property setter also is fixed? (post 293, third error)
     
    Last edited: Dec 10, 2018
  17. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
  18. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    Thank you so much, now I am going to sleep ... but I will check tomorrow.
    I noticed that the error with the node "break" also applies to the node "continue"

    I guessed. ;)
     
    Last edited: Dec 10, 2018
  19. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Do you mean the warning?
    I think i have fix it too, just check it out when you wake up;).

    I just post in this thread and my discord channel.
     
  20. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    uNode v1.7.2 has been released on the Asset store.
     
    Mark_01 likes this.
  21. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    I checked all reported bugs except constructors - and everything works, thank you. :)

    But I have new ones. ;)

    I have three scripts --->
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Script_0 : MonoBehaviour
    4. {
    5.     public System.Collections.Generic.List<UnityEngine.Vector2> Var_vector0 = null;
    6. }
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Script_1 : MonoBehaviour
    4. {
    5.     public static Script_0 Var_script0 = null;
    6.  
    7.     public static Script_0 Prop_script0
    8.     {
    9.         get
    10.         {
    11.             return Var_script0;
    12.         }
    13.     }
    14.  
    15. }
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Script_2 : MonoBehaviour
    4. {
    5.     public int Var_int0 = 0;
    6.     public int Var_int1 = 0;
    7.  
    8.     public void NewFunction()
    9.     {
    10.         Var_int0 = Script_1.Prop_script0.Var_vector0.Count;
    11.         Var_int1 = (Var_int0 + 1);
    12.     }
    13. }
    Parses the third script --->
    2018-12-12_23-34-43.png
    Everything looks good when parsing, but when I try to do it myself in the uNode editor, I have errors suggesting that this is a non-static property - hence the request for instances
    2018-12-12_23-36-06.png

    EDIT//
    2018-12-13_00-53-01.png
    The compilation seems fine, but there is still error information - it applies to the four selected operator types.
     
    Last edited: Dec 13, 2018
  22. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Will be fixed ASAP.

    Thanks for report it.
     
  23. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan

    next ----->
    I have script:
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Script_0 : MonoBehaviour
    4. {
    5.     public int NewVariable = 0;
    6.  
    7.     public void NewFunction()
    8.     {
    9.         switch (NewVariable)
    10.         {
    11.             case 0:
    12.             case 3:
    13.                 NewFunction1();
    14.                 break;
    15.             case 1:
    16.             case 2:
    17.                 NewFunction2();
    18.                 break;
    19.         }
    20.     }
    21.     public void NewFunction1()
    22.     {
    23.     }
    24.     public void NewFunction2()
    25.     {
    26.     }
    27. }
    After parsing ----->
    2018-12-13_17-28-55.png
    After parsing, I must manually delete unnecessary nodes "break". Besides, it would be nice if the compiler did not repeat the code.

    P.S.
    It's nice that I can help in improving this extremely cool tool. :)
     
    Last edited: Dec 13, 2018
    Mark_01 likes this.
  24. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Will be fixed ASAP.

    Thanks for reporting it.
     
    Mark_01 likes this.
  25. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    Thanks.

    Next --->
    I Have script --->

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using UnityEngine;
    3.  
    4. public class Script_0 : MonoBehaviour
    5. {
    6.     public List<int> List_int = new List<int>();
    7. }
    I create second script in uNode ... --->
    2018-12-14_03-32-03.png

    An attempt to compile --->
    2018-12-14_03-35-11.png
     
  26. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    The bug will be fixed in next update.

    Thanks.
     
  27. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    --->
    2018-12-15_13-48-27.png

    In case of nested loops there are still private class variables used. For more clean code it would be better to always use in-loop variables, of course they should have a different name in each loop.
     
  28. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    It look like bugs flow body is not detected by the generator, prev i just test with one node inside of flow body. The class variable should be used when foreach value is used by node outside of flow body, this to prevent error happened.
    I will find solution to fix it ASAP.

    And the warning unreachable block inside of switch statement i could't fix it in sort time because need a code analizer which is complex stuff.
    For now need to manually remove block node to fix it.
     
  29. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    Ok.
    The most important are errors from post 321 and 325.
     
  30. AthrunVLokiz

    AthrunVLokiz

    Joined:
    Jun 7, 2017
    Posts:
    32
    [Edit]
    sorry, i just find required "Import CSharpParser" for about syntax highlighter issue
    --------------------------------------------------------------------------------------

    Hello, I just find an issues

    issue on unity 2018.2.14f1 or above
    -uNode runtime not work
    upload_2018-12-16_4-41-2.png

    issue on unity 2018.3.0f2
    -red text color in editor
    -uNode runtime not work
    upload_2018-12-16_4-42-46.png

    Thanks for good tool and support :)
     
    Last edited: Dec 16, 2018
  31. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    I create and compile to C # such a script:
    2018-12-16_13-51-59.png

    And then the second one and when I add a variable an error appears --->
    2018-12-16_13-53-25.png
    2018-12-16_13-50-04.png

    This error doesn't occur when everything is in one script.
     
    Last edited: Dec 16, 2018
  32. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Hi,

    Can you tell me how to reproduce it?

    Can you send the prefab of that bugs?
    I couldn't reproduce the error.
     
  33. AthrunVLokiz

    AthrunVLokiz

    Joined:
    Jun 7, 2017
    Posts:
    32
    import uNode 1.7.2 to new projects of Unity 2018.1, 2018.2, 2018.3 (import CsharpParser and change script runtime to .Net 4.x equivalent as well)

    issues
    -uNode runtime not work (2018.1, 2018.2, 2018.3)
    -editor wrong to show red text (only 2018.3)

    Thanks :)
     
  34. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed in next update, thanks for report it.
     
    AthrunVLokiz likes this.
  35. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    I did one more clean test project

    First step (I create and compile to C # the first script) --->
    2018-12-17_10-10-18.png
    All is ok.

    Second step (I create a second script) --->
    2018-12-17_10-15-15.png
    All is ok.

    Third step (I add a variable of type Class_0) --->
    2018-12-17_10-18-09.png
    Errors in the inspector and console

    Unity version: 2018.2.18f1
    uNode version: 1.7.2
    I attach files --->
     

    Attached Files:

  36. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed in next update, thanks.
     
  37. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    The private class variables that are used in loops cause problems with static functions, because (for obvious reasons) they can't be used in them.
     
  38. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Ah i see, it will be fixed soon.
     
    Mark_01 and Szaruga like this.
  39. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    I met the first serious error.I could not reproduce it in laboratory conditions, but I decided to report it.
    When I removed the function parameter - the uNode editor was completely clean and errors appeared in the console. --->
    ERROR 006.png

    Closing the editor and restarting allows to open the script, but when I mark the function (left mouse button) in which I removed the parameter - the contents of the windows disappear again.
    the only salvation was to remove this function (right mouse button) and arrange it from scratch.
    I hope that you may find a clue in this matter - it is the first really serious error.
     
  40. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed in next update;).

    Thanks for report it.
     
  41. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    Writing a serious issue - I mean one that spoils what is already done. ;)

    Small issue with nodes "Increment-Decrement" (no "energy" on exit) --->
    2018-12-19_15-18-54.png

    P.S.
    I wrote a letter to Santa asking for a new version of uNode on Christmas. :rolleyes:
     
    AthrunVLokiz likes this.
  42. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed in next update;).
    I just forgot to generate the exit.

    I'll upload new version before the Christmas:).
     

    Attached Files:

  43. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    I found another issue --->
    2018-12-19_19-13-53.png

    Nested IFs don't work properly, in this case there are 2 problems:
    1. The first instance of "first finish" shouldn't be there.
    2. "second finish" should be inside the else block.

    P.S.

    Also it would be nice to have an option to put the opening '{' in separate lines, for some people (like me) the code looks more clear this way. (like this) --->
    Code (CSharp):
    1. public class test_001 : MonoBehaviour
    2. {
    3.     public bool NewVariable = false;
    4.     public bool NewVariable1 = false;
    5.    
    6.     public void NewFunction()
    7.     {
    8.         if (NewVariable)
    9.         {
    10.             Debug.Log("first true");
    11.         }
    12.         else
    13.         {
    14.             if (NewVariable1)
    15.             {
    16.                 Debug.Log("second true");
    17.             }
    18.             Debug.Log("second finish");
    19.         }
    20.         Debug.Log("first finish");
    21.     }
    22. }
     
  44. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Fixed in next update.

    For the other code options, i think will be using code formatter after the code generation.
    My plan will available in v.1.8, ofc the minimum unity version will be 2018.1 (this for make new feature which need to use .Net 4.x Equivalent)

    Thanks.
     

    Attached Files:

    Szaruga likes this.
  45. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    What does this attached file do? ;) I downloaded it but the issues are still there.
     
  46. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Got it, work on state flow but not work on regular flow.
    Here is the updated nodes:
     

    Attached Files:

  47. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    This is probably the first serious issue ;) - because it still does not work.
     
  48. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    I'm sorry, I did not notice that I forgot to include a screen with an error :oops:
    This issue --->
    2018-12-21_01-37-50.png
     
  49. wahid_rachmawan

    wahid_rachmawan

    Joined:
    Oct 4, 2017
    Posts:
    516
    Sorry for late reply, lately i very busy.

    Ah this why i couldn't fix it, but its okay.
    Try the new script:
     

    Attached Files:

  50. Szaruga

    Szaruga

    Joined:
    Jan 29, 2016
    Posts:
    403
    @wahid_rachmawan
    There is still an error that compiles false as true, if I do not connect anything to the true