[RESOLVIDO] Alguém poderia me ajudar a diminuir esse script?
2 participantes
SchultzGames :: UNITY 3D :: Resolvidos
Página 1 de 1
[RESOLVIDO] Alguém poderia me ajudar a diminuir esse script?
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TrocarArmas : MonoBehaviour {
public GameObject arma1,arma2,arma3,arma4,arma5;
public RawImage image1,image2,image3,image4,image5;
public Particle particula1,particula2,particula3,particula4,particula5;
public GameObject pt1,pt2,pt3,pt4,pt5 ;
void Start () {
arma1.gameObject.SetActive(false);
arma2.gameObject.SetActive(false);
arma3.gameObject.SetActive(false);
arma4.gameObject.SetActive(false);
arma5.gameObject.SetActive(false);
image1.gameObject.SetActive (false);
image2.gameObject.SetActive (false);
image3.gameObject.SetActive (false);
image4.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
}
void Update () {
if (Input.GetKeyDown("1")){
arma1.gameObject.SetActive(true);
image1.gameObject.SetActive (true);
pt1.gameObject.SetActive (true);
arma2.gameObject.SetActive(false);
image2.gameObject.SetActive (false);
pt2.gameObject.SetActive (false);
arma3.gameObject.SetActive(false);
image3.gameObject.SetActive (false);
pt3.gameObject.SetActive (false);
arma4.gameObject.SetActive(false);
image4.gameObject.SetActive (false);
pt4.gameObject.SetActive (false);
arma5.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
pt5.gameObject.SetActive (false);
}
if (Input.GetKeyDown("2")){
arma2.gameObject.SetActive(true);
image2.gameObject.SetActive (true);
pt2.gameObject.SetActive (true);
arma1.gameObject.SetActive(false);
image1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
arma3.gameObject.SetActive(false);
image3.gameObject.SetActive (false);
pt3.gameObject.SetActive (false);
arma4.gameObject.SetActive(false);
image4.gameObject.SetActive (false);
pt4.gameObject.SetActive (false);
arma5.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
pt5.gameObject.SetActive (false);
}
if (Input.GetKeyDown("3")){
arma3.gameObject.SetActive(true);
image3.gameObject.SetActive (true);
pt3.gameObject.SetActive (true);
arma2.gameObject.SetActive(false);
image2.gameObject.SetActive (false);
pt2.gameObject.SetActive (false);
arma4.gameObject.SetActive(false);
image4.gameObject.SetActive (false);
pt4.gameObject.SetActive (false);
arma1.gameObject.SetActive(false);
image1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
arma5.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
pt5.gameObject.SetActive (false);
}
if (Input.GetKeyDown("4")){
arma4.gameObject.SetActive(true);
image4.gameObject.SetActive (true);
pt4.gameObject.SetActive (true);
arma3.gameObject.SetActive(false);
image3.gameObject.SetActive (false);
pt3.gameObject.SetActive (false);
arma1.gameObject.SetActive(false);
image1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
arma2.gameObject.SetActive(false);
image2.gameObject.SetActive (false);
pt2.gameObject.SetActive (false);
arma5.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
pt5.gameObject.SetActive (false);
}
if (Input.GetKeyDown("5")){
arma5.gameObject.SetActive (true);
image5.gameObject.SetActive (true);
pt5.gameObject.SetActive (true);
arma4.gameObject.SetActive(false);
image4.gameObject.SetActive (false);
pt4.gameObject.SetActive (false);
arma3.gameObject.SetActive(false);
image3.gameObject.SetActive (false);
pt3.gameObject.SetActive (false);
arma1.gameObject.SetActive(false);
image1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
arma2.gameObject.SetActive(false);
image2.gameObject.SetActive (false);
pt2.gameObject.SetActive (false);;
}
}
}
boa madrugada se tiver alguem acordado rs... int eu queria diminuir esse script,como vcs podem ver nao e necessario esse tanto de linha,queria fazer um sistema que no inspector eu escolhece o tanto de arma que eu quero ter o tanto de particula etc... tipo aquele sistema de tiro raycast do marcos...se alguem puder me ajudar serei grato
Última edição por dstaroski em Qui Ago 17, 2017 9:18 am, editado 1 vez(es) (Motivo da edição : Resolvido)
Unidade3d5- Avançado
- PONTOS : 3029
REPUTAÇÃO : 28
Respeito as regras :
Re: [RESOLVIDO] Alguém poderia me ajudar a diminuir esse script?
- Código:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TrocarArmas : MonoBehaviour {
public GameObject arma1,arma2,arma3,arma4,arma5;
public RawImage image1,image2,image3,image4,image5;
public Particle particula1,particula2,particula3,particula4,particula5;
public GameObject pt1,pt2,pt3,pt4,pt5 ;
void Start () {
DesativarTudo ();
}
void DesativarTudo(){
arma1.gameObject.SetActive(false);
arma2.gameObject.SetActive(false);
arma3.gameObject.SetActive(false);
arma4.gameObject.SetActive(false);
arma5.gameObject.SetActive(false);
//
image1.gameObject.SetActive (false);
image2.gameObject.SetActive (false);
image3.gameObject.SetActive (false);
image4.gameObject.SetActive (false);
image5.gameObject.SetActive (false);
//
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
pt1.gameObject.SetActive (false);
}
void Update () {
if (Input.GetKeyDown("1")){
DesativarTudo ();
arma1.gameObject.SetActive(true);
image1.gameObject.SetActive (true);
pt1.gameObject.SetActive (true);
}
if (Input.GetKeyDown("2")){
DesativarTudo ();
arma2.gameObject.SetActive(true);
image2.gameObject.SetActive (true);
pt2.gameObject.SetActive (true);
}
if (Input.GetKeyDown("3")){
DesativarTudo ();
arma3.gameObject.SetActive(true);
image3.gameObject.SetActive (true);
pt3.gameObject.SetActive (true);
}
if (Input.GetKeyDown("4")){
DesativarTudo ();
arma4.gameObject.SetActive(true);
image4.gameObject.SetActive (true);
pt4.gameObject.SetActive (true);
}
if (Input.GetKeyDown("5")){
DesativarTudo ();
arma5.gameObject.SetActive (true);
image5.gameObject.SetActive (true);
pt5.gameObject.SetActive (true);
}
}
}
Re: [RESOLVIDO] Alguém poderia me ajudar a diminuir esse script?
Obrigado marcos vlw mesmo
Unidade3d5- Avançado
- PONTOS : 3029
REPUTAÇÃO : 28
Respeito as regras :
Tópicos semelhantes
» Alguém poderia me ajudar a entender esse script
» [RESOLVIDO] Alguem pode me ajudar? tenho esse erro aqui em um script
» Alguém poderia mudar esse script pra botão
» Porque esse script não esta funcionando alguém poderia me explicar ??
» alguem pode me ajudar com esse script
» [RESOLVIDO] Alguem pode me ajudar? tenho esse erro aqui em um script
» Alguém poderia mudar esse script pra botão
» Porque esse script não esta funcionando alguém poderia me explicar ??
» alguem pode me ajudar com esse script
SchultzGames :: UNITY 3D :: Resolvidos
Página 1 de 1
Permissões neste sub-fórum
Não podes responder a tópicos