What im trying to do is i have a list of diffrent buttons that open diffrent things,I want it so i click one of the button it shows what it need too but if i click on another button it closes the first thing and open the other.
I don’t care if you use c# or JS i can translate to what i need ![]()
EDIT Ok because it was recomended that i made some artwork here are some, for the project it is in danish, since this was made for me and it is only going to be a student project
[10389-udklip+til+thor+(katalog).png|10389]
so when you click on “Solcelle1” it opens the window to the right and i want it so, that if you click any of the other buttons like “Solcelle2” it replaces Solcelle1 window in its place, atm they just stack on each other
EDIT2 Ok ill just post my code now, but warning it is not optimised and is relly just horribel to look at ATM i feel, here we go:
`
using UnityEngine;
using System.Collections;
public class GUI_Script : MonoBehaviour
{
float MyBoxLeft = -600f;
public Texture icon;
public Texture icon2;
public Texture Sol_celle1;
public Texture Sol_celle2;
public Texture Sol_celle3;
public Texture Sol_celle4;
public Texture Vind_mølle1;
public Texture Vind_mølle2;
public Texture Vind_mølle3;
public Texture Vind_mølle4;
public GUIStyle SlideButton;
public GUIStyle KatologLabel;
public GUIStyle UdendørsLabels;
public GUIStyle købsmenuTekst;
public GUIStyle KøbsmenuBilleder;
public GUIStyle brødtekst;
private bool udendørs = false;
private bool solcelle1 = false;
private bool solcelle2 = false;
private bool solcelle3 = false;
private bool solcelle4 = false;
private bool vindmølle1 = false;
private bool vindmølle2 = false;
private bool vindmølle3 = false;
private bool vindmølle4 = false;
void OnGUI()
{
Rect tBoxRect = new Rect(MyBoxLeft,0.0f,620, 740);
Rect tButtonRect = new Rect(MyBoxLeft+600,320.0f,50,100);
Rect tBoxArt = new Rect(MyBoxLeft+50,170.0f,200,550);
//KatalogBox
GUI.Box(tBoxRect, icon);
//LABEls
//Katalog
GUI.Label(new Rect(MyBoxLeft+200, 25, 300, 100), "Katalog",KatologLabel);
//BUTTONS!
//Slide ud Button
if (GUI.Button(new Rect(MyBoxLeft+620,350.0f,30,70), "",SlideButton))
{ StartCoroutine(AnimateBox()); }
//Udendørs button
if (GUI.Button(new Rect(MyBoxLeft + 80, 100, 150, 70), "Udendørs"))
{
udendørs = udendørs ? false : true;
}
if (udendørs)
{
//udendørsbox
GUI.Box(tBoxArt, icon2);
//Solceller
GUI.Label(new Rect(MyBoxLeft + 90, 170, 250, 70), "Solceller", UdendørsLabels);
//Vindmøller
GUI.Label(new Rect(MyBoxLeft + 80, 400, 250, 70), "Vindmøller", UdendørsLabels);
//SolCelleButtons
//SolCelle1 button
if (GUI.Button(new Rect(MyBoxLeft + 80, 230, 150, 30), "SolCelle1"))
{
solcelle1 = solcelle1 ? false : true;
}
//SolCelle2
if (GUI.Button(new Rect(MyBoxLeft + 80, 270, 150, 30), "SolCelle2"))
{
solcelle2 = solcelle2 ? false : true;
}
//SolCelle3
if (GUI.Button(new Rect(MyBoxLeft + 80, 310, 150, 30), "SolCelle3"))
{
solcelle3 = solcelle3 ? false : true;
}
//SolCelle4
if (GUI.Button(new Rect(MyBoxLeft + 80, 350, 150, 30), "SolCelle4"))
{
solcelle4 = solcelle4 ? false : true;
}
//VindmølleButtons
//Vindmølle1 button
if (GUI.Button(new Rect(MyBoxLeft + 80, 470, 150, 30), "Vindmølle1"))
{
vindmølle1 = vindmølle1 ? false : true;
}
//SolCelle2
if (GUI.Button(new Rect(MyBoxLeft + 80, 510, 150, 30), "Vindmølle2"))
{
vindmølle2 = vindmølle2 ? false : true;
}
//SolCelle3
if (GUI.Button(new Rect(MyBoxLeft + 80, 550, 150, 30), "Vindmølle3"))
{
vindmølle3 = vindmølle3 ? false : true;
}
//SolCelle4
if (GUI.Button(new Rect(MyBoxLeft + 80, 590, 150, 30), "Vindmølle4"))
{
vindmølle4 = vindmølle4 ? false : true;
}
}
//Buttons for forskellige udendørs ting WARNING LOT OF CODE!
//Solcelle1
if (solcelle1)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Solcelle1", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Solcelle2
if (solcelle2)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Solcelle2", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Solcelle3
if (solcelle3)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Solcelle3", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Solcelle4
if (solcelle4)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Solcelle4", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Vindmølle1
if (vindmølle1)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Vindmølle1", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Vindmølle2
if (vindmølle2)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Vindmølle2", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Vindmølle3
if (vindmølle3)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Vindmølle3", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
//Vindmølle4
if (vindmølle4)
{
//BUTTON
if (GUI.Button(new Rect(MyBoxLeft + 320, 600, 150, 70), "Bestil"))
{
Debug.Log("Clicked the button with an image");
}
//BOXES
GUI.Box(new Rect(MyBoxLeft + 250, 170, 300, 550), "");
GUI.Box(new Rect(MyBoxLeft + 300, 250, 200, 150), Sol_celle1, KøbsmenuBilleder);
//LABELS
GUI.Label(new Rect(MyBoxLeft + 340, 200, 300, 100), "Vindmølle4", købsmenuTekst);
GUI.Box(new Rect(MyBoxLeft + 250, 400, 300, 100), "blahblahblah jeg er en masse tekst
blah blah blah
blah blah blah blahb
lahb alhbasdohd
JEG KAN GODT LIDE KAGE!!!", brødtekst);
}
}
void Update()
{
}
//Det der laver Slide Animationen på GUI
IEnumerator AnimateBox()
{
if (MyBoxLeft == -600f)
{
while (MyBoxLeft < 20.0f)
{
MyBoxLeft += 5.0f;
yield return 0;
}
}
else if (MyBoxLeft == 20.0f)
{
while (MyBoxLeft > -600.0f)
{
MyBoxLeft -= 5.0f;
yield return 0;
}
}
}
}`
EDIT3 Ok, I got it now, and I feel like a giant idiot for failing at this… so easy well that is what happens when you work on coding for 6 hours in a row
agian thanks for the help and if anyone want the souce code just post a comment but really just think for two seconds and it make sense.