Forum rules - please read before posting.

Replacement for GameObject.FindWithTag (Tags.gameEngine).GetComponent <Dialog> ?

Hello there,

I'm trying to tweak a dialog box to resize based on text and working from an older code that works given to me by a colleague. I notice they use this code in several places:





Dialog dialog = GameObject.FindWithTag (Tags.gameEngine).GetComponent <Dialog> 
 ()

But in my version of AC I get an error message saying Tags no definition for gameEngine. Is there a new way I should be doing this?

Additionally, has Dialog.GetLine() been replaced by GetLatestSpeech()?

Thank you for any help you can give!

Comments

  • Wow, quite old code there!  Yes indeed, the GameEngine tag was dropped to ease the installation process.  Now, you can reference any script from it's KickStarter static variable:

    Dialog dialog = KickStarter.dialog;

    Basic script-accessing is covered on the front page of the scripting guide.  The entry for GetLatestSpeech() is here, which will return the SpeechLine class of the last speech to be played.

    Any SpeechLine generated by the Speech Manager can also be found by referencing it's ID number:

    SpeechLine speechLine = KickStarter.speechManager.GetLine (2);
  • Thanks Chris, that helps loads! Perhaps a silly question, but what would be the easiest way to get the current line to be spoken?
  • Is GetLatestSpeech not what you're looking for?  What is it you're trying to do with it?

    Another option is to call a custom event whenever a speech line is spoken.  This is a new feature, a tutorial for which is available here.
  • Hey Chris, that worked perfectly! I was having some issues unrelated to GetLatestSpeech, that was actually exactly what I was looking for. Thank you so much for the advice! I'm making a rescaling text box to fit behind the text and it looks like it's work great, for the most part anyway!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.