Unity client interview questions collection

Friends who are looking for a job & are about to start looking for a job soon ~ I am caring, and this time I have prepared a [Gift Pack of Interview Questions] for everyone! !

During the interview process of Unity game development engineers , we can always come into contact with many familiar interview questions. If the scores of this part are accidentally lost, it will be the most pity! The gate of the big factory will only close before your eyes...  

Randomly search a lot of interview questions on the Internet, and there will inevitably be some questions with high repetition rate, inaccuracy, and "too old" questions! Considering that it is convenient for everyone to check for omissions and fill in vacancies at any time , this article has compiled a total of 20 interview questions for you, covering real interview questions & C# basic questions & Lua interview questionsI suggest students collect them quickly!

1. Unity interview highlights

Unity interview questions

1. Introduction to the script life cycle of MonoBehaviour

answer:

Awake: After the object is instantiated for the first time, it will only be called once

OnEnable: Called every time the object is activated

Start: will only be called after the instance is enabled for the first time, before the first frame is updated

FixedUpdate (Physics): Fixed update frequency, performing physical calculations and updates.

Update: Called every frame to execute business logic.

After the Update function returns, the coroutine update will be performed.

Different uses of coroutines:

Yield null Continue to execute the current coroutine in the next frame

yield WaitForSeconds Continue to execute the current coroutine after the specified time (seconds)

yield WaitForFixedUpdate Wait for the next Fixed Update to continue the current coroutine

yield WWW continues the current coroutine after WWW download is complete

yield StartCoroutine(MyFunc) links the coroutines together, and waits for the completion of the MyFunc coroutine before executing the current coroutine.

LateUpdate: Each frame calls LateUpdate after Update is called. The common use of LateUpdate is to follow the third-person camera, ensure the movement and rotation of the character in Update, and perform all camera movement and rotation calculations in LateUpdate.

OnDisable: This function is called every time the object is set to inactive.

OnDestroy: This function is called after all frame updates have been completed in the last frame in which the object exists

OnApplicationQuit: This function is called when the application exits.

2. How to calculate the memory occupied by the texture after it is loaded into the memory?

answer:

After the texture Texture is loaded into the memory, the size calculation formula is as follows:

Texture memory size (bytes) = texture width x texture height x pixel bytes

Pixel byte = number of pixel channels (R/G/B/A) x channel size (1 byte/nibble)

Example: For example, how much memory does a 1024 * 1204 RGBA 32bit texture take up?

Total number of bits occupied: allbits = 1024 * 1024 * (4*8bit)

Total bytes occupied: allbytes = allbits / 8bit

Note: 1 byte = 8bit

3. The difference between boxing and unboxing

answer:

Boxing: converting a value type to a reference type

Boxing operation: the managed heap allocates memory, the value type copies data, and the object address points to the managed heap object.

Unboxing; converting a reference type to a value type

Unboxing operation: find the data on the managed heap according to the reference address of the object, and copy the data on the stack.

Avoid boxing operations, which can be solved by overloading or generics.

4. The difference between public, private, protected, internal, and sealed

answer:

public global, private class internal, protected derived class, internal this assembly
sealed declaration class cannot be inherited, and the declaration method cannot be overridden

5. Please describe the difference between interface and abstract class

answer:

An interface is a behavior, an abstract class is an object that cannot be instantiated.

Interface interface can declare methods

Abstract class abstract can define fields, static fields and methods, abstract methods, properties, constructors

An interface can inherit multiple interfaces, an abstract class can only inherit one class

Classes that inherit interfaces must implement all interfaces; abstract classes need to rewrite the override abstract method

Neither interfaces nor abstractions can be instantiated

An abstract class can be derived from another abstract class, an interface can have multiple inheritance, and an abstract class can only have single inheritance.

6. How many light sources does Unity3d provide? What are they?

answer:

A total of 4 types, DirectionalLight, PointLight, SpotLight, AreaLight

7. What is the relationship between Net and Mono?

answer:

.Net can only run on the windows platform, and the emergence of Mono is to solve the problem that .Net cannot be cross-platform. Mono provides an integrated development environment for .Net, integrates and implements the .NET compiler and basic class library, so that .Net can run on both windows and linux, Unix, Mac OS, etc.

8. How to write the C# function Fu nc(string a, string b) using Lambda expression?

answer:

‍Lambda expression (arbitrary parameter) => {expression}; => read as goesto(a,b) => {};

9. What error will be reported if static is added before the function construction of the class? Why?

answer:

Static constructors do not allow access modifiers and must be parameterless.

Reason: No matter how many objects of the type are created, the static constructor is only executed once. Before the class is instantiated or the first static member is called, the runtime library will call the static constructor first. The static constructor has a higher priority than any other constructor, and this and base cannot be used to call the static constructor. A class can only have one static function. If there is a static variable, the system will automatically generate a static function.

Two, C# basic questions

1. Introduce C#'s string and String Builder

answer:

String is an immutable value. When splicing through string, it will cause new heap memory to be generated, thus generating GC;

And StringBuilder maintains a dynamic array internally, as long as it does not exceed the size of the array, it can be reused. Note: The premise of reducing GC is to give a reasonable capacity and avoid frequent resize.

2. What is the difference between a regular container and a generic container in C#? Which is more efficient?

answer:

Regular containers have unboxing and boxing operations, which are slow and consume performance; generic containers are more efficient because there is no unboxing operation.

3. What are the common value types

answer:

Numerical types (int/short/float/double, etc.), Boolean, structure, enumeration

4. Can the constructor be rewritten?

answer:

The constructor Constructor cannot be inherited, so it cannot be overridden, but it can be overloaded.

5. What is the difference between delegate and interface in C#? What occasions are they used in?

answer:

Delegate delegate: Unity events are closely related to delegates, and the callback mechanism reduces data interaction between objects.

Interface interface: multi-person collaboration, complete abstraction, single inheritance.

A delegate is a collection of constraint methods, and an interface is a collection of functions possessed by a constraint class, which solves the problem of single inheritance.

6. What is the unsafe keyword in C# used for? What occasions to use?

answer:

unsafe Unmanaged code, used together with fixed, used in occasions that require pointer operations. Used in the task equipment column of the item backpack system.

3. Lua interview questions

1. Briefly describe the principle of Lua's object-oriented implementation?

answer:

1. The table table is an object, and the object has related operations such as identification self and status

2. Use the parameter self to indicate that the receiver of the method is the object itself, which is the core point of object-oriented. The colon operator can hide the self parameter

3. Class (Class): Each object has a prototype, and the prototype (lua class system) can organize shared behavior among multiple objects

4. setmetatable(A,{__index=B}) Set B as the prototype of A

5. Inheritance (Inheritance): classes in Lua are also objects, and methods and unavailable fields can be obtained from other classes (objects)

6. Inheritance feature: You can redefine (modify the implementation) any method inherited in the base class

2. Data types supported by Lua

answer:

nil means an invalid value

number integer

table table

string character

userdata user-defined

function function

bool Boolean

thread thread

3. The result of print(string.find("hello hello","hel"))?

answer:

6 9

4. What is the use of __index and __newindex in Lua?

answer:

__index is mainly used for table query;

__newindex is mainly used for table update

5. How does Lua call C#

answer:

Three ways.
The first: not recommended by the official.
The second: if the Lua file is under the Resource file, use Lua’s Require function.
The third: if the Lua file is downloaded, use a custom Loader to satisfy

Opportunities will only be reserved for those who are prepared . Take every interview seriously, and take the time to review it carefully after the end . Even if the interview fails in the end, we can learn a lot from it~

In fact, the interview is not only a very important part of job hunting , but also an opportunity to fully exercise our knowledge & skills & communication &... and other aspects!

Of course~ Before the interview, you must read this article carefully, check for omissions and fill in the gaps , so that you can better meet the interview challenges of major game companies!

The above 20 interview questions

Have you memorized it all? !

Students who want to know more interview questions from game manufacturers such as [Tencent, Netease, Mihayou, Lilith] ~ quickly scan the QR code below to add a teaching assistant teacher! ! !

Guess you like

Origin blog.csdn.net/Richard_shen/article/details/127654923