Search Issue Tracker
Fixed in 2017.1
Error when creating a RectTransform component in an Awake call of an instantiated MonoBehaviour
When using an Awake call in an instantiated prefab during play mode, to instantiate another gameObject and attach a RectTransform, the program throws an error saying that it can't add RectTransform because a Transform is already attached.
Steps to reproduce:
1.Open attached project.
2.Run play mode.
The issue appears only in the Awake() calls of the instantiated prefabs. Even when using the suggested "var go = new GameObject("Canvas", typeof(RectTransform));" workaround proves to be ineffective.
Expected outcome: When the prefabs are created, their awake scripts create gameObjects with rectTransforms attached.
Actual outcome: The original Awake() call functions normally, but the second awake() calls made in the instantiated objects are thrown.
Reproduces on v. 5.5.2p4, 5.6.0f2, 2017,1,0a4
Doesn't reproduce on v. 5.5.1p4
Similar issue reported here. Probably caused by the same thing.
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
- [Progress] Progress bar does not revert to unresponsive status after another task completes
- [Progress] Progress always displays the remaining time after doing it once
- Added Asset changes are lost in Unity Collaborate when renaming new Assets with Asset Import Pipeline V2 enabled
- [iOS] Debug .pdb files are added to iOS release builds
- UnityLinker strips classes used with the SerializeReference attribute