Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Bug WORKING PERFECT ON EDITOR BUT NOT ON PHONE

Discussion in 'Editor & General Support' started by CoolCosmos, Oct 19, 2020.

  1. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    247
    My game works perfectly on unity editor. I have built it for android devices and uploaded the apk on google drive. Then i installedit on my android device. But some of codes are not working.

    Whats not working is: I have two dropdowns which players can select fire color and character color. I save the values and text strings by using playerprefs When they select one. Then they press start button to load next scene. Character color is working good but fire effects are not being instantiated. The more interesting thing is that animation clips are not playing too when press button.
     
  2. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    247
    THIS IS IN FIRST SCENE
    Code (CSharp):
    1.     void Start()
    2.     {
    3.         dropDownCharacter.onValueChanged.AddListener(delegate {
    4.             OnMyValueChange01(dropDownCharacter);
    5.         });
    6.  
    7.         dropDownFire.onValueChanged.AddListener(delegate {
    8.             OnMyValueChange02(dropDownFire);
    9.         });
    10.     }
    11.  
    12.     private void OnMyValueChange01(Dropdown change)
    13.     {
    14.         PlayerPrefs.SetInt("characterInt", change.value);
    15.         PlayerPrefs.SetString("characterString", change.options[change.value].text);
    16.     }
    17.  
    18.     private void OnMyValueChange02(Dropdown change)
    19.     {
    20.         PlayerPrefs.SetInt("fireInt", change.value);
    21.         PlayerPrefs.SetString("fireString", change.options[change.value].text);
    22.     }
    THIS IS IN SECOND SCENE
    Code (CSharp):
    1.    private void StartGame()
    2.     {
    3.         characterInstance = (GameObject)Instantiate(theCharacter, Vector3.zero, Quaternion.identity);
    4.  
    5.         myGun = GameObject.FindWithTag("Gun");
    6.  
    7.         characterAnimator = GameObject.FindWithTag("Character").GetComponent<Animator>();
    8.     }
    9.  
    10.     public void Fire() //FIRE BUTTON
    11.     {
    12.         if (!characterDied && ammo > 0)
    13.         {
    14.             ammo -= 1;
    15.  
    16.             characterAnimator.SetTrigger("isFire");
    17.  
    18.             fireEffectInstance = (GameObject)Instantiate(fireEffect, myGun.transform.position, fireEffect.transform.rotation);
    19.         }
    20.     }
    21.  
    22.     private void SetColors() // IN AWAKE METHOD
    23.     {
    24.         if (PlayerPrefs.GetString("characterString", "Blue Character") == "Blue Character")
    25.         {
    26.             theWitch = blueCharacter;
    27.         }
    28.  
    29.         if (PlayerPrefs.GetString("characterString", "Blue Character") == "Pink Character")
    30.         {
    31.             theWitch = pinkCharacter;
    32.         }
    33.  
    34.         if (PlayerPrefs.GetString("fireString", "Blue Fire") == "Blue Fire")
    35.         {
    36.             fireEffect = blueFire;
    37.         }
    38.  
    39.         if (PlayerPrefs.GetString("fireString", "Blue Fire") == "Pink Fire")
    40.         {
    41.             fireEffect = pinkFire;
    42.         }
    43.  
    44.         if (PlayerPrefs.GetString("fireString", "Blue Fire") == "Yellow Fire")
    45.         {
    46.             fireEffect = yellowFire;
    47.         }
    48.  
    49.         if (PlayerPrefs.GetString("fireString", "Blue Fire") == "Purple Fire")
    50.         {
    51.             fireEffect = purpleFire;
    52.         }
    53.  
    54.         if (PlayerPrefs.GetString("fireString", "Blue Fire") == "Green Fire")
    55.         {
    56.             fireEffect = greenFire;
    57.         }
    58.     }
     
    Last edited: Oct 20, 2020
  3. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    247
    noone even views the thread as usual...

    These codes are working perfect on unity editor but when i built it for android and download on my phone via google drive, it doesn't work.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    For these types of issues do two things. First, check the player log on the mobile device for any errors. Maybe there are errors loading certain textures, maybe something else, no idea because "doesn't work" doesn't give enough information to guess.

    Second add Debug.Log statements everywhere so you can track what is actually happening in your code. Then verify the code path is being followed as you expect it should. If not, that gives you something specific to investigate.
     
    Last edited: Oct 19, 2020
  5. CoolCosmos

    CoolCosmos

    Joined:
    Nov 21, 2016
    Posts:
    247
    Hi @Joe-Censored thanks for reply, i don't know how to check player log on mobile and i don't know how to see debug.log messages from mobile.

    I don't get any errors or bugs on unity editor. The problem might be when i build it for android. I'm not that good on technical details.
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Yeah if it works fine in the editor but not on Android, then the editor logs aren't going to tell you anything. To view the log info, including Debug.Log, on Android you use logcat. More info:
    https://docs.unity3d.com/Manual/LogFiles.html
     
    CoolCosmos likes this.
  7. germincjk

    germincjk

    Joined:
    Mar 9, 2023
    Posts:
    1
    If you have a faulty code and open unity editor in unsafe mode, the firebase package disappears.
    I realised that when I was comparing my previous working apk with the damaged one.
    If you have a working one:
    1) Change the file type from fileNameWorking.apk to filenameWorking.zip.
    2) Then unzip and compare both fileNameWorking.zip and fileNameDamaged.zip.

    There is a FirebaseCrashlytic.UnityPackage which may help.
    Hope this works.