当前位置:网站首页>[unity] button of UI interactive component & summary of optional base classes

[unity] button of UI interactive component & summary of optional base classes

2022-06-27 04:25:00 Rice shrimp

Button (Button)

 

The button control can respond to the user's click and trigger the start or confirm operation , such as Web On the form Submit And Cancel Button . There are mainly Three attributes Interactable / Transition / Navigation

️Interactable Property function :

Enable to make the button accept input ( There are related API file

️Transition Property function :

Visual responses to user actions can be made in some way , The specific methods and responses are as follows ( Transition options )

In the optional components , The number of transition options depends on the current state of the optional components . Different states include : normal / highlight / Press down / Ban .

Transition options : function :
None The button has no status effect at all .
Color Tint Change the button color according to the button state . Colors can be selected for each individual state , It can also be set between different states Fade Duration attribute . The greater the number , The slower the color fades in and out .
Sprite Swap Allow different sprites to be displayed according to the current state of the button , Customizable sprites .
Animation (Animation) Allow animation based on button state , An animator component must exist to use animation transitions . It is important to ensure that root motion is disabled . To create an animation controller , single click Generate Animation / Create your own , And make sure you have added an animation controller to the button's animator component .

except None Each transition option outside provides additional options for controlling transitions . Each option section will be described in detail below .

Color Tint

attribute : function :
Target Graphic Graphics for interactive components .
Normal Color The normal color of the control
Highlighted Color The color when the control is highlighted
Pressed Color The color when the control is pressed
Disabled Color Control is disabled
Color Multiplier This multiplies the shading color of each transition by its value . This allows you to create a larger than 1 The color of the , So that the primary color is smaller than white ( Or less than full Alpha) The color on the graphic elements of ( or Alpha passageway ) Brighten .
Fade Duration The time it takes to fade in and out from one state to another ( In seconds )

Sprite Swap

 

attribute : function :
Target Graphic Normal sprites to use
Highlighted Sprite Control to use when highlighting
Pressed Sprite Control to use when pressed
Disabled Sprite Control to be used when disabled

Animation

attribute : function :
Normal Trigger Normal animation trigger to use
Highlighted Trigger The trigger to use when the control is highlighted
Pressed Trigger The trigger to use when the control is pressed
Disabled Trigger Trigger to use when the control is disabled

️Navigation Property function :

Used to determine the control order ( See navigation options for details )

attribute : function :
Navigation Navigation options indicate how to control UI Element navigation in playback mode .
None Keyless navigation . just so so Make sure you click / Clicking won't get focus .
Horizontal lateral navigation .
Vertical Vertical navigation .
Automatic Automatic pilot .
Explicit In this mode , You can explicitly specify where different arrow keys will navigate the control .
Visualize choice Visualize It can visually display the navigation you set in the scene window .

 

The scene window of the visual navigation connection diagram

 

In the above visualization mode , Arrows indicate how to set focus changes for the entire control collection . It means , For each individual UI Control , If the user presses the arrow key when a given control has focus , You can see what will get the focus next UI Control . therefore , In the example shown above , If “Button” Has focus and the user presses the right arrow key , Is the first ( left ) The vertical slider will then gain focus . You cannot use the up or down keys to move the focus away from the vertical slider , Because these two keys are used to control the value of the slider . Horizontal slider and left / The same is true for the right arrow key . 

️ event On Click Property function

When you click and release the button , call UnityEvent

Details

The button is used to start an operation when the user clicks and releases it . If you move the mouse away from the button control before releasing the click , The operation will not be performed .

The button has a name  On Click  Events , When the user finishes clicking, it will respond . Typical use cases include :

  • Confirm a decision ( for example , Start the game or save the game )
  • Move to GUI Submenu in
  • Cancel the operation in progress ( for example , Download new scene )
原网站

版权声明
本文为[Rice shrimp]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/178/202206270402560471.html