I have scenes with some basic flame effect. Its max particle count is 20 and there are not more than 4-5 instances active on the screen at once. I even checked the profiler but the memory usage was around 150 MB maximum.

Given these, all runs fine in the editor but once the particles become visible, the game crashes every time. I tested this on a virtual Nexus tablet. I'm using Unity 2017.1.0p4. If anyone has encountered an issue like this, I'd appreciate any help to get around this.

EDIT: the built game crashes on PC as well (made a final build for PC, using the same PC).


So I was able to trace the issue back to the few following lines:

var mf = transform.parent.gameObject.GetComponentFromParentRecursive<MeshFilter>();

if (mf != null && mf.mesh != null)
    var sh2 = system.shape;
    sh2.mesh = mf.mesh;

public static class GetComponentRecursive
    /// <summary>
    /// Returns the first Component (T) found on the parent or its children
    /// = the gameobjects on the same level as this is called on.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="g"></param>
    /// <returns></returns>
    public static T GetComponentFromParentRecursive<T>(this GameObject g)
        where T : Component
        if(g.transform.parent.GetComponent<T>() != null)
            return g.transform.parent.GetComponent<T>();
            foreach (Transform c in g.transform.parent.transform)
                if(c.GetComponent<T>() != null)
                    return c.GetComponent<T>();
        return null;

Please bear in mind that GetComponentFromParentRecursive works, can use it for sprites, no harm done. When I comment out the first few lines, it doesn't crash(just lost functionality).

Any ideas why this might cause a crash? And only in built game?

  • \$\begingroup\$ If I'm not mistaken, I believe Unity usually generates some crash information on PC when something goes wrong - have you been able to inspect that, or hook a debugger into the running built game to find out where it's crashing? Without some diagnostic information it will be very tough for us to isolate the issue. \$\endgroup\$ – DMGregory Sep 7 '17 at 23:23
  • \$\begingroup\$ That's a good idea, I go and try to find where Unity puts the crash log. \$\endgroup\$ – agiro Sep 8 '17 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.