About 8,830 results
Open links in new tab
  1. Which is better practice in Unity? GetComponent<> () or making …

    Apr 17, 2020 · Say, the component attached to an object is of type Animator and the name is animator. So, in the script, I can write private Animator animator; and then call the function …

  2. How is Unity's GetComponent implemented in C#

    Mar 5, 2018 · I'm just curious that what aspects of the C# language Unity's GetComponent method uses. In the C# language we have reflection that lets programmers access a variable …

  3. unity - SerializeField vs GetComponent Efficiency - Game …

    Aug 4, 2015 · If you use GetComponent () in your script, you will generally store the component in a variable so that it is cached for reuse in your script, so it works out to be the same thing in …

  4. unity - How to get materials from objects? - Game Development …

    Aug 3, 2023 · Although the inspector lists the materials below the components of a gameObject, Materials are not components. So GetComponent<Material> is never going to return anything. …

  5. unity - How do I use GetComponent on multiple children? - Game ...

    Oct 7, 2019 · How do I use GetComponent on multiple children? Ask Question Asked 6 years, 1 month ago Modified 6 years, 1 month ago

  6. unity - How to get a specific button component - Game …

    Jan 31, 2021 · Remember, someObject.GetComponent gets a component attached to someObject. If you don't lead with a specific object to look in, and just type GetComponent on …

  7. unity - What are the differences between using …

    May 27, 2015 · I can understand using GetComponent() in most cases, but why would you specifically use the function for GameObject and Transform when the two items are accessible …

  8. unity - How To Avoid GetComponent on raycasts and collisions

    Nov 29, 2021 · GetComponent() is suggested to not be used so frequently because it can cause a performance impact. I'm working on a game that needs to check the components of objects …

  9. unity - What is a faster alternative to a GetComponent from a ...

    Jul 11, 2017 · It's a good idea, I have seen unity developers using component like Collider2D to cache other component. Though, I am still curious if unity has lazy initialization. If we have …

  10. unity - How do I get the object color? - Game Development Stack …

    Dec 25, 2016 · In Order to get the color on the screen one could also use render texture with pixel get access and use worldtoscreenpoint to get the pixel positions of the object. Then the exact …