- Home /
Camera problems
i got a
gamecamera pausecamera
when level loads game camera its active when i press optionguiTexture it disables game camera and enables pause camera.
problem is on unity it works great cuz i used a on mouse down, but i also have the ray hit for mobile, and when i click anywhere on the screen on game camera it switches pause camera and then i cant click anything on pause camera, altho it works great on unity here my come.
MY GUITEXTURE SCRIPT
#pragma strict
private var hit : RaycastHit;
//CAMERAS//
var gamecamera : Camera;
var pausecamera : Camera;
//GUITEXTURES//
public var optionsTexture : GUITexture;
function Start () {
gamecamera.camera.active = true;
pausecamera.camera.active = false;
}
function Update()
{ions
var touches = Input.touches;
//detect which mobile buttons are pressed
for (var touch in touches)
{
if(touch.phase != TouchPhase.Canceled && touch.phase != TouchPhase.Ended)
{
if(optionsTexture.HitTest (touch.position)) //if touch position is inside options texture
gamecamera.camera.active = false;
pausecamera.camera.active = true;
}
}
if(Input.touchCount == 0)
{
}
else
{
//----------------------------------
}
}
//function OnMouseDown () {
// gamecamera.camera.active = false;
// pausecamera.camera.active = true;
// }
MY PAUSE CAMERA SCRIPT
#pragma strict
private var ray : Ray;
private var hit : RaycastHit;
function Start () {
}
function Update ()
{
if(Input.GetMouseButtonDown(0))
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if(Physics.Raycast(ray, hit))
audio.Play();
{
//////////INTRO/////
if(hit.transform.name == "pauserestartbutton")
{
Application.LoadLevel (Application.loadedLevel);
}
if(hit.transform.name == "pausemainmenubutton")
{
Application.LoadLevel("main");
}
}
}
}
i cant figure out what im doing wrong, i been at itfor a couples days, someone enlight me please :)
PS : all references are are set on inspector
Answer by RChrispy · Jan 13, 2014 at 03:29 PM
Em I dont know if its the problem but when you touch the button your if statement only includes one camera? Shoudnt it be something like this:
if(touch.phase != TouchPhase.Canceled && touch.phase != TouchPhase.Ended) { if(optionsTexture.HitTest (touch.position)) //if touch position is inside options texture { gamecamera.camera.active = false; pausecamera.camera.active = true; } }
I would recomend to write a ToggleCameraViews() function.
the brackets dont matter the code its gonna get executed either way
Answer by TSSTUDIOS · Jan 13, 2014 at 03:47 PM
i solved it
what i did was i set a boolean to false
var options boolean : false;
function start
options false
function update
on touch or on mouse down on guitexture
options = true;
then
(options) { gamecamera.camera.active = false; pausecamera.camera.active = true; }
sorry for the sloopy script hope ti helps
Your answer
Follow this Question
Related Questions
How do I make a border decoration effect? 1 Answer
GuiTexture and Split Screen 1 Answer
One camera sees a GUI texture but the other camera does not. I need them both to. 1 Answer
Problem With healthbar 1 Answer
Multiplying GUIs 0 Answers