Selection of Unity interview questions (2)

Hongliu Academy will make you a few steps faster.

I sorted out some Unity interview questions today, hoping to help you.

Interviewer: What is the difference between an abstract class and an interface?

Answer :

  • Neither abstract classes nor interfaces can be instantiated.
  • Abstract classes can have abstract methods and non-abstract methods, which can be overridden by subclasses.
  • An abstract class is primarily a common structure for subclasses. A constant, field, operator, instance constructor, destructor, or type cannot contain static members.
  • Interfaces cannot have implementation methods, and interfaces are primarily used as specifications.

Interviewer: One of the main differences between MeshCollider and other Colliders?

Answer :

MeshCollider is a mesh collider. For collision detection on complex mesh models, it is more accurate than other collision detection, but compared with other collision detection calculations, it also increases, so generally using mesh collision will not compare the number of faces. Adding to the high model, two models will be made, one ultra-simplified model can represent the shape of the object for collision detection, and the other is for display.

Interviewer: What is the difference between a collider and a trigger in Unity3d?

Answer :

The collider is the carrier of the trigger, and the trigger is just an attribute on the collider. When Is Trigger=false, the collider triggers a collision according to the physics engine to produce a collision effect, you can call the OnCollisionEnter/Stay/Exit function; when Is Trigger=true, the collider is ignored by the physics engine, there is no collision effect, you can call OnTriggerEnter/Stay/Exit function. Triggers can be used if you want to detect the contact of an object without letting the collision detection affect the movement of the object, or if you want to detect whether an object passes through a certain area in space.

Interviewer: Please describe the design patterns you know, and where have you used them in your project?

Answer :

Singleton: object pool, game manager, abstract factory
State: finite state machine
Bridge: finite state machine
Strategy: a unique example of each control algorithm in AI automatic behavior control

Interviewer: Please name 4 object-oriented design principles and briefly describe their meanings.

Answer :

Single Responsibility Principle: A class, it is best to do only one thing, and only one change that causes it.
Open-Closed Principle: Open for extension, closed for change.
Liskov Substitution Principle: A subclass must be able to replace its base class.
Dependency Inversion Principle: Design should depend on abstractions rather than concrete implementations.
Interface Segregation Principle: Use multiple small dedicated interfaces instead of one large general interface.

Pay attention to the public account of Hongliu Academy , and regularly push it every Monday.


I'm Dazhi (vx: zhz11235), your technology pathfinder, see you next time!

don't go! Like it , collect it!

OK, you can go.

Guess you like

Origin blog.csdn.net/zhenghongzhi6/article/details/111193006