Questions on Scripting

I have a couple questions on Scripting.

  1. I created a script, and on opening, it ran in VS-Code.
    That’s good. The only problem is, I don’t get code completion, which is strange, I think.
    I have the three extensions installed - C/C++; C#; Mono Debug.
    Is there something missing for code completion in C#?

  2. I tried to use Visual Studio, as the code editor, so I enabled VS2022, but that doesn’t even start (I checked the Task Manager).
    I tried VS2019, which shows up in the Task Manager’s Background Processes, but that’s as far as it gets. I waited a long time for it to start, but it doesn’t.
    Now that I think about it, maybe I should start it before opening the script.
    I haven’t missed anything important, have I?

  3. I wanted to try out Visual Scripting, but I need a push start.
    I selected a Vector 3 node in order to declare a variable, but I don’t know what to do.
    How do I declare a variable, like this, with Visual Scripting?

Vector3 norm;
Vector3[] arrays = {};
  1. For Flax, I have the .NET Framework 4.8, C#, C/C++, and Mono Debugger installed and autocompletion works for me. I have a lot of software, so I don’t remember if any of these are required for Flax specifically, but maybe this will help you out. The reason why I don’t use VSCode is because Flax uses the .NET Framework 4.5.1, which is not available to download anymore. So, any time I modified the scripts in Flax, I’d have to go into the Game.csproj file and change the .NET target from 3.5 to 4.8 manually to get autocompletion working. Doing that after each time I crate, rename, move, delete, or otherwise modify a script in Flax Engine gives me autocompletion:
    image

  2. That sounds like a bug that you should file, if it happens consistently. I’ve never experienced that issue personally with any Visual Studio version. Although, Visual Studio will at first open a dialogue window asking to convert the NET target from .NET Framework 4.5.1 to 4.8. I let it do that, and it opens for me.

  3. Variables in Visual Script are called Parameters. Create a new parameter from the side bar and select the type:

You can double-click the name to rename the parameter and you can adjust its initial value:
image

To switch it to an array, right-click the parameter and select Type > Array:
image
You can also use this menu to change the access modifier. I hope this helps you out!

1 Like

I don’t have a .csproj in my project’s directory.
Wouldn’t that be created by Visual Studio?

I’ll try it a couple more times, before I do anything else, thanks.

Thanks. That’s helpful.
I’m looking at the manual, but not seeing anywhere, where I can get this kind of help. Is there any docs on these, so that one can know how to use Visual Scripting with more ease?

1 Like

If you set the code editor to VSCode in the Flax Editor Options, then it should automatically generate the project files for you. If not, you can go to File > Regenerate Script Project Files.

Unfortunately, yeah, Visual Script lacks almost any documentation. I came from UE, so I could translate most of my Blueprint knowledge pretty easily. But for anyone new to Visual Scripting, the Docs aren’t going to be of much help.

Something must be wrong with my system, because no project files are generated, despite following those instructions.

For Visual Studio, does Flax try to run a 32 bit instance of VS.
msvs1
I’m wondering if that’s why it doesn’t start.
Half an hour after, and Visual Studio doesn’t open.

I’m a quick learner, so once you get me started, I’ll be able to work my way through.

So, how do I declare a variable, like the following?
norm = new Vector3();

This looks wrong, for some reason.

I’m wondering if Flax has a hard time when multiple versions of Visual Studio are installed? I only have VS2022, and before that I had VS2019 64-bit.

As far as I’m aware, variables are initialized when they are created in Visual Script, similar to Blueprints. So, your initial value will be in the side bar, and it has a default value of Vector3.Zero.
image

I’ve never used that node before, but it seems to be used when creating objects. Your current node setup would translate to this in C#:

public override void Start()
{
    norm = Vector3.Zero;
    Object.NewValue<Type>();
}

The white lines are used to declare code flow. Whatever is connected to the current node will be called after the current node has finished executing. The circles are used to transfer data, such as a String:
image
The color of the line indicates its type. White is Impulse (a.k.a. execution flow), green is float, red is boolean, yellow is Vector3, etc.

I can see that happening, if Flax is using a registry key, or a location which all versions of VS uses.
Do you know where Flax looks?

Thanks for the Visual Scripting start.

1 Like

Looks like it reads the registry key.

I also have 4 different VS version , but if your set it to “Default” it will use the windows extension associate, so it will act just like if you double click it in explorer , that works for me :slight_smile:

cs-associate

1 Like

Ouch. That will hurt.
I’ll have to keep changing that when I have a file that requires VS2010, and so forth.

I’ve decided to just create a project in VS, edit the code there, debug it, and then copy it to my project.
Thankfully, VS supports the Flax engine.

@Spectrix I found a video that can help me with Visual Scripting.
Apparently, Flax and Unity have similar Visual Scripting components.