- Home /
GUI Button to open an external document? HELP!!!!
I am trying to make a button in-game which would open my Readme Text document located in the data folder. How do I go about doing this?
My goal is to create a OnGUI function with a GUI button. On clicking the button I want an external text document to open. I have done this with internet URLS which work fine.
Help please? =)
P.S. : It will be VERY helpful if you could post a finished code that I can use =)
for asking for code. You need to learn to program if you're serious about your game. I also think it's rude.
Excuse me? Jamora if you can't help, don't bother commenting, ITS NOT RUDE TO AS$$anonymous$$ FOR CODE SA$$anonymous$$PLES!
$$anonymous$$any people recieve/ask for code samples in the unity answers. Please stop posting unnecessary and rude comments on my post.
Asking for a code snippet to demonstrate a solution is ok, whereas asking for a complete, working, finished script is not.
I was asking for a code snippet, just because I said finished code it doesnt mean that I asked for an entire script, I was just asking for the portion about the GUI Button. Please read carefully.
Answer by BawsAnimations · Aug 03, 2013 at 08:56 AM
Ok guys here's how I fixed this problem :
if(GUILayout.Button ("ReadMe"))
{
Application.OpenURL("Game_Data\\ReadMe.txt");
}
I used the Path, but instead of the entire path I started it from only the data folder so that anyone that downloads my game will be able to open the Text Doc.
Cheers =)
It does, after building, just have to place the txt doc in the data folder
Answer by roojerry · Aug 01, 2013 at 06:02 PM
Check out Process.Start() examples. There is an example for opening text files
Thanks but how would I go about making this in Javascript? Please reply =)
Answer by fafase · Aug 03, 2013 at 08:09 AM
Sorry but that's completely different. Im not looking to open a URL like a website or anything. Im trying to open a text document which is on my computer. So for example I have a readme.txt document. On clicking a GUI button ingame, I want it to open the readme.txt document. It is VERY SI$$anonymous$$ILAR to Application.OpenURL, but I need something that opens files.
Actually, I realized we are using :
Process.Start(Path.Combine(Application.dataPath,nom_fichier));
but url works as well, but I think we had issue with the build. So use the other.
Ok I think I fixed the problem, I changed the URL so that it only opens a document in the data folder of the game.(where i placed the txt)
Your answer
Follow this Question
Related Questions
Player model doesn't stay on ground 1 Answer
Why when I hit play the game is paused? 1 Answer
I open my project and I found that everything's gone?! 2 Answers
the textures look bad 1 Answer