SchultzGames
Para tirar dúvidas, crie um tópico especifico na área "Dúvidas em Geral" e aguarde ser respondido. Evite comentar em tópicos não relacionados a sua dúvida :D
TÓPICOS RECENTES:
Tópico:
Postado em:
Postado por:
Collider (mesh?)
ShapeKeys do Blender para a Unity altera áreas próximas
Player travando na colisão com o chão Unity 2D
COMO EVITAR QUE UM OBJETO (PLAYER,ITEM ETC...) ATRAVESSE UMA PAREDE.
Ajuda em Script de Verificação de Ação e Reação
unity Failed to load PlayerSettings (internal index #0). Most likely data f
modelar avatar e skins para um jogo web
PRECISO FAZER QUE MEU GAME FIQUE ONLINE
Materiais do Blander não aparecem no MeshRendere do Objeto na Unity
Repetiçoes de Textura no Terreno
SERVER IS DOWN - UNITY+MSQL
Procuro programadores - Novo jogo
Problema com o MS VEHICLES
Preciso de ajuda com a Unity
Problema com vídeo em 360° na Unity
Problemas no MS Vehicles
unity- eventos na Animação com Armature/Bones vinda do blender não funciona
ajuda exibir resultados simulados em uma liga Game Unity
Unity - ParticleSystem não é redirecionado no rawimage no canvas
Como resolver o problema de "face orientation" no Blender.
[DÚVIDA] Tive um problema com meu Canvas
erro na Directional Light
Problemas com o Directional Light da Unity 3D
210 Linhas de código para inimigo é muito grande?
Novo jogo da franquia Sphere game em desenvolvimento
malha da roda não girando com wheel collider unity
Problemas com ambiguidade
Touch mobile
INVALID TOKEN
Como acessar o "HD Render Pipeline" do HDRP por script?
CHAT GPT PRA JOGO DE TIRO? comentem
Tutorial script inimigo segue e foge do player
Ainda vale a pena lançar Asset na Asset Store?
Ajuda com tabela de historico de pontuaçao.
[TUTORIAL] Entrar no carro estilo GTA
Como derrapar um Whell Collider
Como altertar o valor do "Asymptote Value" do Whell Collider via Script
Preciso de ajuda para substituir valor de variavel em outro script
Ajuda com Top Down Shooter utilizando Photon
Duvida com Netcode
[RESOLVIDO] Unity - Movendo a Câmera na Horizontal/Vertical com Touch
Alguém me ajuda com os anúncios pfv
Segundo Trailer do jogo Dark Age, Feliz Natal a todos!
Unity - ScrollRect, Viewport, Content - O Conteúdo ñ inicia no topo
Coleta de itens
Unity - Cadastro do email do jogador
[GRATIS] PACK DE MODELOS 3D PARA JOGO DE TERROR
Onde Conseguir músicas para meu Jogo?
error CS0246 em Script
Alguem teve ja esse problema?
[Projeto em Andamento] Draug, um jogo de hordas
DISPONIVEL PARA FAZER MODELOS 3D
Unity-Loja.Como os Jogadores terão acesso aos ítens comprados na PlayStore?
Bugando depois do Build.
Primeiro Trailer do jogo Dark Age
Problema com sombra
Mesh e Material do objeto trocando para uma instancia no inicio do jogo
[RESOLVIDO] Unity - RawImages_Layer_Camera
INVESTIMENTO EM JOGOS E BANCO DE TALENTO
Teaser do meu novo projeto pessoal, Dark Age
Preciso de ajuda com mudança para mobile androide.
[RESOLVIDO] Posição final do objeto em jogo 2D
Input.GetAxis() obedercer a orientação de um objeto.
Interação com elementos UI
Meu primeiro jogo na steam
Minimap/Radar/GPS Estilo GTA V
[RESOLVIDO] Erro no console depois que formatei o pc
PACK GRÁTIS de Músicas ELETRÔNICAS para ajudar vocês em seus Jogos Indies!
[TUTORIAL] Entenda como funciona: ENUM, SWITCH, BREAK, CASE no C#
O Labirinto II - Baixe o Jogo
Qual e o codigo de Botões na unity para saber seus estados?
Como carregar itens pequenos dentro do carro sem que atravesse os colliders
[Duvida] Script pegar itens
Travamento ao trocar de cena
Colisão zoada e movimentação
Salvar objetos que foram destruidos entre cenas na unity
Quero começa a desenvolver um jogo de luta porem eu queria aprender a faze
Pegar qual objeto colidiu com o Linecast.
movimentação e camera?
[RESOLVIDO] Unity - SceneManager.LoadScene abre scene com objeto "vazio"
[RESOLVIDO] ajuda sobre skybox
MEU SIMULADOR DE CARRO
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY
[RESOLVIDO] Ausencia da funçao NavMesh na Unity 2022.2.12
[_____IMPORTANTE_____] ALTERAÇÕES NA POLÍTICA DE COBRANÇA DA UNITY - 2
Roll Up Um jogo de aventura e desáfios
Terminologia da Unity em outras engines
Como criar a iluminação do Sol no Sistema Solar?
Conexão de lobby pelo OnConnectedToMaster
Problema na exportção de projeto unity
[RESOLVIDO] Unity - Áudios estão emitindo som só Depois do Botão ser solto
Unity - Banco de Dados Online junto ao Jogo
Player virar para o inimigo(Prefab)
[TUTORIAL] Sistema De Save Game Ao Sair Da Fase
Problema de Sincronização de um objeto de um jogo multiplayer usa q Photon
Unity - Compartilhar meu Jogo
Alguém que manja do Google ADmob?
Unity - Avaliar meu Jogo
[RESOLVIDO] Destruir inimigo com o player.
Ontem à(s) 10:47 pm
Sex Mar 22, 2024 2:41 pm
Sex Mar 22, 2024 11:38 am
Dom Mar 10, 2024 2:30 pm
Sex Mar 01, 2024 1:27 pm
Qui Fev 22, 2024 9:57 pm
Qua Fev 21, 2024 10:39 am
Ter Fev 20, 2024 9:28 am
Ter Fev 20, 2024 12:15 am
Seg Fev 19, 2024 1:06 pm
Seg Fev 12, 2024 1:56 pm
Seg Fev 12, 2024 1:17 pm
Dom Fev 11, 2024 8:55 pm
Dom Fev 11, 2024 11:16 am
Seg Fev 05, 2024 4:18 pm
Dom Fev 04, 2024 9:39 pm
Qua Jan 31, 2024 11:59 pm
Ter Jan 30, 2024 7:37 pm
Ter Jan 23, 2024 6:33 pm
Dom Jan 21, 2024 6:03 pm
Sáb Jan 20, 2024 7:03 pm
Sáb Jan 20, 2024 6:58 pm
Sáb Jan 20, 2024 6:39 pm
Sex Jan 19, 2024 1:29 pm
Sex Jan 19, 2024 8:40 am
Dom Jan 14, 2024 5:30 pm
Qua Jan 10, 2024 10:29 pm
Qua Jan 10, 2024 8:55 pm
Qua Jan 10, 2024 7:14 pm
Ter Jan 09, 2024 3:55 pm
Ter Jan 09, 2024 8:04 am
Sáb Jan 06, 2024 8:02 pm
Sex Jan 05, 2024 7:01 am
Sex Jan 05, 2024 12:12 am
Qui Jan 04, 2024 6:55 pm
Qui Jan 04, 2024 12:52 pm
Qui Jan 04, 2024 4:34 am
Ter Jan 02, 2024 11:48 pm
Dom Dez 31, 2023 7:25 pm
Qua Dez 27, 2023 5:44 pm
Qua Dez 27, 2023 3:08 pm
Sáb Dez 23, 2023 7:27 pm
Sáb Dez 23, 2023 5:06 pm
Qui Dez 21, 2023 8:10 pm
Seg Dez 18, 2023 2:04 pm
Sex Dez 15, 2023 5:11 pm
Qui Dez 14, 2023 9:13 pm
Qui Dez 14, 2023 2:47 pm
Qui Dez 14, 2023 1:48 pm
Qua Dez 13, 2023 8:58 pm
Ter Dez 12, 2023 2:32 pm
Seg Dez 11, 2023 1:53 pm
Qua Dez 06, 2023 8:13 pm
Sáb Dez 02, 2023 8:06 pm
Qui Nov 30, 2023 7:49 am
Seg Nov 27, 2023 1:35 am
Qua Nov 22, 2023 7:37 am
Qui Nov 09, 2023 1:22 pm
Seg Nov 06, 2023 11:59 am
Ter Out 31, 2023 9:53 am
Dom Out 29, 2023 8:05 pm
Dom Out 29, 2023 3:03 am
Sex Out 27, 2023 3:43 pm
Sex Out 27, 2023 3:28 pm
Qua Out 25, 2023 1:20 pm
Seg Out 23, 2023 10:34 am
Dom Out 22, 2023 6:55 pm
Qui Out 19, 2023 11:57 pm
Qui Out 19, 2023 6:39 pm
Ter Out 17, 2023 6:37 pm
Ter Out 17, 2023 6:18 pm
Seg Out 16, 2023 1:59 pm
Sáb Out 14, 2023 12:15 pm
Qua Out 11, 2023 6:07 pm
Seg Out 09, 2023 4:19 pm
Qua Out 04, 2023 12:12 pm
Qua Out 04, 2023 12:11 pm
Ter Out 03, 2023 9:18 pm
Ter Out 03, 2023 9:08 pm
Ter Out 03, 2023 6:05 pm
Ter Set 26, 2023 12:45 pm
Seg Set 25, 2023 9:02 pm
Seg Set 25, 2023 9:47 am
Sáb Set 23, 2023 2:10 pm
Sex Set 22, 2023 9:01 pm
Qui Set 21, 2023 11:04 am
Qua Set 20, 2023 4:40 pm
Qua Set 20, 2023 9:15 am
Dom Set 17, 2023 12:17 pm
Sex Set 15, 2023 7:24 pm
Sex Set 15, 2023 5:41 pm
Sex Set 15, 2023 4:28 pm
Sex Set 15, 2023 10:56 am
Sex Set 15, 2023 10:15 am
Seg Set 11, 2023 11:43 am
Seg Set 11, 2023 11:31 am
Sáb Set 09, 2023 4:53 pm
Sáb Set 09, 2023 1:44 pm
Ter Set 05, 2023 11:12 pm



































































































Problemas após trocar de cenas

2 participantes

Ir para baixo

Resolvido Problemas após trocar de cenas

Mensagem por Marc7 Dom Out 09, 2016 10:51 pm

Pessoal, estou com problemas no meu projeto, é o seguinte, estou no menu principal e, quando teclo Enter na opção GameStart, faz um Fade na tela para escurecer, em seguida carrega a cena Loading que me leva para a cena Level1. Fiz um video que vai explicar bem visualmente o que está acontecendo.





Aqui está o script do menu principal, na cena "Main":

Código:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;

public class GCMenuPrincipal : MonoBehaviour {

    public GameObject menuPrincip;
    public GameObject menuConfig;
    public GameObject menuSoundOption;
    public GameObject menuKeyConfig;
    public GameObject menuScreenAdj;
    public static int valor = 1;
    public int mainSelection = 1;
    public int soundSelections = 1;
    public int keySelections = 1;
    public int screenSelections = 1;
    public static int level = 2;
    public static int player = 3;
    public static int credits = 3;
    public static int habilitaMenu = 1;
    public bool gameStart = false;
    public int menus;
    public AudioClip disparar;

    private AudioSource somMenuMain;

    void Awake()  {
        if (somMenuMain == null) {
            somMenuMain = GetComponent<AudioSource>();
        }
    }

    void Update() {

        var menuQuit = GameObject.FindGameObjectWithTag("quit").GetComponent<GCQuitGame>().quitActive;
        if (habilitaMenu == 1 && !menuQuit) {
            menuPrincip.SetActive(true);
            menuConfig.SetActive(false);
            menuSoundOption.SetActive(false);
            opcoesMenuPrincipal();
            valorPadraoConfig();
        }

        if (habilitaMenu == 2 && !menuQuit) {
            if (mainSelection == 1) {
                var _fadeIn = GameObject.Find("FadeCamadaIn").GetComponent<FadeIn>();
                _fadeIn.enabled = true;
                StartCoroutine("carregaJogo");
            }
        }

        if (gameStart) {
            SceneManager.LoadScene("Loading");
            StopCoroutine("carregaJogo");
        }

        if (habilitaMenu == 2 && !menuQuit) {
            if (mainSelection == 2) {
                menuPrincip.SetActive(false);
                menuConfig.SetActive(true);
                menuSoundOption.SetActive(false);
                menuKeyConfig.SetActive(false);
                menuScreenAdj.SetActive(false);
                opcoesMenuConfig();
            }
        }

        if (habilitaMenu == 3 && !menuQuit) {
            if (valor == 4) {
                menuPrincip.SetActive(false);
                menuConfig.SetActive(false);
                menuSoundOption.SetActive(true);
                menuKeyConfig.SetActive(false);
                menuScreenAdj.SetActive(false);
                opcoesMenuSound();
            }
        }

        if (habilitaMenu == 3 && !menuQuit) {
            if (valor == 5) {
                menuPrincip.SetActive(false);
                menuConfig.SetActive(false);
                menuSoundOption.SetActive(false);
                menuKeyConfig.SetActive(true);
                menuScreenAdj.SetActive(false);
                opcoesMenuKey();
            }
        }

        if (habilitaMenu == 3 && !menuQuit) {
            if (valor == 6) {
                menuPrincip.SetActive(false);
                menuConfig.SetActive(false);
                menuSoundOption.SetActive(false);
                menuKeyConfig.SetActive(false);
                menuScreenAdj.SetActive(true);
                opcoesMenuScreen();
            }
        }

        //Fechar o jogo caso a opçao Exit seja apertada.
        if (habilitaMenu == 2) {
            if (mainSelection == 5) {
                var fadeIn = GameObject.Find("FadeCamada").GetComponent<FadeIn>();
                fadeIn.enabled = true;
                defaultOptionsConfig();

                if (FadeIn.valor == 1) {
                    Application.Quit();
                }
            }
        }

        //Carrega a cena Creditos.
        if (habilitaMenu == 2) {
            if (mainSelection == 4) {
                SceneManager.LoadScene("_Credits");
            }
        }

        //Mantem o valor minimo de habilitaMenu em 1.
        if (habilitaMenu == 0) {
            habilitaMenu += 1;
        }

        menus = habilitaMenu;

        trocaMenu();
        opcaoDificuldade();
        opcaoPlayer();
        opcaoCreditos();
        opcaoPadrao();
        optionsRetornar();
    }

    public void opcoesMenuPrincipal() {
        var imgMainSelect = GameObject.Find("MainSelectImage").GetComponent<RectTransform>();

        //Navegar nas opçoes do Menu principal.
        if (Input.GetKeyDown("down")) {
            mainSelection += 1;
            somMenuMain.Play();
        }

        if (mainSelection == 6) {
            if (Input.GetKeyDown("down")) {
                mainSelection -= 5;
            }
        }

        if (Input.GetKeyDown("up")) {
            mainSelection -= 1;
            somMenuMain.Play();
        }

        if (mainSelection == 0) {
            if (Input.GetKeyDown("up")) {
                mainSelection += 5;
            }
        }

        if (mainSelection == 1) {
            imgMainSelect.localPosition = new Vector2(0, 67.0f);
        }

        if (mainSelection == 2) {
            imgMainSelect.localPosition = new Vector2(0, 29.0f);
        }

        if (mainSelection == 3) {
            imgMainSelect.localPosition = new Vector2(0, -8.999f);
        }

        if (mainSelection == 4) {
            imgMainSelect.localPosition = new Vector2(0, -47.0f);
        }

        if (mainSelection == 5) {
            imgMainSelect.localPosition = new Vector2(0, -84.999f);
        }
    }

    public void opcoesMenuConfig() {
        var imagemDific = GameObject.Find("DifficultImage").GetComponent<RectTransform>();

        //Navegar nas opçoes do Menu Config.
        if (Input.GetKeyDown("down")) {
            valor += 1;
            somMenuMain.Play();
        }

        if (Input.GetKeyDown("up")) {
            valor -= 1;
            somMenuMain.Play();
        }

        if (valor == 9) {
            if (Input.GetKeyDown("down")) {
                valor -= 8;
            }
        }

        if (valor == 0) {
            if (Input.GetKeyDown("up")) {
                valor += 8;
            }
        }

        if (valor == 1) {
            imagemDific.localPosition = new Vector2(-53.4f, 103.5f);
        }

        if (valor == 2) {
            imagemDific.localPosition = new Vector2(-53.4f, 69.5f);
        }

        if (valor == 3) {
            imagemDific.localPosition = new Vector2(-53.4f, 35.7f);
        }

        if (valor == 4) {
            imagemDific.localPosition = new Vector2(-53.4f, 2.2f);
        }

        if (valor == 5) {
            imagemDific.localPosition = new Vector2(-53.4f, -31.5f);
        }

        if (valor == 6) {
            imagemDific.localPosition = new Vector2(-53.4f, -64.98f);
        }

        if (valor == 7) {
            imagemDific.localPosition = new Vector2(-53.4f, -98.7f);
        }

        if (valor ==  {
            imagemDific.localPosition = new Vector2(2.050f, -132.5f);
        }
    }

    public void opcoesMenuSound() {
        var textBGM = GameObject.Find("BGMText").GetComponent<Text>();
        var textSE = GameObject.Find("SEText").GetComponent<Text>();
        var textSoundTest = GameObject.Find("SoundTestText").GetComponent<Text>();
        var textDefault = GameObject.Find("DefaultText").GetComponent<Text>();
        var textReturn = GameObject.Find("ReturnText").GetComponent<Text>();

        //Navegar nas opçoes do Menu Sound Options.
        if (Input.GetKeyDown("down")) {
            soundSelections += 1;
            somMenuMain.Play();
        }

        if (Input.GetKeyDown("up")) {
            soundSelections -= 1;
            somMenuMain.Play();
        }

        if (soundSelections == 6) {
            if (Input.GetKeyDown("down")) {
                soundSelections -= 5;
            }
        }

        if (soundSelections == 0) {
            if (Input.GetKeyDown("up")) {
                soundSelections += 5;
            }
        }

        if (soundSelections == 1) {
            textBGM.color = new Color(0.3f, 0.8f, 0.8f);
            textSE.color = new Color(1, 1, 1f);
            textSoundTest.color = new Color(1, 1, 1);
            textDefault.color = new Color(1, 1, 1);
            textReturn.color = new Color(1, 1, 1);
        }

        if (soundSelections == 2) {
            textBGM.color = new Color(1, 1, 1);
            textSE.color = new Color(0.3f, 0.8f, 0.8f);
            textSoundTest.color = new Color(1, 1, 1);
            textDefault.color = new Color(1, 1, 1);
            textReturn.color = new Color(1, 1, 1);
        }

        if (soundSelections == 3) {
            textBGM.color = new Color(1, 1, 1);
            textSE.color = new Color(1, 1, 1f);
            textSoundTest.color = new Color(0.3f, 0.8f, 0.8f);
            textDefault.color = new Color(1, 1, 1);
            textReturn.color = new Color(1, 1, 1);
        }

        if (soundSelections == 4) {
            textBGM.color = new Color(1, 1, 1);
            textSE.color = new Color(1, 1, 1f);
            textSoundTest.color = new Color(1, 1, 1);
            textDefault.color = new Color(0.3f, 0.8f, 0.8f);
            textReturn.color = new Color(1, 1, 1);
        }

        if (soundSelections == 5) {
            textBGM.color = new Color(1, 1, 1);
            textSE.color = new Color(1, 1, 1f);
            textSoundTest.color = new Color(1, 1, 1);
            textDefault.color = new Color(1, 1, 1);
            textReturn.color = new Color(0.3f, 0.8f, 0.8f);
        }
    }

    public void opcoesMenuKey() {
        var textInput = GameObject.Find("InputText").GetComponent<Text>();
        var textReturn2 = GameObject.Find("ReturnText2").GetComponent<Text>();

        //Navegar nas opçoes do Menu Key Config.
        if (Input.GetKeyDown("down")) {
            keySelections += 1;
            somMenuMain.Play();
        }

        if (Input.GetKeyDown("up")) {
            keySelections -= 1;
            somMenuMain.Play();
        }

        if (keySelections == 3) {
            if (Input.GetKeyDown("down")) {
                keySelections -= 2;
            }
        }

        if (keySelections == 0) {
            if (Input.GetKeyDown("up")) {
                keySelections += 2;
            }
        }

        if (keySelections == 1) {
            textInput.color = new Color(0.3f, 0.8f, 0.8f);
            textReturn2.color = new Color(1, 1, 1);
        }

        if (keySelections == 2) {
            textInput.color = new Color(1, 1, 1);
            textReturn2.color = new Color(0.3f, 0.8f, 0.8f);
        }
    }

    public void opcoesMenuScreen() {
        var textResolut = GameObject.Find("ResolutionText").GetComponent<Text>();
        var textReturn3 = GameObject.Find("ReturnText3").GetComponent<Text>();

        //Navegar nas opçoes do Menu Screen Adjust.
        if (Input.GetKeyDown("down")) {
            screenSelections += 1;
            somMenuMain.Play();
        }

        if (Input.GetKeyDown("up")) {
            screenSelections -= 1;
            somMenuMain.Play();
        }

        if (screenSelections == 3) {
            if (Input.GetKeyDown("down")) {
                screenSelections -= 2;
            }
        }

        if (screenSelections == 0) {
            if (Input.GetKeyDown("up")) {
                screenSelections += 2;
            }
        }

        if (screenSelections == 1) {
            textResolut.color = new Color(0.3f, 0.8f, 0.8f);
            textReturn3.color = new Color(1, 1, 1);
        }

        if (screenSelections == 2) {
            textResolut.color = new Color(1, 1, 1);
            textReturn3.color = new Color(0.3f, 0.8f, 0.8f);
        }
    }

    void opcaoDificuldade() {
        var opcoesDific = GameObject.Find("DifficultOptions").GetComponent<Text>();

        if (valor == 1) {
            if (Input.GetKeyDown("right")) {
                level += 1;
                if (level == 4) {
                    level -= 1;
                }
            }
        }

        if (valor == 1) {
            if (Input.GetKeyDown("left")) {
                level -= 1;
                if (level == 0) {
                    level += 1;
                }
            }
        }

        if (level == 1) {
            opcoesDific.text = "Easy";
        }

        if (level == 2) {
            opcoesDific.text = "Normal";
        }

        if (level == 3) {
            opcoesDific.text = "Hard";
        }
    }

    void opcaoPlayer() {
        var opcoesPlayer = GameObject.Find("PlayerOptions").GetComponent<Text>();

        if (valor == 2) {
            if (Input.GetKeyDown("right")) {
                player += 1;
                if (player == 6) {
                    player -= 1;
                }
            }
        }

        if (valor == 2) {
            if (Input.GetKeyDown("left")) {
                player -= 1;
                if (player == 0) {
                    player += 1;
                }
            }
        }

        if (player == 1) {
            opcoesPlayer.text = "1";
        }

        if (player == 2) {
            opcoesPlayer.text = "2";
        }

        if (player == 3) {
            opcoesPlayer.text = "3";
        }

        if (player == 4) {
            opcoesPlayer.text = "4";
        }

        if (player == 5) {
            opcoesPlayer.text = "5";
        }
    }

    void opcaoCreditos() {
        var opcoesCredits = GameObject.Find("CreditsOptions").GetComponent<Text>();

        if (valor == 3) {
            if (Input.GetKeyDown("right")) {
                credits += 1;
                if (credits == 6) {
                    credits -= 1;
                }
            }
        }

        if (valor == 3) {
            if (Input.GetKeyDown("left")) {
                credits -= 1;
                if (credits == 0) {
                    credits += 1;
                }
            }
        }

        if (credits == 1) {
            opcoesCredits.text = "1";
        }

        if (credits == 2) {
            opcoesCredits.text = "2";
        }

        if (credits == 3) {
            opcoesCredits.text = "3";
        }

        if (credits == 4) {
            opcoesCredits.text = "4";
        }

        if (credits == 5) {
            opcoesCredits.text = "5";
        }
    }

    void opcaoPadrao() {
        if (valor == 7) {
            if (Input.GetKeyDown("return")) {
                level = 2;
                player = 3;
                credits = 3;
            }
        }
    }

    void optionsRetornar() {
        if (valor ==  {
            if (Input.GetKeyDown("return")) {
                menuPrincip.SetActive(true);        //Ativa o Painel Principal.
                menuConfig.SetActive(false);        //Desativa o Painel de Configurações.
                habilitaMenu -= 1;
                PlayerPrefs.SetInt("NivelSelecionado", level);
                PlayerPrefs.SetInt("VidaSelecionada", player);
                PlayerPrefs.SetInt("CreditoSelecionado", credits);

                if (habilitaMenu == 2) {
                    habilitaMenu -= 1;
                }
            }
        }
    }

    void valorPadraoMain() {
        mainSelection = 2;
    }

    void valorPadraoConfig() {
        valor = 1;
    }

    public void defaultOptionsConfig() {
        level = 2;
        player = 3;
        credits = 3;
    }

    void valorPadraoSound() {
        soundSelections = 1;
    }

    void valorPadraoKey() {
        keySelections = 1;
    }

    void valorPadraoScreen() {
        screenSelections = 1;
    }

    void trocaMenu() {
        if (habilitaMenu == 3 && soundSelections == 5 || keySelections == 2 || screenSelections == 2) {
            if (Input.GetKeyDown("return")) {
                habilitaMenu -= 1;
                valorPadraoSound();
                valorPadraoKey();
                valorPadraoScreen();
                return;
            }
        }

        //Trocar de menu.
        if (habilitaMenu == 1 && mainSelection == 2 || mainSelection == 5 || mainSelection == 4 || mainSelection == 1) {
            if (Input.GetKeyDown("return")) {
                habilitaMenu += 1;
            }
        }

        if (habilitaMenu == 2 && valor == 4 || valor == 5 || valor == 6) {
            if (Input.GetKeyDown("return")) {
                habilitaMenu += 1;
            }
        }

        //Mantem o valor maximo de habilitaMenu em 3.
        if (Input.GetKeyDown("return")) {
            if (habilitaMenu == 4) {
                habilitaMenu -= 1;
            }
        }
    }

    IEnumerator carregaJogo() {
        yield return new WaitForSeconds(2.5f);
        gameStart = true;
    }
}

E aqui o script que abre o menu PAUSE, que me dá a opção de retomar o jogo ou voltar à cena Main:

Código:
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
using System.Collections;

public class GCPause : MonoBehaviour {

    public GameObject menuPause;
    public int value2 = 1;
    public bool menuPauseActive = false;

    
    void Update() {
        if (Input.GetKeyDown("escape") && !menuPauseActive) {
            menuPauseActive = true;
            Invoke("AtivaPause", 0.1f);
            AudioListener.volume = 0;
        }

        if (!menuPauseActive) {
            PauseDefault();
        }

        pauseOptions();
        botaoVoltar();
        botaoMenuPrincipal();

    }

    void pauseOptions() {

        //Selecionar as opçoes Sim e Nao atraves das teclas frente e tras.
        if (menuPauseActive) {
            if (Input.GetKeyDown("down")) {
                value2 += 1;
            }

            if (Input.GetKeyDown("up")) {
                value2 -= 1;
            }

            if (value2 == 3) {
                if (Input.GetKeyDown("down")) {
                    value2 -= 2;
                }
            }

            if (value2 == 0) {
                if (Input.GetKeyDown("up")) {
                    value2 += 2;
                }
            }

            if (value2 == 1) {
                GameObject.Find("MainMenuText").GetComponent<Text>().color = new Color(0.3f, 0.8f, 0.8f);
            }
            else {
                GameObject.Find("MainMenuText").GetComponent<Text>().color = new Color(1, 1, 1);
            }

            if (value2 == 2) {
                GameObject.Find("BackText").GetComponent<Text>().color = new Color(0.3f, 0.8f, 0.8f);
            }
            else {
                GameObject.Find("BackText").GetComponent<Text>().color = new Color(1, 1, 1);
            }
        }
    }

    public void botaoVoltar() {
        if (value2 == 2) {
            if (Input.GetKeyDown("return")) {
                Time.timeScale = 1f;
                menuPause.SetActive(false);
                menuPauseActive = false;
                AudioListener.volume = 1f;
            }
        }
    }

    public void botaoMenuPrincipal() {
        if (value2 == 1) {
            if (Input.GetKeyDown("return")) {
                Time.timeScale = 1f;
                SceneManager.LoadScene("Main");
                GCMenuPrincipal.habilitaMenu = 1;
                menuPauseActive = false;
                GCMenuPrincipal.level = PlayerPrefs.GetInt("NivelSelecionado");
                GCMenuPrincipal.player = PlayerPrefs.GetInt("VidaSelecionada");
                GCMenuPrincipal.credits = PlayerPrefs.GetInt("CreditoSelecionado");
            }
        }
    }

    void AtivaPause() {
        Time.timeScale = 0f;
        menuPause.SetActive(true);
    }

    void PauseDefault() {
        value2 = 1;
    }
}


Conforme os scripts, onde está o erro?
Marc7
Marc7
Mestre
Mestre

PONTOS : 3205
REPUTAÇÃO : 28
Respeito as regras : Problemas após trocar de cenas WvDYdlf

Ir para o topo Ir para baixo

Resolvido Re: Problemas após trocar de cenas

Mensagem por Marc7 Ter Out 11, 2016 1:07 am

Pessoal, consegui resolver o problema do audio, mas ainda continua falhando o escurecimento da tela quando seleciono a opção Game Start.
Mas essa falha só acontece quando retorno à cena do menu principal, após abrir o menu pause. Na primeira vez, quando clico no play para simular o jogo, esse fade está funcionando.
Queria saber por que não funciona depois numa segunda vez
Marc7
Marc7
Mestre
Mestre

PONTOS : 3205
REPUTAÇÃO : 28
Respeito as regras : Problemas após trocar de cenas WvDYdlf

Ir para o topo Ir para baixo

Resolvido Re: Problemas após trocar de cenas

Mensagem por MarcosSchultz Qua Out 12, 2016 7:25 pm

No momento que você da o play pela segunda vez, aparece um erro.

Poderia nos mostrar qual erro é este?
MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 64736
REPUTAÇÃO : 2650
Idade : 27
Áreas de atuação : Administrador do fórum
Respeito as regras : Problemas após trocar de cenas Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

Resolvido Re: Problemas após trocar de cenas

Mensagem por Marc7 Qua Out 12, 2016 7:37 pm

MarcosSchultz escreveu:No momento que você da o play pela segunda vez, aparece um erro.

Poderia nos mostrar qual erro é este?

Marcos na verdade não é quado dou o play pela segunda vez.

primeiro eu dou o play aí começa a simular o jogo, vou na opção Game Start, teclo ENTER e acontece o escurecimento da tela, é uma imagem UI dentro do canvas em que eu inseri uma camada preta (uma imagem toda preta).

aí começa o jogo na cena Level1. se eu apertar ESC para aparecer o menu Pause e escolher a opção Menu Principal, vou voltar para a cena Main.
Deixando o jogo ainda em simulação, se eu der ENTER de novo no Game Start a camada preta não dá mais o efeito fading.
e isso vai acontecendo mesmo eu voltando varias vezes para o menu principal.
não sei o que é.
Marc7
Marc7
Mestre
Mestre

PONTOS : 3205
REPUTAÇÃO : 28
Respeito as regras : Problemas após trocar de cenas WvDYdlf

Ir para o topo Ir para baixo

Resolvido Re: Problemas após trocar de cenas

Mensagem por MarcosSchultz Dom Out 16, 2016 9:43 pm

Tem como zipar o projeto e mandar para eu ver o que pode ser?

Pelo que da a entender, algum script está perdendo a referência do objeto nas trocas de cena.
MarcosSchultz
MarcosSchultz
Administrador

Masculino PONTOS : 64736
REPUTAÇÃO : 2650
Idade : 27
Áreas de atuação : Administrador do fórum
Respeito as regras : Problemas após trocar de cenas Aad8pUi

https://www.schultzgames.com

Ir para o topo Ir para baixo

Resolvido Re: Problemas após trocar de cenas

Mensagem por Marc7 Seg Out 17, 2016 2:36 am

Marcos por um descuido eu acabei perdendo a pasta do projeto desse jogo, então não vou poder de enviar esse projeto, mas pelo menos alguns scripts dele estavam salvos em outro lugar.
Mas eu descobri o problema, o erro no fade da tela preta estava em uma variavel que setei como static para ser acessada de outro script. depois que tirei o static para volta-la ao normal e fiz o codigo do outro script de uma forma diferente, esse erro corrigiu.
o audio era por conta do AudioListener, eu o retirei suspeitando dele e aí corrigiu.
Marc7
Marc7
Mestre
Mestre

PONTOS : 3205
REPUTAÇÃO : 28
Respeito as regras : Problemas após trocar de cenas WvDYdlf

Ir para o topo Ir para baixo

Ir para o topo

- Tópicos semelhantes

 
Permissões neste sub-fórum
Não podes responder a tópicos