当前位置:网站首页>Unity interview questions (continuously updated)

Unity interview questions (continuously updated)

2022-07-04 16:54:00 Drink my toner

1.UGUI matters needing attention
1.GameObject.SetActive Use... As little as possible . Because in OnEnable and OnDisenable Will reset all the dirty signs
2. Do not use tile type operation Image Use Rawimage
3. Raycast Turn it off if you don't need it ,Unity On by default , But there are a lot of UI There is no need to receive click events
4. UI It is necessary to pay attention to whether the materials are the same in the batch , picture ID Whether or not the same
5. UI On the Color attribute Direct modification is not recommended , Modification will cause redrawing mesh, It is suggested that changing the shader color will not cause this problem
2. Differences between structs and classes
1. Class is a reference type , A structure is a value type .
2. The structure can be dispensed with new Create instance object , Class must use new To create an instance object .
3. Structs cannot inherit classes or structs , Interface can be implemented ; Class can inherit class , Cannot inherit structure , Interface can be implemented .
4. Structure cannot declare a default constructor , The constructor of the structure must assign values to all fields .
3.C# Of Dictionary
1.Dictionary Every element in it is a key value pair ( It's made up of two elements : Key and value )
2. The key must be unique , And values don't need to be unique
3. Keys and values can be of any type ( such as :string, int, Custom type , wait )
4. The time to read a value through a key is close to O(1)
4. The difference between stack and heap
1. Stacks are allocated automatically by the system , And heap is thought to be developed
2. The space obtained by stack is relatively small , The space gained by heap is relatively large
3. The stack is allocated by the system , It's quite fast , The heap is generally slow
4. A stack is a continuous space , The heap is a discontinuous space
5.Navigation
establish NavMesh Navigation grid : After creating all the components, bake out the data needed by the runtime navigation system , Select the grid to navigate , stay static The admission Navigation, Set properties ,Bake.
6. Red and black trees
Binary search tree (BST) What are the characteristics of ?
1. The values of all nodes on the left subtree are less than or equal to the values of its root nodes .
2. The value of all nodes on the right subtree is greater than or equal to the value of its root node .
3. Left 、 The right subtree is also a binary sort tree .
In order to solve the imbalance caused by inserting new nodes into binary search tree many times , Red and black trees came into being .
In addition to the characteristics of binary search tree, red black tree , It's also attached with :
1. The nodes are red or black .
2. The root node is black .
3. Each leaf node is black and empty (NIL node ).
4 The two child nodes of each red node are black .( There cannot be two consecutive red nodes on all paths from each leaf to the root )
5. All paths from any node to each leaf contain the same number of black nodes .
The longest path from heel to leaf will not exceed the shortest path 2 times .
When inserting again , In order to keep the red black tree always red black tree , Discoloration 、 left-handed 、 Three adjustment methods of right rotation .
7.Unity Life cycle
(1) Reset() When the component is reset to the default value ( For editing status only )
(2)Awake() Script component loading ( Call once )
(3)OnEnable() Is called when the game object can call
(4) Start() first Update Before it happened ( Call once )
(5)FixedUpdate() Fixed time call , Commonly used in Physics related calculations , For example, yes. Rigidbody The operation of
(6)Update() Where most of the game behavior code is executed , Except for physical code
(7)LateUpdate() Every frame Update After call
(8)OnGUI() draw GUI Called when the
(9)OnDisable() When the object is set to unavailable
(10)OnDestroy() Call... When the component is destroyed

原网站

版权声明
本文为[Drink my toner]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202141134587744.html