Search Unity

Bug Final build does not update edited data

Discussion in 'Unity Hub' started by dougfight, Feb 26, 2024.

  1. dougfight

    dougfight

    Joined:
    Nov 21, 2016
    Posts:
    5
    Good afternoon.

    Sorry for wrong writing.
    My language is not English and that's why I already have difficulties understanding several things, I'm not a professional in the area, but I've been developing an independent project alone and so far I've been successful, but I'm having problems compiling the game.

    USING:
    Windows 10
    Unity 2022.3.20f1
    Visual Studio 2022

    EXPLANATION:
    I'm creating a game that is working correctly within unity (playmode), but it doesn't work the same way in the build game (compiling for standalone windows).

    PROBLEM:
    When I test the game in playmode it works correctly.
    When I copy it into build and run, it doesn't work correctly.

    I noticed that when I edit a script or model or anything, unity does not recreate the compilation with the new information and only shows the first one that was made.

    ATTEMPTS:

    I've already searched on Google and only things come up regarding online or Android data updates, but I want to talk about building the game and not about data or about online and other platforms.

    I have already turned off and turned on the PC again.

    I already deleted the libraries folder.

    I've already created a new project and it always only creates the first build I generate and doesn't even assign a new change when I edit something and recompile. It always goes back to the first one.

    If there is a bug, what should I do?
    If it is configuration, where and how should I configure, I need instructions in this case.

    Note that in old versions, all you had to do was click on build and run which generated a compilation of the current project and in this new version of unity I have this problem.
    As mentioned, the changes are not updating, and therefore there is no error to report in the console.

    I appreciate everyone's attention for solutions.

    Exemple code:

    Code (CSharp):
    1.  
    2.     //This method is a fist method create
    3.     private void GetDate(string data){
    4.  
    5.         GameObject objUI = GameObject.Find("ObjUI");
    6.         TextMeshProUGUI textUI = objUI.GetComponent<TextMeshProUGUI>();
    7.         textUIEndereco.text = data;
    8.         //Is working alright.
    9.     }
    10.  
    11.     //This method is a method update and not read in copilation
    12.     private void GetDate(string data){
    13.  
    14.         GameObject objUI = GameObject.Find("ObjUI");
    15.         TextMeshProUGUI textUI = objUI.GetComponent<TextMeshProUGUI>();
    16.  
    17.         if(data.Equals("")){
    18.  
    19.             textUIEndereco.text = "Not data";
    20.  
    21.         }else{
    22.  
    23.             textUIEndereco.text = data;
    24.  
    25.         }
    26.  
    27.         //Not owrking. No read 'if' and 'else'.
    28.     }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,672
    Read the device logs and see if you're getting any exceptions.

    ALSO: do not use this command:

    More information: https://starmanta.gitbooks.io/unitytipsredux/content/first-question.html

    More information: https://forum.unity.com/threads/why-cant-i-find-the-other-objects.1360192/#post-8581066

    In general, DO NOT use Find-like or GetComponent/AddComponent-like methods unless there truly is no other way, eg, dynamic runtime discovery of arbitrary objects. These mechanisms are for extremely-advanced use ONLY.

    If something is built into your scene or prefab, make a script and drag the reference(s) in. That will let you experience the highest rate of The Unity Way(tm) success of accessing things in your game.
     
  3. dougfight

    dougfight

    Joined:
    Nov 21, 2016
    Posts:
    5
    Obrigado pela resposta. Mas infelizmente não tem nada a ver com o problema.

    No projeto original não utilizo GameObjEct.Find fiz isso aqui porque é um exemplo de código onde coloquei um texto de ui para mostrar os dados recebidos.

    Como descrevi, o primeiro método mostra a informação, quando adicionei o tratamento 'if' ao "else" para verificar se os dados existiam, o Unity não copiou isso para o jogo final.
    Não faz nada, não passa as informações para a UI.
    Mas se eu deixar o código igual ao primeiro método novamente, funciona.

    Estou pegando esses dados de duas maneiras
    um é Resources.Load<TextAsset>(caminho);
    e o outro é
    Arquivo FileStream = novo FileStream (caminho, FileMode.Open, FileAccess.Read);
    StreamReader sr = novo StreamReader(arquivo);
    DadosArquivo = sr.ReadToEnd();
    sr.Fechar();
    arquivo.Fechar();

    Independente de como eu pego os dados de um arquivo .txt, ele sempre retorna os valores normalmente.

    Coloquei debug.log no método que recebe esses dados e ele coloca no texto da UI. Tudo normal.
    Porém, se eu tento usar esses dados que estão em uma string, ele só funciona no playmode e não no jogo compilado.
     
  4. dougfight

    dougfight

    Joined:
    Nov 21, 2016
    Posts:
    5
    Thanks for the answer. But unfortunately it has nothing to do with the problem.

    In the original project I don't use GameObjEct.Find I did this here because it is a code example where I placed a UI text to show the received data.

    As I described, the first method shows the information, when I added the 'if' treatment to the "else" to check if the data existed, Unity didn't copy this into the final game.
    It doesn't do anything, it doesn't pass the information to the UI.
    But if I leave the code the same as the first method again, it works.

    I'm getting this data in two ways
    one is Resources.Load<TextAsset>(path);
    and the other is
    FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read);
    StreamReader sr = new StreamReader(file);
    FileData = sr.ReadToEnd();
    sr.Close();
    file.Close();

    Regardless of how I get the data from a .txt file, it always returns the values normally.

    I put debug.log in the method that receives this data and it puts it in the UI text. Everything normal.
    However, if I try to use this data that is in a string, it only works in playmode and not in the compiled game.