Scripting Shortcuts

Hi, I’m learning to script, just getting used to few things around here and there.

If I wanted to use gameObject.renderer.material.color often, can’t I just set the whole thing equal to “Color” somehow?

So I tried Color = gameObject.renderer.material.color

I forgot how to make those Shortcuts. Can somebody help me?

+* I just want to be able to use the whole sentence without having to type it out every single time. Do you get me?

I remember watching a tutorial video about it. Someone used a shortened version of narrowing things down, so for example, “Cube Color” instead of renderer.material.color.

He said that would be less messy & faster for Unity to read…

Color variableName = gameObject.renderer.material.color;

Not sure if this is what you are looking for, as it is pretty trivial scripting…

If on the other hand you want to CHANGE gameObject.renderer.material.color often, then no, there is no shortcut, other than defining a new Color, changing it and then setting the material.color to that newly defined Color at the end of the function.

Also, gameObject is unnecessary to type out. renderer.material.color is enough.