{"id":353,"date":"2012-07-27T04:15:49","date_gmt":"2012-07-27T11:15:49","guid":{"rendered":"http:\/\/chazix-scripts.com\/?p=353"},"modified":"2012-07-31T05:32:44","modified_gmt":"2012-07-31T12:32:44","slug":"dialog-controller","status":"publish","type":"post","link":"https:\/\/chazix-scripts.com\/?p=353","title":{"rendered":"Dialog Controller"},"content":{"rendered":"<p><a href=\"http:\/\/u3d.as\/content\/chazix-scripts\/dialog-controller\/3aR\"><img loading=\"lazy\" class=\"size-full wp-image-354 alignleft\" title=\"Dialog Controller\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/post_icon.png\" alt=\"Dialog Controller\" width=\"128\" height=\"128\" \/><\/a>The <a href=\"http:\/\/u3d.as\/content\/chazix-scripts\/dialog-controller\/3aR\">Dialog Controller<\/a> has been designed to display dialog popups filled with textual data at the locations where a particular dialog is taking place.<\/p>\n<p>Data is read in from text files within the Resources directory within the Unity project folder. The text files are sorted and separated based off the name of the desired game object given within it&#8217;s own script behavior. Also, within it&#8217;s own script behavior, this is where its initial dialog state is set, this determines the initial read in dialog. <a href=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/ResourceInfo.png\" rel=\"lightbox-353\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/ResourceInfo.png\" alt=\"Resources Information\" title=\"Resources Information\" width=\"223\" height=\"209\" class=\"alignleft size-full wp-image-365\" \/><\/a>As seen within this image, this shows how what I call the <strong class=\"variable\">NPC (Non-Player Character)<\/strong> game objects dialog data is sorted to be picked when needed for the read in NPC&#8217;s particular dialog state.<\/p>\n<p>This data is picked based off the attached <strong class=\"variable\">Dialog Controller<\/strong> script attached to the <strong class=\"variable\">NPC<\/strong>. The <strong class=\"variable\">Resource Data Location<\/strong> is used to determine where the text files are located within the Resources folder. Also, and importantly, the <strong class=\"variable\">Initial Dialog State<\/strong> locates the initial dialog text within the text files, I will explain this more in depth later on. <a href=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogGameObject.png\" rel=\"lightbox-353\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogGameObject-300x148.png\" alt=\"Dialog Game Object Info\" title=\"Dialog Game Object Information\" width=\"300\" height=\"148\" class=\"alignright size-medium wp-image-370\" srcset=\"https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogGameObject-300x148.png 300w, https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogGameObject.png 367w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a>The next image shows the inputs I gave the <strong class=\"variable\">NPC Behavior<\/strong> script and <strong class=\"variable\">Dialog Controller<\/strong> script based off my example for the individual NPC objects. Within my scene initializing script I dynamically create and change the <strong class=\"variable\">Name<\/strong> attribute within the <strong class=\"variable\">NPC Behavior<\/strong> script. <!--more--><br \/>\n<a href=\"http:\/\/u3d.as\/content\/chazix-scripts\/dialog-controller\/3aR\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/post_BigImage.png\" alt=\"Dialog Controller\" title=\"Main Dialog Controller\" width=\"491\" height=\"389\" class=\"aligncenter size-full wp-image-354\" \/><\/a><\/p>\n<p>Dialog is created with simple text statements and implemented built in functions to either send dialog to a different game object or to change the dialog state of the current NPC a particular dialog is attached to. These are currently the only built in functions, but more will be coming down the road, such as sending a dialog statement to multiple game objects at a time. As seen in the next example, this text file called <strong class=\"variable\">Pondering.txt<\/strong> represents an NPC with the <strong class=\"variable\">Name<\/strong> value of <strong class=\"variable\">Pondering<\/strong> within the <strong class=\"variable\">NPC Behavior<\/strong> script. <a href=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/PonderingTextDataExample.png\" rel=\"lightbox-353\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/PonderingTextDataExample.png\" alt=\"Text Data Example\" title=\"Text Data Example\" width=\"521\" height=\"196\" class=\"aligncenter size-full wp-image-386\" srcset=\"https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/PonderingTextDataExample.png 521w, https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/PonderingTextDataExample-300x112.png 300w, https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/PonderingTextDataExample-500x188.png 500w\" sizes=\"(max-width: 521px) 100vw, 521px\" \/><\/a>The <strong class=\"variable\">Start<\/strong> line represents the <strong class=\"variable\">Initial Dialog State<\/strong> of the NPC object, the next line is the first line that is displayed, <a href=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample.png\" rel=\"lightbox-353\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample.png\" alt=\"Pondering Example\" title=\"Pondering Example\" width=\"342\" height=\"200\" class=\"alignleft size-full wp-image-388\" srcset=\"https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample.png 342w, https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample-300x175.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/a><a href=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample1.png\" rel=\"lightbox-353\"><img loading=\"lazy\" src=\"http:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample1.png\" alt=\"Main Player Response\" title=\"Main Player Response\" width=\"342\" height=\"200\" class=\"alignleft size-full wp-image-393\" srcset=\"https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample1.png 342w, https:\/\/chazix-scripts.com\/wp-content\/uploads\/2012\/07\/DialogExample1-300x175.png 300w\" sizes=\"(max-width: 342px) 100vw, 342px\" \/><\/a>which would look like the image on the left, the blue character represents the main player. As you can see, the three dots <strong class=\"variable\">&#8220;&#8230;&#8221;<\/strong> animate between <strong class=\"variable\">&#8220;.&#8221; -> &#8220;..&#8221; -> &#8220;&#8230;&#8221;<\/strong> repeating this, indicating that there is another dialog statement in this particular dialog. To both advance and initialize a dialog statement the <strong class=\"variable\">Activator Key: SPACE<\/strong> by default must be pressed. The <strong class=\"variable\">[R_MainPlayer]<\/strong> tells the system to send the dialog statement to the <strong class=\"variable\">MainPlayer<\/strong> object, which <strong class=\"variable\">MainPlayer<\/strong> is the name of the main player&#8217;s game object. Continuing on, the next statement in the dialog is sent to the Pondering NPC object, where finally the <strong class=\"variable\">[CS_NewStart]<\/strong> changes the Pondering NPC object&#8217;s <strong class=\"variable\">Dialog State<\/strong> to <strong class=\"variable\">NewStart<\/strong>. Take note of the space between the individual dialogs, this is <strong class=\"variable\">important<\/strong> to separate between dialogs.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Dialog Controller has been designed to display dialog popups filled with textual data at the locations where a particular dialog is taking place. Data is read in from text files within the Resources directory within the Unity project folder. &hellip; <a href=\"https:\/\/chazix-scripts.com\/?p=353\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[19],"tags":[12,11,35,13,22,23,9],"_links":{"self":[{"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/posts\/353"}],"collection":[{"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=353"}],"version-history":[{"count":38,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/posts\/353\/revisions"}],"predecessor-version":[{"id":381,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=\/wp\/v2\/posts\/353\/revisions\/381"}],"wp:attachment":[{"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chazix-scripts.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}