{"id":4128,"date":"2023-02-03T12:29:36","date_gmt":"2023-02-03T03:29:36","guid":{"rendered":"https:\/\/blog.criware.com\/?p=4128"},"modified":"2024-06-05T16:00:12","modified_gmt":"2024-06-05T07:00:12","slug":"adx2-and-unity-visual-scripting","status":"publish","type":"post","link":"https:\/\/blog.criware.com\/index.php\/2023\/02\/03\/adx2-and-unity-visual-scripting\/","title":{"rendered":"ADX and Unity Visual Scripting"},"content":{"rendered":"<p><a href=\"https:\/\/unity.com\/features\/unity-visual-scripting\">Unity Visual Scripting<\/a>, released as an official feature in Unity 2021, allows for the implementation of game logic without writing code. Both programmers and non-programmers can use visual, node-based graphs &#8211; not unlike Unreal Blueprints &#8211; to design the final logic behind game levels or quickly create prototypes.<\/p>\n<p>In this post, we will see how to access the features provided by the Criware Unity Plug-in from Unity Visual Scripting.<\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Setup<\/h2>\n<p>In order to use the Criware-related classes as Visual Scripting nodes, they must be added manually after importing the Criware Unity Plug-in into your project.<\/p>\n<ul>\n<li>In the menu, go to <em>Edit<\/em>, <em>Project Settings<\/em>.<\/li>\n<li>Click on the <em>Visual Scripting<\/em> category.<\/li>\n<li>Expand the <em>Node Library<\/em> list.<\/li>\n<li>At the end of the list click on the + button, and add the <strong>CriWare.Runtime<\/strong> assembly.<\/li>\n<li>If you are using the <em>Asset Support Add-on<\/em>, add the <strong>Criware.Assets.Runtime<\/strong> instead.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4132\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/01-Node-List.png\" alt=\"01 Node List\" width=\"1294\" height=\"794\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/01-Node-List.png 1294w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/01-Node-List-300x184.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/01-Node-List-768x471.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/01-Node-List-1024x628.png 1024w\" sizes=\"auto, (max-width: 1294px) 100vw, 1294px\" \/><\/p>\n<ul>\n<li>Then, expand the <em>Type Options<\/em> list.<\/li>\n<li>Click on the + button at the end of the list, and add <strong>Cri Atom Source<\/strong> or <strong>Cri Atom Source For Asset <\/strong>(with <strong>Cri Atom Assets<\/strong> optionally), depending on your configuration.<\/li>\n<li>Finally, click on the <strong>Regenerate Nodes<\/strong> button to add the Criware-related nodes.<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4133\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/02-Type-Option.png\" alt=\"02 Type Option\" width=\"1296\" height=\"796\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/02-Type-Option.png 1296w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/02-Type-Option-300x184.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/02-Type-Option-768x472.png 768w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/02-Type-Option-1024x629.png 1024w\" sizes=\"auto, (max-width: 1296px) 100vw, 1296px\" \/><\/p>\n<p>To check that everything is working you can create a really simple script:<\/p>\n<ul>\n<li>In your scene, create a new Game Object.<\/li>\n<li>Add a <em>Cri Atom Source<\/em> component to the game object, and select the Cue you want to play.<\/li>\n<li>Below, add a <em>Script Machine<\/em> component, and create a <em>New<\/em> script from there.<\/li>\n<li>Click on <em>Edit Script<\/em> to open the Script Graph window: you should see an empty graph with only the <em>On Start<\/em> and <em>On Update<\/em> nodes.<\/li>\n<li>Right-click on the graph to open the node selector, and type <em>Cri Atom Source<\/em> to see every node available.<\/li>\n<li>Select the <em>Play()<\/em> node to add it to the graph.<\/li>\n<li>Then, connect the output of the <em>On Start<\/em> node to the input of the <em>Play<\/em> node.<\/li>\n<li>Now launch your Scene. You should hear the Cue being played from the start.<\/li>\n<\/ul>\n<p style=\"text-align: center;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-4134\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/03-OnStart-Play.png\" alt=\"03 OnStart Play\" width=\"907\" height=\"496\" srcset=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/03-OnStart-Play.png 907w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/03-OnStart-Play-300x164.png 300w, https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/03-OnStart-Play-768x420.png 768w\" sizes=\"auto, (max-width: 907px) 100vw, 907px\" \/><\/p>\n<h2 style=\"font-size: 150%; font-weight: bold; margin-top: 40px;\">Some examples<\/h2>\n<p>Within Unity Visual Scripting, many functions and logic nodes are available to help you build scripts.<\/p>\n<p>In the following example, we created a small system that plays a cue when a button is clicked and stops when clicked again. We simply use the <em>Once<\/em> node to trigger the <em>Play <\/em>and <em>Stop<\/em> node alternately. Should the Cue be allowed to play until the end, extra logic was added to reset the button behavior. In order to achieve this, the Cri Atom Source\u2019s <em>Get Status<\/em> node is used to reset the <em>Once<\/em> node when the Cue sends a <em>PlayEnd<\/em> message.<\/p>\n<div class=\"wp-video\" style=\"width: 800px; display: block; margin: 40px auto;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4128-1\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-01-Visual-Scripting-Button.mp4?_=1\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-01-Visual-Scripting-Button.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-01-Visual-Scripting-Button.mp4<\/a><\/video><\/div>\n<\/div>\n<p>In the second script, we change the value of an Aisac by moving a slider. A <em>Set Aisac Control<\/em> node is connected to an <em>On Start<\/em> node. Coupled with a <em>Slider Get Value<\/em> node, this allows us to initialize the value of the targeted Aisac. Then, the <em>On Slider Value Changed<\/em> node forces the <em>Set Aisac Control<\/em> node to update the value when the slider is moving.<\/p>\n<div class=\"wp-video\" style=\"width: 800px; display: block; margin: 40px auto;\">\n<div style=\"width: 800px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-4128-2\" width=\"800\" height=\"450\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-02-Visual-Scripting-Slider.mp4?_=2\" \/><a href=\"https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-02-Visual-Scripting-Slider.mp4\">https:\/\/blog.criware.com\/wp-content\/uploads\/2023\/02\/Video-02-Visual-Scripting-Slider.mp4<\/a><\/video><\/div>\n<\/div>\n<p>Visual Scripting is very helpful when it comes to creating small scripts and quick prototypes. If you are not a programmer, this will allow you to be more independent when implementing audio with ADX.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unity Visual Scripting, released as an official feature in Unity 2021, allows for the implementation of game logic without writing<\/p>\n","protected":false},"author":2,"featured_media":5530,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"colormag_page_container_layout":"default_layout","colormag_page_sidebar_layout":"default_layout","footnotes":""},"categories":[5,7],"tags":[],"class_list":["post-4128","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-adx","category-tutorials"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/4128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/comments?post=4128"}],"version-history":[{"count":12,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/4128\/revisions"}],"predecessor-version":[{"id":5529,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/posts\/4128\/revisions\/5529"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media\/5530"}],"wp:attachment":[{"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/media?parent=4128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/categories?post=4128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.criware.com\/index.php\/wp-json\/wp\/v2\/tags?post=4128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}