- Home /
Main Menu Instructions?
Hello, I have made a main menu for my game and it only has two options, start game or quit game. I would like to have a "How to Play" option, but for that would I need to make a scene with just one huge 3d text? Is there a way it can open a word document or something? Thanks a lot!
Answer by aldonaletto · Aug 05, 2012 at 05:41 PM
You could have several different menus in the same scene using the GUI system - like this:
enum MenuID {MainMenu, HowToPlay} // menu types
var curMenu: MenuID = MenuID.MainMenu; // start at the main menu var playInstructions: String = "AD moves left/right\nWS moves forth/back";
function OnGUI(){ switch (curMenu){ case MenuID.MainMenu: // if main menu... // draw the main menu buttons: if (GUI.Button(Rect(...), "Start Game")){ // start the game } break; if (GUI.Button(Rect(...), "Quit")){ // quit the game } if (GUI.Button(Rect(...), "How To Play")){ curMenu = MenuID.HowToPlay; // select the "How To Play" menu } break; case MenuID.HowToPlay: // if how to play selected... // display the instructions: GUI.Label(Rect(...), playInstructions)); if (GUI.Button(Rect(...), "Main Menu")){ curMenu = MenuID.MainMenu; } break; } } You can use textures instead of strings with GUI.Label, producing much better results than plain text.
Thanks a lot everyone! I'll try them both out and see which one I like best!
Answer by RodrigoSeVeN · Aug 05, 2012 at 07:24 PM
In case you choose to open an external file, you may try the code found in this question here: http://answers.unity3d.com/questions/16675/running-an-external-exe-file-from-unity.html
Still, to simplify things, consider that you put your text file inside the Assets folder and test this code to see if it meets your objective. This is in javascript by the way.
import System.Diagnostics;
function Start(){
var stringPath = Application.dataPath+"/HowToPlayDoc.txt";
var myProcess = new Process();
myProcess.StartInfo.FileName = "Notepad.exe";
myProcess.StartInfo.Arguments = stringPath;
myProcess.Start();
}
As you can see, it is calling the Notepad.exe and a .txt file. This should consider the platform the build was made for. There are more advanced methods to load data like this, but this is very simple, so check your needs and/or dig further into this solution if you find it necessary.
Your answer
Follow this Question
Related Questions
Horror Game AI script recommendation? 1 Answer
FPS Game Level Loader 0 Answers
FPS KIT VERSION 2.0 0 Answers
A node in a childnode? 1 Answer
How to make an ingame weapon/ammo shop 0 Answers