Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

FlowCanvas - Visual Scripting Similar to Unreal Blueprints

Discussion in 'Assets and Asset Store' started by nuverian, Apr 14, 2015.

  1. AbyssWanderer

    AbyssWanderer

    Joined:
    Mar 15, 2016
    Posts:
    75
    Thanks, man.
    Will get FC =)
     
    nuverian likes this.
  2. jay-jin

    jay-jin

    Joined:
    Jun 22, 2014
    Posts:
    12
  3. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    58
    <<= Dated OCTOBER 27/2016

    Is this version out? I'm running 5.5 and I am getting the same error as Tony.
     
    Last edited: Nov 28, 2016
  4. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hello,
    The new version with support for Unity v5.5 is already submitted and pending review by the asset store team. It will go live shortly.
    Thank you for your patience!

    @everyone
    Anyone that wants the new version now, I can send it to your via email. Just send me an email to support_AT_paradoxnotion.com along with your invoice ID and I will send it to you as soon as possible.
     
    Last edited: Nov 28, 2016
    GamerPET likes this.
  5. Cdngater

    Cdngater

    Joined:
    May 29, 2014
    Posts:
    58
    Ah great, I did not realize it was not live yet. I shall wait for the asset store to release it.

    Thanks
     
  6. Kuddy

    Kuddy

    Joined:
    Feb 11, 2014
    Posts:
    4
    Can I use Unity's Animation Curve in FlowCanvas?
     
  7. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    It's live now :)
    Thanks.


    Hello,
    Absolutely yes. You can actually use any type (Unity or non-Unity) you like within FlowCanvas.
    Here is a quick example of using an Animation Curve:
    AnimationCurves.png

    If you have any other questions, let me know.
    Cheers.
     
  8. Falagard

    Falagard

    Joined:
    Jan 8, 2014
    Posts:
    43
    Can a Flow Canvas be executed in edit mode rather than play mode?

    I'm thinking of using it for automating some tasks in the scene, such as say... instantiating and placing prefabs.

    I have already purchased Node Canvas, and would probably purchase Flow Canvas for other purposes as well, but was curious about the above use case.
     
  9. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hello,

    First of all, thanks a lot for having NodeCanvas and your interest in FlowCanvas as well.

    While I could make FlowCanvas work in edit mode quite easy, the main reason why it's not already possible is to avoid unpleasant outcomes since in FlowCanvas, one can create scripts that can pretty much affect anything. So it would not be really hard for accidents to happen.

    Thus, at least right now, FlowCanvas only works in runtime. Maybe in the future a special flowgraph type will be included for editor mode only, but I can't promise anything on that :)

    Thanks again.
     
  10. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    In case someone didnt notice, the new version 1.3.2 is live on the asset store. The changes include:

    • Unity 5.5 support.
    • New: Editor performance improvements.
    • New: Added “Break” port in all latent action nodes, like Wait or DOTween are for example.
    • New: Types (including generic types) and methods will now resolve and fallback to other matches by searching types without namespace.
    • Mod: Node browser is now considerably smaller in size.
    • Mod: Obsolete methods and properties are no longer shown in menus.
    • Fix: Duplicate and Delete shortcuts for multiple selected nodes.
    • Fix: Panning graph is now undoable.
    • Fix: “Replace Method” in reflection based node context menu, now works for static method overrides as well.
    • Fix: Runtime Macro instantiation issue.
    • Fix: Memory allocations for when using Dynamic Variables.
    • Fix: Export Macro to JSON now correctly includes it’s input/output port definitions.
    Cheers!
     
  11. Falagard

    Falagard

    Joined:
    Jan 8, 2014
    Posts:
    43
    In regards to edit mode support being dangerous, I'd say that's not a good reason to avoid using it ;)

    Is there anything preventing me from hooking up an event in flowcanvas that is triggered from the editor?
     
    Deon-Cadme likes this.
  12. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hey,

    In reality the most important thing that prevents a flowScript from running in edit mode, is that the port connections are only bound when in playmode. The following (dirty) example force connections to be bound and correctly runs in edit mode.
    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3.  
    4. namespace FlowCanvas.Nodes.Experiments{
    5.  
    6.     public class ExecuteInEditModeEvent : EventNode {
    7.  
    8.         private FlowOutput fOut;
    9.         protected override void RegisterPorts(){
    10.             fOut = AddFlowOutput("Out");
    11.         }
    12.  
    13.  
    14.         #if UNITY_EDITOR
    15.  
    16.         protected override void OnNodeInspectorGUI(){
    17.             if (GUILayout.Button("Execute")){
    18.                 for (var i = 0; i < graph.allNodes.Count; i++){
    19.                     if (graph.allNodes[i] is FlowNode){
    20.                         var flowNode = (FlowNode)graph.allNodes[i];
    21.                         flowNode.AssignSelfInstancePort();
    22.                         flowNode.BindPorts();
    23.                     }
    24.                 }
    25.  
    26.                 fOut.Call(new Flow());
    27.             }
    28.         }
    29.  
    30.         #endif
    31.     }
    32. }
    Of course that is not a very good way to do it, but rather just an experimentation, and there might be more problems that I have not accounted for yet when executing flowscripts in editor. I could take a better look at this and add an option (or create a new type of FlowScript for editor) if that is something people need :)
     
    IFL likes this.
  13. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hello everyone,
    I haven't posted it, but the integration with @Tryz (ootii's) Event System Dispatcher and FlowCanvas is available for download from the FlowCanvas website as promised on an earlier post :)
    Cheers!
     
    IFL likes this.
  14. Tryz

    Tryz

    Joined:
    Apr 22, 2013
    Posts:
    3,260
    You rock!

    Wait until you see the new integration I'm working on with the Motion Controller and Node Canvas! ;)
     
    IFL likes this.
  15. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Awesome!
    Looking forward to see what you come up with Tim. Motion Controller is fantastic :)
    Thanks man!
     
    Tryz likes this.
  16. GamerPET

    GamerPET

    Joined:
    Dec 25, 2013
    Posts:
    367
    Hello Nuv! Happy new year!

    What is a fast way to add a number node?


    Like this one?
     
  17. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hey,
    Happy new year to you as well! :)
    This is simply a float variable node. To create one you can right click in the canvas and select "GraphVariable(float)".
    FloatVariable.png

    Let me know if that works for you.
    Cheers!
     
    GamerPET likes this.
  18. shi377034

    shi377034

    Joined:
    Nov 8, 2014
    Posts:
    1
    how can us 'ReflectedFieldNodeWrapper',I need get Field of class
     
  19. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hey,
    While the script exists in the package, it was not made available to be added in the end, because using fields would result in a performance impact if use frequently/per-frame. If you still want to use fields though I can make the required changes needed to enable the ReflectedFieldNodeWrapper to be added in the UI and send the modified version to you. If so, please send me an email with your order ID (support@paradoxnotion.com) and I will reply with the modified package as soon as possible. I will probably enable this in the next version too as well.
    Thanks!
     
  20. jay-jin

    jay-jin

    Joined:
    Jun 22, 2014
    Posts:
    12
  21. TheGreatGreenBeret

    TheGreatGreenBeret

    Joined:
    Jan 13, 2017
    Posts:
    2
    Hi, I really love Flow Script and visual node programming, anyway I hope it can still improve.
    I have a execution order related issue in my project, I try to explain clearly what happens:
    I have two gameobject, each of theme has a flowscript controller on it (they have the same functionality).
    Both flowscript send an event to the other player when the On Awake event is fired. At Runtime, just one of the two events is actually fired.
    I suppose that the problem is due to the fact that one of the two objects is created after the other.
    If a introduce manually a delay between the On Awake event and the send event node everything works as expected.
    I'm going crazy to try a smart solution that avoids these kind of syncro problems. Can you help me? Thanks in advance

     
    Last edited: Feb 5, 2017
  22. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Hey,
    Thanks. I am really glad you like FlowCanvas! There is of course always room for improvements. :)
    Regarding the issue you are facing, you are correct in saying that this has to do with the order in which the objects are initialized. To resolve this issue, I have created (and attached for you here) a new node named "Start", which is similar to the Awake node, but is called 1 frame later. As such, all event nodes of graphs will have a chance to initialize first.
    Let me know if this node works for you.
    Thanks!
     

    Attached Files:

    GamerPET likes this.
  23. TheGreatGreenBeret

    TheGreatGreenBeret

    Joined:
    Jan 13, 2017
    Posts:
    2
    @nuverian thanks for your support. It works perfectly ;)
     
  24. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    Great! Thanks for letting me know and glad to be of help :)
     
  25. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Hi nuverian,

    started with Unity 3D and Flowcanvas/NodeCanvas after a longer break.
    In conjucntion with TextMeshPro and FlowCanvas, I noticed that I cannot set several font-style at the same time, like Bold+Italic, I can only chose one style. Have a look at the screenshot how TMP handles it differently than Unity Text.
    TextMeshpro_01.JPG

    And here is a FC screenshot:
    FlowCanvas.JPG
    How would I do this in FC? ... And in NC?

    Another question, for a RPG/Simulation style of game, would you recommend creating classes for the different Characters (attributes and so on) or could I stay completely within FC and NC?

    Thanks!
     
  26. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    I'm not author of FC/NC, but I try answer to first question,
    Its because FontStyles enum in TMP not marked as [Flags]. While it use custom inspector - all works fine, but standart inspectors can't handle this in "normal way". But you can use this node, I write it very fast, if dont work correctly, let me know.

    Code (CSharp):
    1. using FlowCanvas;
    2. using FlowCanvas;
    3. using ParadoxNotion.Design;
    4. using TMPro;
    5. using UnityEngine;
    6. #if UNITY_EDITOR
    7. using UnityEditor;
    8. #endif
    9. namespace Core.Tools
    10. {
    11.     [Name("TMP Font Style Chooser")]
    12.     [Category("Variables")]
    13.     [Description("Returns font style for Text Mesh Pro.")]
    14.     [ContextDefinedOutputs(new [] {typeof(FontStyles)})]
    15.     public class TmpFontStyleNode : FlowNode
    16.     {
    17.         [SerializeField]
    18.         private int style;
    19.  
    20.         protected override void RegisterPorts()
    21.         {
    22.             base.RegisterPorts();
    23.             AddValueOutput("Value", () => (FontStyles)style);
    24.         }
    25.  
    26. #if UNITY_EDITOR
    27.         protected override void OnNodeInspectorGUI()
    28.         {
    29.             EditorGUI.BeginChangeCheck();
    30.             EditorGUILayout.BeginHorizontal();
    31.             int styleValue = (int)style;
    32.             int v1 = GUILayout.Toggle((styleValue & 1) == 1, new GUIContent { text = "B", tooltip = "Bold"}, GUI.skin.button) ? 1 : 0;
    33.             int v2 = GUILayout.Toggle((styleValue & 2) == 2, new GUIContent { text = "I", tooltip = "Italics" }, GUI.skin.button) ? 2 : 0;
    34.             int v3 = GUILayout.Toggle((styleValue & 4) == 4, new GUIContent { text = "U", tooltip = "Underline" }, GUI.skin.button) ? 4 : 0;
    35.             int v7 = GUILayout.Toggle((styleValue & 64) == 64, new GUIContent { text = "S", tooltip = "Strikethrough" }, GUI.skin.button) ? 64 : 0;
    36.             int v4 = GUILayout.Toggle((styleValue & 8) == 8, new GUIContent { text = "ab", tooltip = "Lowercase" }, GUI.skin.button) ? 8 : 0;
    37.             int v5 = GUILayout.Toggle((styleValue & 16) == 16, new GUIContent { text = "AB", tooltip = "Uppercase" }, GUI.skin.button) ? 16 : 0;
    38.             int v6 = GUILayout.Toggle((styleValue & 32) == 32, new GUIContent { text = "SC", tooltip = "Smallcaps" }, GUI.skin.button) ? 32 : 0;
    39.             EditorGUILayout.EndHorizontal();
    40.             if (EditorGUI.EndChangeCheck())
    41.             {
    42.                 style = v1 | v2 | v3 | v4 | v5 | v6 | v7;
    43.             }
    44.         }
    45. #endif
    46.     }
    47. }
    48.  
    It looks like this:
    upload_2017-2-11_13-20-47.png

    While in FlowNode OnNodeGUI is sealed we cant override Node GUI and can use only inspector panel.
    (For NC its must ctreated in seam way, I dont use it, and dont try implement nodes for it)

    Second question in my opinion dont have "right" answer. It all very much depends on the architecture of your game, not game style.
     
    Last edited: Feb 11, 2017
    GamerPET, nuverian and Smolli like this.
  27. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Wow! Sorry for replying so late, but wow! Wonderful and it works perfectly. Thank you very very much fot this!
    Btw, do you know why [ContextDefinedOutputs(new [] {typeof(FontStyles)})] ContextDefinedOutputs is red underlined? It says unknow symbol, but it still works???

    Ok, I must admit that I didn't understand everything, as I'm no pure coder :)

    Hmm, I will try the classes first method and see howit works.

    Thanks again for your help!
     
  28. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    What IDE you use? And can you share screen shot with error?
     
  29. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    I use the Scriptinspector 3 as IDE, a very nice tool btw.
    Here is the screenshot.
    TMP_FC.JPG
     
  30. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    Maybe you must send bug report to author of "Scriptinspector 3" because in Visual Studio and MonoDevelope all works fine.
     
  31. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Hi,
    me again :) Any ideas why FC is always loosing the references? No matter what I select as Reference, saving it, after I quit and restart Unity they are gone.
    TMP_FC_onClick_LoosingReference.JPG Unity_TMP_FC_onClick_LoosingReference.JPG

    And another question regarding the first screenshot with the Toggle on click, is this the correct way to do it?
     
  32. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Ok, but it still works fine, it's only red underlined, maybe a warning that is not crucial?
     
  33. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    Its talk to you that them dont find class, but its exist (thats why all works fine, IDE and Unity dont use the same techs for code review/compiling). But I think you can help author of this asset and tell him about this bug (because its really bug).

    Anyway. About loose reference - you actualy use unbound FlowGraph (this graph without any scene or prefab owner) this graph cannot save any scene references! You must create bounded graph and use them. About it you can read in docs =)
    About you second question, yes, I think its must work (if I understand what you try implement) but maybe using of FlipFlop nodes be better. =)
     
    nuverian and Smolli like this.
  34. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    I already noticed that you never sleep ;) And I really appreciate your help, helps me so much going on!
    I will send the author of SI3 a bug report.
    Bindings, yes! That was it, thanks again for that!
    And yes, FlipFlop is what I was after :)

    Can't thank you enough for your help!
     
  35. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    No, I sleep some times (actually I plan go to sleep right now) =) glad I could help =)
     
  36. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    :D Have a nice sleep then :D
     
  37. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Hi,

    I have a rather basic question about using Classes and Instances. Maybe it has already been answered but since I cannot search thorugh a single thread I may have missed it.
    The question is about the best way for FC/NC to use/create classes/instances/fields/properties in comparison to the normal Unity way.
    I simply don't know where to start. I have created a test-class and instantiated through FC Add-Type. Is this the correct way? Or should I leave the instantiating inside a script I call through FC?
    What about namespaces? About [System.Serializable]
    That's where I would need a few answers to or a short tutorial.
    A Wiki would be nice to, to gather all questions and answers btw :)

    Thanks!
     
  38. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    Lets try understand what you mean =)
    So. There is no direct parallelism between C# paradigm and FC/NC paradigms... But its can be explain with few simplifications.
    1. Flow/FSM/Tree Graph - its class in progarmming termins. You can create this asset in asset folder and assign them to many objects on scene. Its allow you create "instance" from this class. But you cant create "child classes" use polimorphism and another features of C#.
    2. Fields and properties. So if we talk about properties and fields - graph variables its class (private) fields, you can acces them from any flow inside FC (I think in NC its work in similar way, I dont use it). Variables exposed in Black Board - its public properties and fields, you can acess to them from outside and set/get values.
    3. Events - its your methods (predefined and custom) and Flow which created by event its your execution of this method. FC right now dont provide any "local" Flow variables, but its may changed soon, because some peoples request this feature =)
    4. And main point - understanding. FC/NC/Playmaker/Uscript - ALL VISUAL SCRIPTING SOLUTIONS - its not replacement of standart C# scripting. Its good and usefull adidition. You can use it for prototyping (without time wasted for recompile), you can use it as "asset" logic container (in my game all spells its special flow graphs, but core casting logic realized on pure C#, in graphs stored only "spell scenario" - hit that, wait 10 seconds, hill that for example) and you can store it in asset bundles or use as dynamic loaded code - but anyway, use it for all logic in game - its bad design.
     
    Smolli and nuverian like this.
  39. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
  40. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    I think that its need very very large time spent for author...
     
    Last edited: Feb 13, 2017
  41. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    @mf_andreich Thanks a lot for helping @Smolli out! I really appreciate it and these are very good answers indeed. I couldn't have answer them better myself :)

    @Smolli You can also use the FC forums if you want by the way, since indeed searching through this thread for previous answers is not very easy like you said, whereas in the FC forums, things are somewhat more organized to find :)
     
    GamerPET and HolyShovel like this.
  42. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Hi @mf_andreich, you seem to be the best supporter here :)

    1) Ah, ok, but what about Data-Classes for example. It would be easy in c#, or completely in FC, or use the c# data classes within FC? I'm still very unsure when to use what.
    2) Hmm, normally I would use getters and setters. In the inspector I could set them, but I cannot directly change them from FC, or can I? How are blackboard variables related to the public class-variables I can see in the inspector?
    3) This one I didn't totally understand. I can use all methods inside FC, but I cannot directly access the c# varaibales?
    4) I think that is my main problem. When to use what. Looking at Blox 3 (which I don't have, but from the manual and the tuts) it's like completely programming but with a Scratch type method. Whatever you would do in c# you do with blox 3. It just has some magic (like FC has with automatic type casting and so on) to prevent errors.
     
  43. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Shouldn't it be shorter than with c#? The coding part is already pretty small.
    For me it would be a great help if someone could simply explain me how/why he/she would do what parts in c# and what with FC? I'm constantly switching between both and don't really progress.
     
  44. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Indeed, that was ultra helpful!
    I did, but did you know that your server is very slow, which makes navigating quite sluggish.
    It would be cool to have some more projects to depict the best way how for what parts to use FC btw. The above mentioned Puzzle tutorial just came to my mind, because I watched it and everything was very clear to me. Only when trying to figure out what parts I would do with FC is when it's started to become cumbersome.
     
  45. HolyShovel

    HolyShovel

    Joined:
    Jun 19, 2013
    Posts:
    156
    1) Can you explain what you mean by "Data-Classes"
    2) You can change (get/set) BlackBoard variables of FlowCanvas from FC graph and from pure C#.
    3) FC use "Flow" paradigm. Flow its execution line goes from event to end through nodes. All nodes on this flow - its "execution plan" of event. And ALL this stuf - can be named "method" if we talk about parallels with C#. From FC you can get/set properties of C# objects, call methods, as form C# you can call custom events in FC why not? Its very flexible system.
    4) Its more general understanding than "I tald you do it like that and now you know how design your game" and its looks like question "How create cool games?". I cant get right answer, because I dont have this knowlege =) You need try, ask when you cant do something (dont ask question like "How I need do that?" ask "I try, but something wrong... How I can fix it!" sense the difference), watch tutorials, and try, try, try again! Its usual learning process.
     
  46. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    1) Data Classes are classes that only hold variables, arrays, lists and so on, like rooms, items, questions( like in the puzzle example. Here is a link to the example: https://unity3d.com/learn/tutorials/topics/scripting/data-classes?playlist=17117
    2) Ok, only through getter/setter, no direct access to the public variables.
    3) Ok, that's what you meant, then I understood.
    4) Sorry, but no, this is absolutely not a question about 'How do a make a game', but more about the philosophy behind FC. What is it's intention? How can it help and how must I use this tool to actually be a help and not a hindrance.
    Every tool on top of Unity has it's purpose and it's best way how to use it. I understand Playmaker (although I don't really like it so much), I understood how to best use Blox 3 (if would own it), I understood the intention and purpose if IcanScript, it's all very clear. Even NC is clear to me, but FC? It didn't make click. Is it there to not have to code? Would I better code and only when it's pure logic then switch to FC? Or the other way around? I wouldn't know where to put FC right now, it's no Blox, ICanScript, Playmaker, ... a little of it all. I just want some help to better understand where to put FC, and how to use it following best it's philosophy. And I do watch tutorials, hence why I'm easier with C# than FC ;) There are NO tutorials to watch or read about FC and this is a big miss. And believe me, normally I'm a very auto didactic learner! And I bought FC (and NC) to make my life easier, not more difficult ;) Tutorials rule the world and that's why Playmaker for example is successful, even though the combination of NC/FC is maybe much much better.

    I think this would be @nuverian 's task now as developer to jump in and explain more.
     
  47. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Not knowing better and easier to read (for me) I will stick to code for most part and use FC for the Logic only.
    So, getters and setters, no problem, but Dictionaries don't work.
    I tried this and it won't show up in FC. Are Dictionaries not possible?

    Code (CSharp):
    1.     public Dictionary<string, string> users = new Dictionary<string, string>();
    2.    
    3.     public void Set(string key, string value)
    4.     {
    5.         if (users.ContainsKey(key))
    6.         {
    7.             users[key] = value;
    8.         }
    9.         else
    10.         {
    11.             users.Add(key, value);
    12.         }
    13.     }
    14.    
    15.     public string Get(string key)
    16.     {
    17.         string result = null;
    18.        
    19.         if (users.ContainsKey(key))
    20.         {
    21.             result = users[key];
    22.         }
    23.        
    24.         return result;
    25.     }
     
  48. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Hi,

    now that the Unity Forums finally have a thread search this helps a lot. I found the issues with the Dictionary types.
    And that I should NOT use getters/setters in the code.
     
  49. nuverian

    nuverian

    Joined:
    Oct 3, 2011
    Posts:
    2,052
    @mf_andreich
    Thanks again for helping by :)

    @Smolli
    Considering that you are code savvy and generally speaking, I would always recommend using FlowCanvas (or any visual scripting system able for that matter) on top of your own code. So your code/scripts would more or less contain the various things that you would want to do in your game and then use FlowCanvas on top of that (get/set properties, call methods, await events) to manage and bring your scripts functionality together, thus for creating the logic rather than the underline game backend or complex algorithms. You could probably use FC completely on it's own and that could be possible, but once again, managing existing functionality and creating logic is the best use case in my opinion.

    Also, FC being an event-based system at heart (since that is where flows begin in the graph), it is naturally best suited for things in the game that are also even-based in nature. Gameplay controls for example, are not really event based, and input controls don't really qualify as events. What I am talking about here are events like as seen in an adventure game for object interactions, or even as seen in a turn based strategy or card game for unit/card abilities, where in both cases a series of broader scope "stuff" will happen.

    The best way to think for where FC can be a good fit, is to think from the side of the game designer only. If you only had the role of the game designer, what building blocks would you like to have, or would ask from your coders to create for you? The answer is the nodes you most probably want to use in FC :) At least that's how I think it.


    So, regarding your other questions, if you are referring to being unable to access field members, that is something that is already made possible and will be available in the next version.

    Regarding Dictionaries, technically they are supported even though there are no nodes available for them due to difficulties encountered in the UI due to having two generic arguments.
    With that said, if you get a reference port to a dictionary you can drag&drop the port on the canvas to use dictionary related method/properties. Here is a step-by-step:

    1) We use this example script where we have property created for a backing dictionary field (once again, next version will support fields directly).
    Code (CSharp):
    1. public class Example : MonoBehaviour {
    2.  
    3.     public Dictionary<string, GameObject> _dictionary = new Dictionary<string, GameObject>;
    4.     public Dictionary<string, GameObject> dictionary{
    5.         get {return _dictionary;}
    6.         set {_dictionary = value;}
    7.     }
    8.  
    9. }
    2) Drag and drop the attached component of Example in the FC canvas. Select to get our property.
    3) Drag and drop the out value port into empty canvas to get list of available things possible with this type.

    DictionaryUsage.gif

    Finally, I have attached for you here 2 files that I've made in the past with nodes for working with dictionaries. These nodes are made to only work with string as key, but any type as value (again due to UI difficulties of 2 arguments).

    The first file is a number of nodes possible to find under "Functions/Dictionaries"
    DictionaryNodes.png

    The second file is for creating a new dictionary within the flowscript, very similar to the existing "CreateCollection(T)" node and found under "Variables/"
    CreateDictionary.png


    I hope the above works for you and helps clarify things as well :)
    If I miss something, let me know.
    Cheers.
     

    Attached Files:

  50. Smolli

    Smolli

    Joined:
    Mar 12, 2014
    Posts:
    76
    Yes absolutely, even if I may have strained his patience :)

    Thank you very much for your thorough answer. I was constantly switching between 'do it all with FC' and 'F***, I'll code it all' :)
    Now with your explanation and your example as thinking as a Game Designer I have shifted my mind (don't know the right terms in english :)) by that I mean that I now develop as Game Designer on one side and as coder working for the Game Designer, so providing the methods needed to be able to concentrate on the the Game itself, the fun part :)

    This means of course that I really have to get my hands dirty with the Unity Api, something I was thinking to be able to prevent :) I could maybe, but the result could get really bloated and messy for anything larger.

    I found another way to handle it instead of using Dictionaries, I used a combination of a List and another class. That provides more flexibility for now. But I'm sure the Dictionary will come handy sooner or later, so thanks.

    I sure hope that some day a few tutorials will be released. The time spent there could save you time for the development.

    Cheers
     
unityunity