In-Game Browser, help needed!
Hi there, I've been working on a game for awhile now, and for some reason this seems to stump me the most. So, what I'm planning to do is try and make a working browser on the game. Another thing is to adding, I'm working on Unity 5, and already have a browser set up. Here's an image.
So, another thing to know to adding, I'm trying to add where if the player just types in a random link, it'll just give them an error like "This page cannot be accessed at this time. Please try again later." Which I can do that, but I don't know how to exactly how to script using the Input Field. So if they typed a wrong URL, (Ex: www.blahblah.saq) the script will then open a UI Image. Like, seriously. If anyone can help with this, it would be life saving. Thank you! :D
Answer by Landern · Aug 10, 2016 at 08:36 PM
Not a lot to go off of here, you can use a switch/case (as opposed to if/else stack) to take the text field on the inputfield(you will need a reference to the input field).
switch (inputField.text.ToLower())
{
case "www.blahblah.saq":
// do something when they hit up www.blahblah.saq
break;
case "www.microsoft.com":
// do something else based off the www.microsoft.com URL
break;
default:
// load up the browser image for any "WRONG" URL's
}
Dude, you are an absolute life saver! :D Thanks again, man!
Actually, wait. Sorry for this, aheh.
But apparently rewriting the script and having a few issues going on. Now, it keeps giving me an unexpected error, that can't be fixed for anything I do. I'm an alright scripter, but the script gives me a couple different errors if I try and fix it.
There are no characters expected in this, and I have no idea why this is stumping me, thanks.
I fixed the script, and has no issues whatsoever. But please, could you go step by step on how to actually set up the script? Because I have it set along the Input Field, and it has no extra options whatsoever.
Thanks!~