Ugui Source Learning Image

Source: Internet
Author: User

"Reprint" https://blog.csdn.net/a237653639/article/details/50774207

Disclaimer: As the official only exposes the Ugui source C # Package of this layer, does not expose C + + underlying code, but look at these C # code is also good

Uibehavior a total of 14 derived classes, derived classes include selectable, graphic, and so on. Where button, Slide, Scrollbar, Toggle, Inputfield are classified as selectable subclasses, which means "optional", while image, Text, and Rawimage are classed as subclasses of graphic, This is the writer's design ideas.

Ugui source code is divided into run-time and edit-time code, run-time and edit-time code are divided into EventSystem and UI two parts. This section explains only the runtime code, first the image of the UI section:

one, the various attributes explained

1.Source Image
When you create a new panel panel, the image component is added automatically, using a background picture of Unity's own. This way you will see that the screen is not filled and that there is a certain amount of space around it.
If your goal is to fill the full screen, it is recommended that you set the source image and material to none, so that you can use Unity's default rendering method instead of using the specified background image.

2.Color
A hex color indicates the hexadecimal of the current color when the point is opened

3.Material

4.Raycast Target
Whether the target is marked as a ray projection. The default tick indicates that the mouse clicks into the object and no longer penetrates into the object below. Uncheck to penetrate the object. Tips: When you create a new button, you can set the object on it to click through.

5.Image Type 6.FillMethod 7.FillOrigin 8.FillAmount 9.Clockwise 10.Fill Center

11.Preserve Aspect
Keep the picture's original aspect ratio. (regardless of how wide the picture is, the ratio of the width to height remains constant, only for imagetype simple and filled)

second, from the class inherited by the image and the implementation of the interface to see

The following is an image of the class and the implementation of the interface to see what these interfaces and the parent class is used, the class diagram is as follows:

public class image:maskablegraphic, Iserializationcallbackreceiver, ilayoutelement, 
icanvasraycastfilter

1.MaskableGraphic

Graphic is the base class for UI controls that are visible to the player. And maskablegraphic inherit from the graphic class, then with graphic properties, such as layout, material, vertex processing, color. The difference between maskablegraphic as a subclass of graphic is whether it can be labeled as masked, and the default value of TRUE indicates that it can be mask.

In addition, the graphic class caches the recttransform, and the image inherits the Maskablegraphic, which has the above properties.

2.ISerializationCallbackReceiver

This thing has two callbacks, onafterdeserialize and onbeforeserialize, meaning that the image is allowed to perform some of its own processing before and after serialization and deserialization. That means that the image has been serialized. Of course, for example, *.unity is the data that holds the scene, and at runtime we go to the object where the data is deserialized to the runtime .

3.ILayoutElement

See the text, this interface is intended to match the layout of this type of script to use. With it, and then hang a layout script on the object of the image, you can do the arrangement.

4.ICanvasRaycastFilter

This interface is used for the event of a button. There is an interface method, Israycastlocationvalid, to detect whether the light is effective in projecting the object.

Another very good article, recommended to you: http://www.resetoter.cn/?p=396

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.