How Add component using script in Unity

Опубликовано: 07 Октябрь 2024
на канале: VionixStudio
4,999
23

Unity works based on a component system. Every Gameobject’s characteristics are defined by the components added to it. For example, the position is defined by the transform component and the collision is defined by the collider component. This component-based system requires a constant addition or removal of components to alter the behavior of the Gameobjects. In this tutorial, we will see how to add a new component to a Gameobject and also how to access and modify the existing components.
Adding component to a Gameobject during gameplay is not the right way to manage your code, adding a new component takes up a lot of memory and if you frequently add or remove a component from a Gameobject during gameplay, there will be performance issues. We will discuss on how to to efficiently work with components in the later part of this tutorial.

Read more on https://vionixstudio.com/2021/09/22/u...