The use of {get;set;}

Could someone explain what this code below does and why haven’t we used set; instead?

private Material curMaterial;
    Material material
    {
        get
        {
            if (curMaterial == null)
            {
                curMaterial = new Material(chromeAbbShader);
                curMaterial.hideFlags = HideFlags.HideAndDontSave;
            }
            return curMaterial;
        }
    }

1 Answer

1

This is a getter that creates a default material the first time it is called.

Keep up the good work, I'm building an mmo-esk game that has everything from first/3rd and eagle cam, I need a player controller that works with custom gravity, steps, and physics.