Combine the sugar, cornstarch, and salt in a medium saucepan. Gradually stir in the milk until smooth. Bring to a boil over medium heat, stirring constantly, and boil for 1 minute, until thickened. Remove from heat and stir in the butter and vanilla. Once the butter has melted, stir in the unsweetened flaked coconut. Cool the mixture completely.