Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Bug Game behaves differently between editor (Windows) and hardware (Android)

Discussion in 'Scripting' started by xanrer, Oct 6, 2022.

  1. xanrer

    xanrer

    Joined:
    May 10, 2015
    Posts:
    12
    Hello, I have a script that should restart the level with the default variables:
    SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    . When this code executes in the editor everything works as intended and the level rotation is set to 0 however when I try this on the hardware level rotation gets messed up and rotates to the angle script is called instead of the default angle of the level. For the first time in a while, I think this is not my fault and is about Unity instead, If any developer wants to look into the code I can share some snippets.
     
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,455
    1. It almost always is an oversight of the developer and not the engine (especially for code)
    2. Always share affected code
     
    Kiwasi likes this.
  3. TheDevloper

    TheDevloper

    Joined:
    Apr 30, 2019
    Posts:
    69
    please share your code, it's 100% code related issue, just create 2 new empty scenes and test your script witout any other script.
     
  4. xanrer

    xanrer

    Joined:
    May 10, 2015
    Posts:
    12
    I can't test this with empty scenes since it requires the rotation value however I can share some of the code.

    Here is a largely cut down version of the GameManager: https://pastebin.com/8sZPcMZJ
    Here is some of LevelGenerator: https://pastebin.com/TJ3ftc6r

    Hope these help. If any more code is needed please tell me.
     
  5. xanrer

    xanrer

    Joined:
    May 10, 2015
    Posts:
    12
    Hey, I shared the code. Is it enough code? If not I can share more.
     
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,455
    Not going through the whole script right now, but use debug logs to see what goes wronf
     
  7. xanrer

    xanrer

    Joined:
    May 10, 2015
    Posts:
    12
    I cannot use them on my phone because I don't have the cable to do so.
     
  8. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    4,455
    Then buy a cheap usb cable...

    Edit: you can also debug wirelessly using wifi
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    You can also write the Debug.Log output to the UI into a (temporary for now) text field. That is what I do on the Sample IAP Project, very handy for debugging (no cable required!). This may help too https://forum.unity.com/threads/tips-for-new-unity-users.701864/#post-5057741

    Code (CSharp):
    1. private void MyDebug(string debug)
    2.     {
    3.         Debug.Log(debug);
    4.         myText.text += "\r\n" + debug;
    5.     }