Search Unity

[Solved] Modifying a RectTransform crashes Build

Discussion in 'Editor & General Support' started by ediit, Mar 29, 2022.

  1. ediit

    ediit

    Joined:
    Mar 17, 2018
    Posts:
    8
    I'm trying to solve a critical issue in my game that's causing it to crash as soon as any RectTransform is changed. I have no idea why this is happening, all I did was refactor my Pause Menu UI to use RectTransforms instead of Transforms so I can use pixel space & make UI tweens work at any resolution.

    Now, when I modify any RectTransform, my game crashes in a build. For example, the following line in Start() causes my game to crash instantly:
    confirmationPanel.localScale = Vector3.zero;

    If I comment that line out the game doesn't crash. But unfortunately for me, I guess, I need to be able to change RectTransforms.

    I have no idea what happened or how to fix this but if anyone has any idea please let me know.
     
  2. ediit

    ediit

    Joined:
    Mar 17, 2018
    Posts:
    8
    SOLVED! whew. When I switched the variable type for my panels, I fixed the type mismatches and updated my Pause Menu prefab. Somehow the prefab never saved so the types were still mismatched for my Main Menu scene and that was causing the crashes.

    So, double-check your prefabs if you make a sweeping change like this :cool:
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,676
    Yeah, that's definitely a thing... if you change the type of a field that Unity is serializing for you but you leave the name exactly the same, *BOOM*!

    The best approach I find is to rename it, at least trivially, and make sure all the serialization is removed.

    Then name it back and drag all of your references back in.

    Working with source control you will easily be able to see all the places that get changed... it will have a slightly different internal ID number, if I recall.