In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces Unity3D how to customize the bulletin board, the article is very detailed, has a certain reference value, interested friends must read it!
Make a bulletin board
Create a Canvas for UI, change the Render Mode mode to World Space, and then drag the Canvas canvas into a folder to become a prefab
Add Image background image, then add Text,Canvas canvas, Text text width and height are all set to 0, and the size of the bulletin board is set by Image
Set the anchor point and other related attributes again.
Finally, bind our control script.
In this way, a custom bulletin board is made.
Mode one
If the lens zoom lens is set to the fieldOfView value of the lens
Using UnityEngine
/ * * customize the bulletin board, follow the lens rotation and always face the screen in parallel, follow the lens to zoom and zoom the same size * / public class Billboard: MonoBehaviour {Camera camera;// main lens
Private float _ fieldOfView;// initial fieldOfView
Void Start () {camera = Camera.main; _ fieldOfView = camera.fieldOfView;} void Update () {/ / follow the rotation of the lens and directly assign the rotation value of the main lens to the bulletin board. Transform.rotation = camera.transform.rotation; / / follow the lens to zoom (zoom the lens is set to the fieldOfView value of the lens) float fieldOfView = camera.fieldOfView Transform.localScale = new Vector3 (fieldOfView/_fieldOfView,fieldOfView/_fieldOfView,fieldOfView/_fieldOfView);}
} Mode two
If the lens zooms the position of the lens set by the lens
Using UnityEngine
/ * * customize the bulletin board, follow the lens rotation and always face the screen in parallel, follow the lens to zoom and zoom the same size * / public class Billboard: MonoBehaviour {Camera camera;// main lens
Private float _ distance;// initial distance
Void Start () {camera = Camera.main; _ distance = Vector3.Distance (camera.transform.position, transform.position);} void Update () {/ / follow the rotation of the lens and directly assign the rotation value of the main lens to the bulletin board to transform.rotation = camera.transform.rotation
/ / follow the lens zoom (zoom the position of the lens set by the lens), float distance = Vector3.Distance (camera.transform.position, transform.position) according to the distance from the bulletin board to the main lens; / / the ever-changing distance var scale = distance/_distance * 0.1F; transform.localScale = new Vector3 (scale,scale,scale);}} effect
The following effect does not follow the zoom. If you want to follow the zoom, you can comment on the zoom part of the script code.
The above is all the contents of the article "how to customize the bulletin board by Unity3D". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.