Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles

[Solved] Trouble with integrating STM into a dialogue manager

A topic by Cro created May 03, 2018 Views: 81 Replies: 5
Viewing posts 1 to 3
(1 edit)

Hi Kai,

I've spent the last four days trying to get a dialogue system hooked up to STM, first trying with Yarn and YarnSpinner, then with this system here, but I just can't get it to run. Using Yarn I replaced everywhere it expected to use Unity's UI text with STM's text, and I eventually got every error it threw at me corrected but then it just wouldn't actually display any text during runtime and I couldn't figure out what was missing.

With the second system I feel like I'm close to getting it but as soon as I integrate STM its giving me a "CS0120: An object reference is required to access non-static member" that I just can't crack or understand what any solutions I've googled mean.

I've gone back and forth right through the provided documentation without any luck. Tbh I'm really struggling to understand the difference between the Rebuild, Complete and Undrawn functions?

Is it at all possible to use STM with a dialogue system? Could you tell me what I'm missing?


Thank you!

Developer

Hey!

I'm using STM with my own dialogue system right now and messed around with yarnspinner for a bit before that, so it should be possible. That error you mentioned pops up when you try to call a non-static member thru a class directly... so basically it means this:


public TempClass myTempClass; //an instance of TempClass
class TempClass{
    public static void StaticMember(){
        //this can be called directly thru the class, with TempClass.StaticMember()
    }
    public void NonStaticMember(){
        //this has to be called thru an instance, like myTempClass.NonStaticMember(), in this situation
    }
}


Within STM, Rebuild() is what makes the mesh get info from whatever string was typed into it, and redraws the mesh. So the Rebuild event is invoked when the mesh is told to rebuild. The OnCompleteEvent is invoked when the mesh finishes reading, and the OnUndrawn event is invoked when the mesh finishes Unreading (You have to call Unread() to make the mesh unread)


Hopefully this info helps for now? I have an incredibly basic dialogue box within the sample scene if you want to give that a look, but I'm not sure how much that can help with hooking it up to YarnSpinner.

Thanks Kai, I've definitely been studying your example scene since I purchased STM and have been trying to get it set up the same way.

At the moment I can get a basic single string to pass from one script into the STMDialogueSample provided as a test, but when trying to pass through anything from the saved dialogue that would shows up in Unity UI normally, instead it just empties the dialogue box and sits blank if I do it by STM.

Also the typed in default text in the inspector is displaying to the camera as black and pixellated, no matter what colour is picked for it or if the default rainbow tag is on it. The SuperTextMesh component has the same material and shader, and is all set up identically to the provided example but I can't get it to have any effect at all. Any idea what could be causing this?

Developer

Oh, since it's appearing black and pixelated, you're probably using a normal shader with UI text? Try creating a new material for your text mesh, and assigning one of STM's UI shaders to it!


STM and Unity UI text should use the same type of code to work, could you show me the code you're using? I'm not 100% what could be causing the dialogue box to empty and sit blank when you assign text to it vs Unity UI

Thanks heaps Kai, I appreciate it, the rendering's working fine now!

I had started over again with the dialogue attempt but I've got an assignment to finish up atm, do you mind if I catch back up with you again in a few days and send you the scripts if I'm still stuck by then?

Developer

Take all the time you need, I won't be able to do any proper debugging for about 2 weeks or so anyway!