In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use Unity to make close-up related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have something to gain after reading this article on how to use Unity to make close-ups, let's take a look at it.
Similar to this effect.
The size of the black edge can be adjusted by itself.
In order to make it convenient to bind the method directly with two Button, you need to call the method yourself.
1. First of all, make the upper and lower black edges.
Create a Canvas and then create a new empty object on the canvas and name it CinemaCloseUpShot
Create a new script CinemaCloseUP above
Public class CinemaCloseUP: MonoBehaviour {public float targetSizeInput; / / the width of the upper and lower black stripes public float showTime; / / the time required for scaling. BottomBar; / / declares the upper and lower RectTransform. This component controls the UI size, position and other parameters private float changeSizeAmount; / / the change of the upper and lower black stripes private bool isActive in the UI. / / whether to make a close-up private float targetSize; / / private void Awake () {/ / create the top black bar with the type of image GameObject gameObject = new GameObject ("topBar", typeof (Image)); gameObject.transform.SetParent (transform, false); / / set the previous empty object as the parent object gameObject.GetComponent (). Color = Color.black / / set the color to black topBar = gameObject.GetComponent (); / / get the RectTransform of the black bar image / / set the anchor points of the above image to (0,1) and (1,1), which are actually the two anchor points topBar.anchorMax = new Vector2 (1,1) in the upper left corner and upper right corner of the parent object; topBar.anchorMin = new Vector2 (0,1) TopBar.sizeDelta = new Vector2 (0,0); / / default image size is 0 / / create the lower black bar. The type is gameObject = new GameObject ("bottomBar", typeof (Image)); gameObject.transform.SetParent (transform, false); gameObject.GetComponent (). Color = Color.black; bottomBar = gameObject.GetComponent () / / if the anchor points in the image below are set to (0,0) and (1,0), they are actually the lower left corner and lower right corner of the parent object: bottomBar.anchorMax = new Vector2 (1,0); bottomBar.anchorMin = new Vector2 (0,0); bottomBar.sizeDelta = new Vector2 (0,0). / / the default image size is 0} private void Update () {if (isActive) {Vector2 sizeDelta = topBar.sizeDelta; / / declare a sizeDelta and assign it to topBar.sizeDelta sizeDelta.y + = changeSizeAmount * Time.deltaTime / / the y direction of sizeDelta continues to increase / decrease, which is actually the width of the picture / / according to the following two methods, it is displayed as positive Hidden as negative if (changeSizeAmount > 0) / / case shown by clicking {if (sizeDelta.y > = targetSize) / / if the sizeDelta.y reaches the maximum width {sizeDelta.y = targetSize / / set the width of the sizeDelta isActive = false; / / stop changing}} else / / Click the hidden case {if (sizeDelta.y)
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.