What class is a Panel?

I’d like to be able to move a Panel object around inside it’s parent Canvas object in script. I’d like to add a public variable to a gameobject so it can manipulate the Panel in script. What type do I use for the panel variable? There are UnityEngine.UI.Button and UnityEngine.UI.Text classes, but there is no UnityEngine.UI.Panel class, so I’m confused.

2 Answers

2

A Panel does not have it’s own class, all the “Panel” Game Object is, is a “Rect Transfrom”, a “Canvas Renderer”, and a “Image” script, which are classes that are on every uGUI Game Object that I have seen (except the “Image” script, which isn’t on a uGUI “Text”), the “Image” script is just the script to actually show the image for the panel., so I think you should use the “Rect Transform” as it holds the position, and maybe a hidden button for dragging it, if it can only be dragged from a certain area anyway, or a custom script that detects mouse down, and mouse drag.

As indicated panels don't exist. When you click create panel Unity simply creates its internal prefab for panel. This is the same as creating a cube or any of the other built in GameObjects. There is no cube class. The cube is a GameObject with mesh, renderer and collider components attatched.

–

I was looking for the same thing and I find out that panel it’s just used like a simple GameObject.