I’ve been trying to learn the new UI to build a sidebar menu for my strategy game (It will display army and units or construction options). I had something working a few months ago using the old UI stuff though scripting and I have been trying the same approach with the new system. I have run into a problem trying to create panel’s as panels are just a gameobject with a RectTransform, CanvasRender and image script. I can easily add the first two but how do I get the image script? I tried to copy it or open it to create my own version but I can’t seem to do that, as it just opens Mono but no script.
I am also curious as to what all the script handles. I am still trying to figure out what the new UI is better at and why I should use it (anchoring is pretty cool). I’ve seen a lot of videos on how to use it but I am still unclear if it handles things like clicking though the UI and if so, what part is responsible for that. In my old system I had an object that handled clicks based on where the click was and what regions of the screen had active menus. Do I still need to implement something like that?
Thanks, this is part of what I am looking for. I needed the Image.cs to make a panel through scripting, however now that I have it though the repository, making a copy of it creates errors due to the protection level of SetPropertyUtility which is used in the Image.cs script.
Is there another way to make a panel by script other than by creating a gameobject with the same components?
You do not need to download the GUI code and put it into your project.
Just include the namespace and you can use the GUI components like every other component in unity.
Whats wrong with the component approach?
You can make a Panel Prefab and instantiate it yo you can save some scripting work.
Part of my problem was using UnityEngine and not also using UnityEngine.UI , which I thought would be included. I need to get more familiar with how namespaces work. Thanks again!