- Home /
Question by
LarsTheGlidingSquirrel · Apr 03, 2020 at 09:33 AM ·
gameobjectcreate
Create premade GameObjects (e.g. UI/Canvas) in Editor via Script
I want my script to create a Canvas & EventSystem if none is present during runtime. In the editor I can click GameObject/UI/Canvas and the Editor will create a Canvas and EventSystem for me. Can I call whatever function is triggered here also inside my script?
I know about two other ways to solve this: 1. Create a prefab for Canvas and EventSystem and instantiate this. 2. Create Canvas and EventSystem via script using "new GameObject(...)" and "addComponent<...>()". However, since the Unity editor is capable of this anyway, I would like to use the same code.
Have a great day! :)
Comment