In general, the situation is this. There is a MainMenu script, hung on MainCamera .

 using UnityEngine; using UnityEngineInternal; using System.Collections; using UnityEngine.UI; using System; public class MainMenu : MonoBehaviour { public GameObject canvas; public GameObject background; public GameObject button; GameObject panelMainMenu; void Start() { panelMainMenu = Instantiate(canvas) as GameObject; GameObject background = CreateBackground(0,0,1920,1080,panelMainMenu) as GameObject; } public GameObject CreateBackground(float posX, float posY, float sizeX, float sizeY, GameObject parent) { GameObject back = Instantiate(background, Vector3.zero, Quaternion.identity) as GameObject; back.transform.SetParent(parent.transform); back.transform.localScale = new Vector3(sizeX, sizeY, 1); back.transform.localPosition = new Vector3(posX, posY, 0); return back; } } 

canvas, background, button - standard UI elements attached through the inspector. After the scene starts, a furious memory zhory with the Unity application begins, as a result of which, if you do not have time to close the process, the entire system is put. What could be the reason? In the scene there are only MainCamera and EventSystem .

  • With this script, Zhorikov was not noticed ........ hence the problem is not this ..... aren't there any scripts attached to anything else? Where is update or fixedUdpdate or IEnumerator, etc.? Any scripts in the Editor folder that work with current classes? What is the version of the unit? - Alexey Shimansky
  • Yes, I tested it in another project, everything works. There are no objects and scripts in the scene, except for the above, version 5.2.0f3. - Sick Hooglight
  • Try it means to re-create a new project and do it in it - Alexey Shimansky

1 answer 1

As far as I remember, we had a similar problem with this version (5.2.0) of Unity, when working with the UI, the memory very quickly overflowed and the application crashed. We treated this by installing the latest patch for this version. Try to put patches (we put 3 if I'm not mistaken), but rather update to the latest version, most likely the problem will be solved.