How to call C# code from an Ink Dialogue File in Unity | Ink External Functions

  Рет қаралды 7,304

Shaped by Rain Studios

Shaped by Rain Studios

Күн бұрын

This video covers how to call C# code in Unity directly from an Ink Dialogue File using Ink External Functions.
It references a dialogue system built in some previous tutorials; however, you don't need of seen those to understand what's happening in this one. That said, the below playlist contains all of the videos I've done on this topic which may help if you're just getting started with writing dialogue with Ink and Unity.
I hope this helps and best of luck! 🙂
► INK + UNITY TUTORIAL PLAYLIST
This playlist includes all videos I've done on Ink + Unity.
• Learn Ink (video game ...
► TIMESTAMPS
0:00 Intro
0:44 Ink External Functions
1:51 External Functions vs Tags
3:18 Project Overview
4:03 Implementing an External Function
5:59 Playing Emotes Example
8:58 External Functions at the end of the dialogue
10:12 Code Cleanup
12:38 Outro
► GITHUB PROJECT
The '8-ink-external-functions-example' branch contains the code by the end of this tutorial.
github.com/shapedbyrainstudio...
► RESOURCES
Ink Official Website
www.inklestudios.com/ink/
Ink + Unity Integration Documentation (including External Functions)
github.com/inkle/ink/blob/mas...
► MUSIC
The backing music is custom made by @themaykit.
/ themaykit
► DISCORD
Come ask questions, suggest a video topic, or just hang out!
📱Discord ➔ / discord
► THE PATH OF REN
Wishlist 'The Path of Ren' on Steam!
🎮 Steam (The Path of Ren) ➔ store.steampowered.com/app/16...
► SOCIAL MEDIA LINKS
Follow my current project!
🐦 Twitter ➔ / trevermock
📷 Instagram ➔ / trevermock
🕑 TikTok ➔ / shapedbyrainstudios
🌐 Website ➔ shapedbyrainstudios.com/
► SUPPORT
Any support is much appreciated! I may receive a commission on any assets purchased using the below Unity Asset Store link.
🛍️ Unity Asset Store Affiliate Link ➔ assetstore.unity.com/?aid=110...
☕ Buy me a coffee! (Ko-fi) ➔ ko-fi.com/shapedbyrainstudios
#gamedev #ink #unity

Пікірлер: 46
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
Hope you found the video to be helpful! Feel free to come by my Discord server and ask questions, suggest a video topic, or just hang out! ➔ 📱discord.gg/99gcnaHFf9
@ZOMGbies
@ZOMGbies Жыл бұрын
Oh my days I have been parsing tags through a switch since watching your last video(s) the other week after failing to discover this feature. I knew it must have it but I clearly didnt look hard enough. Thank you for this
@bigfatmomma
@bigfatmomma Жыл бұрын
Always great getting more ink tutorials. Best ink info around!
@DaddyOho
@DaddyOho Жыл бұрын
Incredible work, thank you!
@Haavenstadt
@Haavenstadt Жыл бұрын
Thanks Trevor, great stuff as always.
@user-yx5bf7dp4s
@user-yx5bf7dp4s 7 ай бұрын
What a good tutorial with details! Thank you so much!
@guybrushmonkey97
@guybrushmonkey97 Жыл бұрын
You've helped me so much with these videos, thank you!
@krzysis756
@krzysis756 Жыл бұрын
Your videos are really helpful for me right know, I started making my own quest system, when i was looking for dialogs I found your ink tutorials. thank you so much for your time spended on that tutorials
@user-go5qh1cj1p
@user-go5qh1cj1p Жыл бұрын
Thanks for this tutorial , u are my hero!
@divyankratoniya3613
@divyankratoniya3613 Жыл бұрын
hey brother really your tuttorials helps me a lot really I must say that you are doing great thanks for everything
@maxarthurw
@maxarthurw 5 күн бұрын
Thank you man! i can finally create a good dialogue system for my game with some modification! but i face a problem, so if you select a dialogue option with left click (instead of my main select key: Space) it will make the button highlight disappear, and if i press either space or left click again, it will close the dialogue instead of continue to the next dialogue. that's the only problem, the rest is good, thank you so much!
@raymonddavis7233
@raymonddavis7233 Жыл бұрын
I can’t tell you how amazing this channel is. If you need any digital art in the future, I’d be happy to help you out!
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
Appreciate the kind words a ton! 🙂I'm not in need of any at the moment, but I'll keep that in mind! Feel free to email me your portfolio if you'd like so I have it on hand (you can use the contact email listed on my KZbin page). Thanks a ton and best of luck!
@SanoKei
@SanoKei Жыл бұрын
this is so great 😭Thank you for sharing the code too! as a micro-indie dev this is always appreciated~
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
No problem! I'm really glad to hear you'll get some use out of it! 🙂
@echodff
@echodff Жыл бұрын
Ink all day baby 🥂
@yuriyzvirblis5327
@yuriyzvirblis5327 Жыл бұрын
Hello Trevor. Thank you very much for these videos, I never knew about Ink until you introduced the tool. I was wondering if you could do a video on how to actually build a quest system in unity which is triggered with Ink and how to make it conditional, for example if you finish a quest that an npc gave you than the dialogue will be different the next time you talk to him. Thanks!
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
Hey there! Really glad you found the videos helpful! I'm actually working on a Quest System tutorial right now, haha. It won't initially cover integration with ink dialogue, but I do plan on making a follow up video that shows exactly what you described. It may be a bit before both of those videos are finished, but definitely keep an eye out!
@ven6815
@ven6815 Жыл бұрын
Thank you
@Somewhere_sometime_somehow
@Somewhere_sometime_somehow Жыл бұрын
This is awesome!
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
Really glad to hear you think so! 😀
@markorossie9296
@markorossie9296 Жыл бұрын
Another great exciting and useful tut. Well done. Now it would also be interesting as a good complement to your serie of Ink, doing a tutorial how you use own customize string-commands and how to write a simplified parser in C# in order to interpret that string. For instance >>> CAMERA: top-down-1 Changing to a preset cameraobject named top-down-1 or >>> LIGHT: light-obj-2 or even >>> VoiceOver: 003.ogg or something like that in the text-contens. That would exciting to watch. The character >>> is only a matter of preference what the software easily should read as a potential customized string-command. Above is only what I have seen so far taken from a clip (GDC) showing using them, but not understand how to/where to start writing them 😞 Thanks again Trever, you doing inspiring videos
@durianc6138
@durianc6138 9 ай бұрын
Hey, I really like your video, it helped me to make my own dialogue system. Will you be making the best localization about ink in a future video?
@gminfly
@gminfly 11 ай бұрын
Thank you for these tutorials, they're always so helpful! I was wondering: do you think you might do a video on how to get the player's name from an input field? Or do you know where one could find info on this? Thanks again!
@ShapedByRainStudios
@ShapedByRainStudios 11 ай бұрын
Glad to hear they've been helpful! I think that would be a fun topic to put something together for, I'll definitely keep it in mind! I'm not aware of any other resources that cover that specifically, but in the meantime, here's a few thoughts off the top of my head that might help with implementing this. 1. Think of the Players Name as a global variable in Ink that will only get set once when inputting the name through an input field. Then, of course, use that variable anytime you want to refer to the players name in your Ink dialogue. 2. For the Input Field itself, CodeMonkey has a really good video that looks like it'll help get you started - kzbin.info/www/bejne/ap-Zg4duZZqlecU 3. As for linking those two things together (Input Field -> Setting the global Ink variable), you'll likely want to add a *SetVariableState()* method to the DialogueManager. It'll be really similar to how *GetVariableState* works (from one of the videos in this dialogue system series) except you can use it to set a variable in the global variables dictionary rather than get it. I have an example of this stubbed out in the FAQ section on my Discord if you need an example - discord.gg/99gcnaHFf9 From there, it should just be a matter of calling that SetVariableState method from the Input Field code and then using that global variable anytime you need to reference the players name. Best of luck and I hope that helps a bit!
@amongryzh
@amongryzh Жыл бұрын
Thanks for your great tutorials! I’d like to see a tutorial on how to delay typing on a certain character in the line.
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
Thanks for the suggestion! I'll definitely be keeping that in mind!
@Fyres11
@Fyres11 Жыл бұрын
Something I did by myself I'm sure people would like you to show would be to combine that dialogue system with fmod. Since I saw your fmod tutorial. I'm using fmod everywhere. Building a nice weather system with it.
@ShapedByRainStudios
@ShapedByRainStudios Жыл бұрын
For sure! I'll be keeping this in mind. Thank you for the suggestion and awesome job integrating them together yourself! 🙂
@Fyres11
@Fyres11 Жыл бұрын
@@ShapedByRainStudios You did the main job. Just took the scriptableobjects containing data from the dialogue system, combining it with the fmod part to remove the singleton containing all the fmod events and put event data in specific scriptable objects instead.
@furionstormrage4053
@furionstormrage4053 9 ай бұрын
Thank you for a short and straight to the point tutorial. I have a few questions, I hope you can spend a moment of your time to answer: 1. Why do we need to unbind external functions ? 2. Binding the same functions every time we start a new conversation surely does not affect performance noticeably, but it still does bother me. Is there a way to do it only once ? Something like, put all the external functions in a same ink file then included it in every other ink file ?
@_joshuazack
@_joshuazack 5 ай бұрын
Great tutorial! does this method works the other way? I mean, can I inject for example a csv table to my ink file for localization? Do you have any tutorial for that?
@Jourlik
@Jourlik Жыл бұрын
Hello, thanks for the vid, however can you help me with a problem i'm currently breaking my brain over? Can you use external methods with a return value, and use them to set a variable in Ink? Because no matter how i try, it gives out an error, saying something about a void value. And the documentation is very vague on this topic.
@user-xx5ie7td3b
@user-xx5ie7td3b 10 ай бұрын
pls help StoryException: ERROR: Missing function binding for external: 'ShowHiddenObject' (ink fallbacks disabled) Exception: Trying to call EXTERNAL function 'ShowHiddenObject' which has not been bound (and ink fallbacks disabled).
@gamingbloxa2865
@gamingbloxa2865 Жыл бұрын
Could you please make make a tutorial,about how to make fireflies?
@OmarAlFarajatz
@OmarAlFarajatz 8 ай бұрын
Hi Trever. I notice at 2:32 After you add the calls to the external function, you lose the interactable preview of the story in the right-side of the editor. I'm actually experiencing the same problem. Is this normal/intentional? Is there a workaround?
@ShapedByRainStudios
@ShapedByRainStudios 8 ай бұрын
Hey there! Yeah, I actually hadn't noticed this until after making the video, but there does seem to be a work-around out there to fix it. Check out this GitHub issue where it was mentioned the issue can be fixed by creating a fallback function in the Ink code. I haven't done this myself, so can't confirm, but looks like it should work. - github.com/inkle/inky/issues/357 Hope that helps and best of luck!
@fathermaggus778
@fathermaggus778 5 ай бұрын
For me, the whole inky didn't worked after implementing the calls. So not just in the preview, even in the game. It seems you must implement a fallback function with the same name as the "real" one.
@benjaminparra982
@benjaminparra982 8 ай бұрын
hi, do you know how can I modify the value of a variable belonging to an .ink file using C# code?
@user-cg1tb1wd1v
@user-cg1tb1wd1v 8 ай бұрын
Maybe I missed something very basic in all these INK/dialogue series but how do you change a VAR from C# to reflect something that happens in game that you want INK to update to? This video shows the use of external functions and other videos explain how to change something within the game based on VARs back in your game, but say you wanted to do the reverse at some point and tell INK that the VAR is something else and you want the dialogue to change or update to this.... Maybe I missed something very basic but I don't want to create a brand new conversation for this one small thing, when I want to weave out of one conversation based upon the completion of a quest and just want the dialogue to not repeat itself keeping track of the fact that the quest was completed in another C# variable and then change my global VAR to reflect that before going back and talking to say NPC who gave you the quest????
@ShapedByRainStudios
@ShapedByRainStudios 8 ай бұрын
Hey there! The best approach I've found is to do something really similar to 'GetVariableState()', assuming you followed the previous videos in the series for how that's all set up. Except, of course, it would be a 'SetVariableState()' method. I have a FAQ channel on my Discord (link in video description) outlining how to change an Ink Variable from a C# script. The FAQ post is called "How do I change Ink Variables from a Csharp Script?". I've pasted that post below for convenience. There are certainly other ways to go about it, but I hope this helps and best of luck! --- FAQ Post from Discord: To change one of the global Ink variables from any C# script, you can add the below 'SetVariableState' method to your DialogueManager. // this method will allow of a variable defined in globals.ink to be set using C# code public void SetVariableState(string variableName, Ink.Runtime.Object variableValue) { if (dialogueVariables.variables.ContainsKey(variableName)) { dialogueVariables.variables.Remove(variableName); dialogueVariables.variables.Add(variableName, variableValue); } else { Debug.LogWarning("Tried to update variable that wasn't initialized by globals.ink: " + variableName); } } Then, you'd call it from another script with something similar to the below line to change a variable by name. You'd use StringValue, IntValue, etc.. depending on the type. // convert the variable into a Ink.Runtime.Object value bool pokemonChosen = false; Ink.Runtime.Object obj = new Ink.Runtime.BoolValue(pokemonChosen); // call the DialogueManager to set the variable in the globals dictionary DialogueManager.GetInstance().SetVariableState("pokemon_chosen", obj);
@Yu-Yu-Jia
@Yu-Yu-Jia Жыл бұрын
Hello , I don't know how to use inky in timeline. Can you help me?
@JohnDoe-su1bc
@JohnDoe-su1bc Жыл бұрын
Could someone help me with this please? I'm using the external function from Ink to play voice overs for my lines of dialogue. However, after implementing the external function, I get multiple copies of the same error, even when the game's not playing in the Unity Editor, saying: "Exception: Trying to call EXTERNAL function 'playVoiceLine' which has not been bound (and ink fallbacks disabled)." This error points to one of Ink's own files and I'm not sure how to fix it. Any help would be appreciated and thank you in advance!
@chance255
@chance255 Жыл бұрын
I was getting this error after I added an external function to my ink script (and bound it on the C# side) but still had the ink plugin tab open in unity (that lets you test the ink story in the unity editor rather than the inky editor). The error ended up going away after closing and reopening the ink plugin tab. I’ve mostly kept that plugin tab closed now though because the inky editor is nice on its own.
@JohnDoe-su1bc
@JohnDoe-su1bc Жыл бұрын
@@chance255 Thank you, I was stressing about this, I can't believe the solution was so simple!
@chance255
@chance255 Жыл бұрын
@@JohnDoe-su1bc No problem, glad to be of help!
How to make a Dialogue System with Choices in Unity2D | Unity + Ink tutorial
29:45
Shaped by Rain Studios
Рет қаралды 132 М.
КАРМАНЧИК 2 СЕЗОН 5 СЕРИЯ
27:21
Inter Production
Рет қаралды 603 М.
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 2 МЛН
Шокирующая Речь Выпускника 😳📽️@CarrolltonTexas
00:43
Глеб Рандалайнен
Рет қаралды 11 МЛН
Trivia Question System in Unity Tutorial
29:28
Jayometric
Рет қаралды 6 М.
Unity in 100 Seconds
2:45
Fireship
Рет қаралды 1,1 МЛН
Learn Ink (video game dialogue language) in 15 minutes | Ink tutorial
14:47
Shaped by Rain Studios
Рет қаралды 55 М.
Simple Question Dialog in Unity! (Yes-No Ok-Cancel Unity Tutorial)
15:37
Java 21 Is Good?! | Prime Reacts
27:08
ThePrimeTime
Рет қаралды 211 М.
#goodthing #respect
1:01
wen ling
Рет қаралды 19 МЛН
Please Love Your Self (P10)
0:21
Discovery Boy
Рет қаралды 2,4 МЛН
Самая высокая малышка в мире 😳
0:39
УГОЛ СМЕХА
Рет қаралды 7 МЛН
Forging a cool BBQ Fork
1:00
Rust Legion
Рет қаралды 31 МЛН
Please Love Your Self (P10)
0:21
Discovery Boy
Рет қаралды 2,4 МЛН