- Home /
Pop up window from external source
Hi all...im new to Unity so please be patient...:) I need to develop an educational game...the problem is i have some bookcases with books in them. I would like the mouse to go over a bookcase and when clicked it moves forward dimming the other bookcases...and then another click on a book will open a pop-up with details of that book, which are already in html format on the same server..is there a way to all'this html inside Unity..and not to redirect or open another window....im using the pro license (30 days..so not much time :)..any ideas..please help
Answer by Tarun · Nov 10, 2010 at 09:46 PM
Just an idea. You may want to open a 2D Texture with background image as that book's HTML content. For that to happen, you will need to store the HTML in image format.
So when you click on the book, an object can become visible in front of the camera and that will have the book content as its texture. Clicking on another book can refresh the texture with the other book's content. There are enough APIs to make the object visible disappear or appear when clicked. To move the book forward when clicked, you can use something like this (put this script on the book - change this the way you want - this is just an example):
var wasClicked : boolean;
var targetWall : GameObject; // this is your object that can appear/disappear on book click
function OnMouseDown() {
wasClicked = true;
Activate();
}
function OnMouseUp() {
wasClicked = false;
Deactivate();
}
function OnMouseEnter() {
if (wasClicked) {
Activate1(); // wasClicked is true - now you want the popup
}
}
function OnMouseExit() {
Deactivate();
}
function Activate() {
renderer.material.color = Color.red; //replace this with lighten up the book's material
// Move the object forward along its z axis 1 unit/second. you can decide whether you want x,y,z movement
transform.Translate(Vector3(0, 0, 1) * Time.deltaTime);
}
function Activate1() {
//Find the object that is disabled - your popup - and make it visible
targetWall.active = true;
// now change its texture
targetWall.renderer.material.mainTexture = Resources.Load("<your HTML page texture>", Texture2D);
}
function Deactivate() {
renderer.material.color = Color.white; //replace this with dim the book's material
// Move the object back along its z axis 1 unit/second.
transform.Translate(Vector3(0, 0, -1) * Time.deltaTime);
}
Thank you so much...being a newbie has its issues...especially in writing code....thanx again
Your answer
Follow this Question
Related Questions
create info window 1 Answer
Facebook external eval ? 1 Answer
How to make Jumpscares 0 Answers
How to load html content 2 Answers
Games and websites 1 Answer