Alrighty, I’ve actually got a toughie X3 What I have is a simple script that I can slap on anything I want to talk to (of course I’m missing one element, but I’m working on the mechanic first). Slap it onto a sign, give it three elements of text, then it will display each one until I’ve went through all of the elements.
var guiSkin: GUISkin;
//var nativeVerticalResolution = 1200.0;
private var stayInTrigger = 0.0;
private var talkMode = false;
static var talking = false;
private var dialogcontinue = false;
private var endTalking = 0.0;
private var talkDelay = 0.0;
private var WindowWidth = Screen.width * .90;
private var WindowHeight = Screen.height * .20;
var WhatImSayingElements : String[];
//private var WhatImSaying = "Lookie lookie! Press Jump to end this dialog!";
function FixedUpdate()
{
//My way of getting GUI to react to a on a button click, not a mouse click
//Make sure I'm talking/reading
if (talkMode == true)
{
//When I hit the jump button...
if(Input.GetButton ("Jump"))
{
//Give some time to delay, otherwise I'll zoom through text
if (Time.time > talkDelay + .5)
{
//If I have more dialog use my now unfinished "ContinueDialog()" function
if (dialogcontinue == true)
ContinueDialog();
else
//Nothing else? Finish talking/reading
EndDialog();
}
}
}
}
function OnTriggerEnter()
{
stayInTrigger = Time.time;
}
function OnTriggerStay ()
{
//Make sure I'm in the trigger long enough to turn off my Jumping ability.
if (Time.time > stayInTrigger + 1.00)
{
talking = true;
//This would also put a little "Talk (A)" picture above the object that you're going to talk to, but I don't have that finished.
//I'm going to do two functions for that, ShowPopupPicture() and ClosePopupPicture(), to show and erase the picture.
}
//It seems like a lot, but it basically says:
//If I'm not already in talkmode, and I'm allowed to talk. If I hit the jump button (accept button) Show the dialog.
//The endTalking is a delay timer to prevent the accept button from continually executing.
if (Input.GetButton ("Jump") talkMode == false talking == true Time.time > endTalking + .5)
{
//talkMode turns on my Talking GUI
talkMode = true;
//Turns off my controls so I don't run away while I'm talking/reading.
ThirdPSWalker.isControllable = false;
//talkDelay will also be used to prevent a player from zooming through the text.
talkDelay = Time.time;
}
}
function OnTriggerExit()
{
//Give the Jump button control back to the controller so I can jump again.
talking = false;
}
function OnGUI()
//talkMode turns my GUI on and off.
{if(talkMode == true)
{
GUI.skin = guiSkin;
GUI.Label (Rect ((Screen.width/2 - WindowWidth/2),(Screen.height - WindowHeight),WindowWidth,WindowHeight), WhatImSayingElements + "", "box");
//I will also have an accept button picture at the bottom right of the box in order to make it feel like a Nintendo game X3
}
}
//Unfinished, it's supposed to bring up the next element in the array.
function ContinueDialog()
{
}
//Close the dialog and give control back to the player. Also start the delay timer to prevent the player from opening the dialog again.
function EndDialog()
{
ThirdPSWalker.isControllable = true;
talkMode = false;
endTalking = Time.time;
}
I can get my Dialog box to display one variable of text (I had “private var WhatImSaying” instead), but I want it to display 1 element at a time until I’m done with elements.
What I want it to do, is to detect the number of elements I have in my Array. If the I’m at the max # of elements in that array, set off the “EndDialog” function, but if I’m not done, with my array, use my “ContinueDialog” which will then display the next element in the array… Ah, I hope I’m not confusing anyone reading this ^^;;