TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Charalampakis kostas
NA
14
516
I have a broblem with boolean (Unity)
Jul 17 2018 12:01 PM
I have 3 canvas and 3 buttons that make each panel visible
Button 1 ---> Canvas 1, Button 2 ---> Canvas 2, Button 3 ---> Canvas 3
I want only one canvas visible every time, so i want every click on the button 1 to: activate canvas 1 and close canvas 2 and 3 (same for buttons 2,3)
this is my code (i dont know why but it doesnt work can you help me?):
(Only one bool works every time)
public CanvasGroup CgUp;
public CanvasGroup CgGe;
public CanvasGroup CgMa;
private bool isVisibleUp;
private bool isVisibleGe;
private bool isVisibleMa;
// Canvas1 Visibility
public void ToggleVisibilityUp ()
{
if (isVisibleUp == false)
{
CgUp.alpha = 1;
CgGe.alpha = 0;
CgMa.alpha. = 0;
CgUp.interactable = true;
CgGe.interactable = false;
CgMa.interactable = false;
isVisibleUp = true;
isVisibleGe = false;
isVisibleMa = false;
}
else
{
CgUp.alpha = 0;
CgUp.interactable = false;
isVisibleUp = false;
}
}
// Canvas2 Visibility
public void ToggleVisibilityGe ()
{
if (isVisibleGe == false)
{
CgUp.alpha = 0;
CgGe.alpha = 1;
CgMa.alpha. = 0;
CgUp.interactable = false;
CgGe.interactable = true;
CgMa.interactable = false;
isVisibleUp = false;
isVisibleGe = true;
isVisibleMa = false;
}
else
{
CgGe.alpha = 0;
CgGe.interactable = false;
isVisibleGe = false;
}
}
// Canvas3 Visibility
public void ToggleVisibilityMa ()
{
if (isVisibleMa == false)
{
CgUp.alpha = 0;
CgGe.alpha = 0;
CgMa.alpha. = 1;
CgUp.interactable = false;
CgGe.interactable = false;
CgMa.interactable = true;
isVisibleUp = false;
isVisibleGe = false;
isVisibleMa = true;
}
else
{
CgMa.alpha. = 0;
CgMa.interactable = false;
isVisibleMa = false;
}
}
}
Reply
Answers (
3
)
Draw circles based on co ordinates of textbox in corelDraw
my topic 2D Array and how to book ticket in flight