try get component code example
Example: unity try get component
using UnityEngine;public class TryGetComponentExample : MonoBehaviour
{
void Start()
{
if (TryGetComponent(out HingeJoint hinge))
{
hinge.useSpring = false;
}
}
}