This is a stupid question, but I can’t find the answer as it seems like an accepted convention, except I am not sure what the convention is.
this.GetComponent**<SpriteRenderer>**().color = Color.yellow;
What is this <> ? I am used to seeing codes that could look like, GetComponent(SpriteRenderer) or GetComponent(“SpriteRenderer”) or GetComponent.SpriteRenderer …but I have never seen <>
Is this a C# thing, or a unity thing? what is it called ? When is it used other than this particular instance?
While trying to research the answer on GetComponent, i came across this example :
2. HingeJoint hinge = gameObject.GetComponent(typeof(HingeJoint)) as HingeJoint;
What is this code doing? It looks to me like the 2nd as HingeJoint is unnecessary because the variable hinge was declared as HingeJoint in the first place at the beginning of the code.
Why can’t it just be: hinge = gameObject.GetComponent(typeof(HingeJoint)) as HingeJoint;
OR HingeJoint hinge = gameObject.GetComponent(typeof(HingeJoint))