That’s not true by today’s standards of programming. In fact, some consider comments to be a code smell. Readable code is achieved by naming and structuring things correctly which typically doesn’t involve comments since the code explains itself. There are exceptions to the rule but not many.
With code that does various complex functions, and may access memory of something defined by some numbers (but what), comments really help. The problem with code is making tidy comments, it’s not easy. I personally think you can never have too many comments depending who the audience is. But, given that the coding process is the main part, it’s about spending a little time after to organise with some comments which I know is rarely done in the programming community. Algorithms that’s another thing though, although a pseudo comment might help.
For example, while trying to understand code for RenderMeshIndirect I commented until I understood. Some ? where I am asking myself to fully understand. I’d love to mess with some voxels, so my idea this could simply be an offset, a cube region/half, and then numbers for each position, changed to a position in memory (if say using a 8x8x8 to fit into 256 as half a cube). But it does help to write comments to develop into things.
void InitialiseBuffers()
{
// -- Setup Instance Positions --
// Init array of float3 - positions changed to Matrix4x4 in shader
positionsV3 = new NativeArray<float3>(instances, Allocator.Temp);
// Test case, random square based on the range size
for (int i = 0; i < instances; i++)
{
float2 pos = new float2(UnityEngine.Random.Range(0, terrainWidth), UnityEngine.Random.Range(0, terrainWidth));
positionsV3[i] = (float3)transform.position + new float3(pos.x, noise.cnoise(pos/10f), pos.y);
}
// -- Setup PositionsBuffer --
// Init buffer with the size of positions, each item being 3 * float (convert to matrix on shader less memory)
GB_positionsBuffer = new GraphicsBuffer(GraphicsBuffer.Target.Structured, positionsV3.Length, 3 * sizeof(float));
// Send positions to the PositionsBuffer
GB_positionsBuffer.SetData(positionsV3);
// Clean up memory
positionsV3.Dispose();
// -- Setup CommandBuffer --
// -- Initial settings required to access the GPU buffer
// Initialise CommandBuffer
GB_commandBuffer = new GraphicsBuffer(GraphicsBuffer.Target.IndirectArguments, commandCount, GraphicsBuffer.IndirectDrawIndexedArgs.size);
// Initialise CommandData (indirect arguments/settings that go into CommandBuffer)
GB_commandData = new GraphicsBuffer.IndirectDrawIndexedArgs[commandCount];
// Indexes of submesh 0
GB_commandData[0].indexCountPerInstance = mesh.GetIndexCount(0);
// Initial vertex index in mesh?
GB_commandData[0].baseVertexIndex = 0;
// Difference to above?
GB_commandData[0].startIndex = 0;
// This doesn't actually work, would be useful to set an offset. Can only be done in shader currently
//GB_commandData[0].startInstance = (uint)startInstance;
// Set number of instances to show from 0..x
GB_commandData[0].instanceCount = (uint)drawInstances;
// Send CommandData to Command Buffer
GB_commandBuffer.SetData(GB_commandData);
// -- Setup Render Parameters -- The specific parameters for rendering, including access to shader buffer
// -- Full list https://docs.unity3d.com/2021.2/Documentation/ScriptReference/RenderParams.html
// Init with a material
renderParams = new RenderParams(material);
// Set receive shadows
renderParams.receiveShadows = true;
// Set shadow casting mode
renderParams.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
// Set bounds of object - bounds are what are seen by the camera when culling. Bounds(centre, corner of 3D bounds). Defaults to object size if unset
//renderParams.worldBounds = new Bounds(startBounds.position, endBounds.position);
// MaterialPropertyBlock so you can access the custom StructuredBuffer in the shader
renderParams.matProps = new MaterialPropertyBlock();
// Send PositionsBuffer to the GPU ShaderBuffer
renderParams.matProps.SetBuffer("_PerInstanceData", GB_positionsBuffer);
}
void Update()
{
// Draw the instances
Graphics.RenderMeshIndirect(in renderParams, mesh, GB_commandBuffer);
}
Anyway, the one thing missing from all Visual Script ideas that exist, is the ease of access cutting and pasting and sharing, which was actually my first project/hole I noticed with VS.
Code, what do you do, a bit of online cut and paste etc, VS thats a no, files yes but thats inconvenient compared to cut and paste. Maybe I’ll go back to that project at some point. Did require some heavy compression on JSON.
A picture is worth a thousand words, but yes. user cannot copy paste the graph and use it without understanding it like you can with typed code. I would call that a bonus when learning because it forces you to actually “show your work” and do it. You can just take the graph and share that though via file share the same as a text file.
Would be sweet to copy text code and convert that automatically to nodes.
or some kind of “workshop” for nodes that the community could contribute
Well I’m a big dreamer, and was full of enthusiasm when I first got into VS (still am but always off on some tangent of discovery currently delegate* lol). One idea I had was a kind of separate window linking to some server with foldable/searchable categories of stuff, where users can upload their graphs into some category with a screenshot. And then if you are looking for some particular way of doing something you can just copy it straight into your graph (with a copy/paste function yet to exist except in my own project). In a way you could have a user system for everything in Unity, eg. Shadergraph user library. All with cut and paste straight in, no file to download/import. That’s what I do like about graphs, working outside the main assembly reload.
For myself, I find the challenge I have whenever I start a new project is maybe I had useful Editor addons here and there - I then have to remember what they were, where they are, just to build the editor setup I try to remember I had. So one project I might work on is a global SSD/hard drive cache to send files to, or to update if there’s a newer version (or I modded my own tool to be better). And then within Unity, I will always be linked to this central cache of stuff that I can favourite etc. Maybe this is beyond my skills at this point. I know people use GitHub, but not sure it’s the same thing. Package manager/assets, not what I mean either as these are a bulk of files. I kind of mean a 2nd Project window of all my global stuff, or even simply showing every project/assets I have created just listed there so I can grab items, move them to an accessible place (global Project folder), so I know always where it is.
I’ll keep dreaming unless I one day create it myself!
Yes, manually collapsing stuff is not always super useful, but can help shrinking a bunch of stuff and collapsing come for free with GTF, not as nice a collapsible/expandable group.
For Icons, visual scripting team is pushing to keep those it was already part of the product core in the 5 previous visual scripting working products made before getting Bolt, we got good feedback from users for those. Same should go for edition fields on nodes.
If you haven’t seen what GFX graph is doing, with vectors, I think you will enjoy the solution they got with expandable ports. Unreal also have the same kind of behavior in Animation graphs and other graphs.
@ericb_unity Will the nodes be super customisable for making your own nodes? I liked working on my own nodes
It should at least be close to what Bolt/Visual Scripting have. What would you expect to be able to customize? Asking so we have your use cases in mind for the future and to add more weight to what users need/want. ^-^.
Oo neat.
I like how the wire sockets are inset into the panel and not floating around on the outside. looks like an audio jack ^.^ Sometimes, those connections glitch out with the current nodes. I hope this also fixes that too!
Feel like folks could easily overlook the little dropdown arrow at first, but once discovered it would be like finding out that you’ve had an ‘alternate fire’ the entire time. Recommend .GIF animations in the documentation that show the usage of everything.
I want to click on that cogwheel and see what’s in that ^.^
but as for customization: for a while I was hooked on just making subgraphs. Like i’d sit down and try to make the cleanest looking subgraph to so some function that I would reuse a lot. Like this little move node that I threw together as an example.
You can see how easy it would be to return to this project later on and instantly tell what it does. I was hooked on it like a video game itself. and WAY more fun then I’ve ever had lookin at functions with typed script. This needs to be a thing still.
I was NOT a fan of how you had to enter in the variables and data i/o from the blackboard on the side however. Most of the time i’d forget to hit enter and apply the Key name… but also… why not just enter it on the actual node? Just pointing this out as a thing that did not feel intuitive. I STILL forget sometimes that you set the ‘Select On’ over in the blackboard/ graph inspector lol
I also want to make it 100% clear that the EXPOSE node is awesome. and really helped me see what types of data is expected or sent or could be obtained. Normally you’d have to review documentation about somthin’ to figure it out… but here it’s like you can see it AND tap into them. I learned a lot just connecting a Debug Log node to the outputs. one of those little things that compounds on other things to make it fun.
Glad to hear. Also, thank you for being available for communication, this is very much appreciated.
I’m not sure if this is covered already but I’d like to dynamically change node’s outputs based on its input for both data values and flow control. For a simple example, say I have some data type that defines dialogue choice options which can range from say 1 to 15 different options. So for however many options the input contains, the node would dynamically display an output for each of those dialogue options.
Instead of manually adding new outputs in Graph Inspector like you do for Sequence, Switch, etc nodes, the node itself would automatically configure the outputs based on rules user defines in the custom node. i.e. no input, no output ports or only the default passthrough output port. And output ports dynamically appear based on input.
Comments can be helpful but the ones in your example are worthless. A comment shouldn’t repeat what the line is already telling you. Instead a comment should tell you why you needed that line if it isn’t immediately obvious. If a line isn’t obvious and I have to open the docs any comments it had have just failed and should be removed.
I’ve never worked with the system that your code is interacting with but the only lines that don’t immediately have meaning to me are lines 9 through 13. Every other line should have it’s comment removed. After all do you really need to know that renderParams.receiveShadows = true;
means that you’re setting “receive shadows”?
Point taken however my comments are custom neon green so they overrule the code in english, rather than like you said reading both comments and code. I did literally comment every line i know so a bit overkill!
// Reply with comment here and move to the next sentence when period is typed.
I think everyone starts out typin’ more comments than code lol [ERROR]
// Continue reply while establishing that it’s alright to start off by typing lots of comments;
But it did help to translate from English to code until understanding more.
// Continue yet again and reenforce that it’s got a use.
Sometimes it’s like a doodle, trying to figure out what you need to do.
But you’ll get to a point when it’s not really necessary.
Unless working with others on a project, as a team, even more-so.
But if it helps you get to where you’re going. hey… that’s what comments are for!
//
Well if I can override the GUI/widget I can add things like sliders and textures. One node I got side-tracked on was a kind of tween node, showing the movement type in a graph/texture (not simple 0 to 1 animation curves). As it’s Visual Scripting the visual element can also be enhanced to be more visual.
Actually I was commenting every line for someone who doesn’t understand code, so there is that. I rarely see enough comments in code to show what absolutely everything is doing (yes some things being obvious).
I get what you mean, but I also get why @Welfarecheck said that.
When talking about structure, we must separate between the structure of higher level symbols (code architecture), and the structure of lower level symbols (code formatting). To explain this with exaggerated examples:
- Architecture:
Structure means subdividing your code into multiple classes/methods that make sense, vs having all your code in one method.
- Formatting:
Structure means making your code understandable at a glance.
int number = 5;
Console.WriteLine("The number is: " + number);
if (number > 0)
Console.WriteLine("The number is positive.");
else
Console.WriteLine("The number is not positive.");
vs having code difficult to read.
int number=5;Console.WriteLine("The number is:"+number);if(number>0){Console.WriteLine("The number is positive.");}else{Console.WriteLine("The number is not positive.");
While it is true that you can observe lack of structure at both levels for both C# and Visual Scripting, it is much harder to find at the lower level for C#. This is because the IDE/refactoring tools automatically do the formatting for you.
In Visual Scripting, though, you need to handle the formatting yourself. To alleviate this problem, I released a refactoring tool for Visual Scripting. You can find it here: Visual Scripting Enhancer | Visual Scripting | Unity Asset Store