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

Is Android losing resources on level loads?

Discussion in 'Editor & General Support' started by CommitteeWind, Jan 25, 2013.

  1. CommitteeWind

    CommitteeWind

    Joined:
    Oct 20, 2010
    Posts:
    38
    I have narrowed down to pin-point accuracy the process to crash my game on Android. Here is how I do it:

    Bootstrap-Scene (start scene) loads and displays menu

    You click play and select character

    You play the character and drop the bomb (creates particle fx and everythigng works)

    You hit pause and go to the main menu (this takes you an Empty scene with just a Main Camera object in it)

    You click play and select character

    You play the character and drop the bomb (as soon as the explosion particle FX WOULD be created they crash the game)


    Here's what I know: it is only when I load into another scene (even an empty one) and then load back into my playable level that the bomb explosion particles crash the game. I can do this every single time, and it does not break otherwise.

    I've looked over every bit of my code and nothing is sticking out, the bomb just has a timer that then calls "Instantiate" on a prefab that contains the particle system (it's one from the Cartoon FX Pack 2 using the Mobile variant).

    When I tap "Try Again" instead of "Menu" the game will not break. This is because when I click "Try Again" I am calling LoadLevel on the scene I am already in to reset it. However "Menu" I call LoadLevel("Empty"), and then after I select the player I get to LoadLevel("Forest")

    Now here's something even crazier: If I put a bomb prefab in my Empty scene, the bomb explodes just fine. The game also does not crash after I LoadLevel from "Empty" to "Forest". This, in my limited understanding of Unity3D's Android implementation and under-pinnings, suggests to me that the resource was lost during a LoadLevel call and then reloaded if the scene contained the resource explicitly. Just a guess... not sure though.

    Any suggestions on what I should do here?
     
  2. CommitteeWind

    CommitteeWind

    Joined:
    Oct 20, 2010
    Posts:
    38
    Still not sure what is going on here, I'd appreciate any insight to why this would be happening.
     
  3. Alastair Callum

    Alastair Callum

    Joined:
    Sep 3, 2012
    Posts:
    71
    This sounds like a null reference exception, but why that would cause your game to crash I'm not sure. Things to check:

    - I know the FX pack uses scripts to disable/destroy the effects at the end of their life. Be sure that they are not the cause.
    - How are you creating the effect, Instantiate() ?

    You can also get full diagnostics by running logcat. WIth your device connected:

    Windows - locate your android SDK folder > tools > ddms.batch and use the search filter "app: unity"
    Mac - locate your android SDK folder > platform-tools > adb.exec
     
  4. CommitteeWind

    CommitteeWind

    Joined:
    Oct 20, 2010
    Posts:
    38
    I might be going crazy, but I updated Unity3D from 4 to 4.1 and now there is no problem...