{"comment":{"url":"https://api.github.com/repos/itbmac/damascus/comments/10104749","html_url":"https://github.com/itbmac/damascus/commit/c751fe6f966968b9f4e57abf160334b90f762740#commitcomment-10104749","id":10104749,"user":{"login":"grrosegr","id":2615986,"avatar_url":"https://avatars.githubusercontent.com/u/2615986?v=3","gravatar_id":"","url":"https://api.github.com/users/grrosegr","html_url":"https://github.com/grrosegr","followers_url":"https://api.github.com/users/grrosegr/followers","following_url":"https://api.github.com/users/grrosegr/following{/other_user}","gists_url":"https://api.github.com/users/grrosegr/gists{/gist_id}","starred_url":"https://api.github.com/users/grrosegr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grrosegr/subscriptions","organizations_url":"https://api.github.com/users/grrosegr/orgs","repos_url":"https://api.github.com/users/grrosegr/repos","events_url":"https://api.github.com/users/grrosegr/events{/privacy}","received_events_url":"https://api.github.com/users/grrosegr/received_events","type":"User","site_admin":false},"position":9,"line":9,"path":"2_platformer/drawmascus/Assets/Scripts/ColorToggle.cs","commit_id":"c751fe6f966968b9f4e57abf160334b90f762740","created_at":"2015-03-09T17:32:33Z","updated_at":"2015-03-09T17:32:33Z","body":"Why are these variables public? They're not used in any other script. It's preferred to make things private by default, and then public *only* when you need to access it in another script, and even then, there are several other things you should try/do before making it public, e.g. \"readonly\", use a property, or have a method which encapsulates interaction (Pancake.Cook() rather than if (!pancake.Cooked) { do stuff, then pancake.Cooked = true; }). \r\n\r\nExposing them publicly means any other script could mess this script up, which is confusing, since it wouldn't even be code in this file. It also clutters up the autocomplete.\r\n\r\nAdditionally, making them public (by default, but you could separately turn this off) exposes them in the editor, meaning someone could accidentally change it, or at least adds another confusing option. Even if no one touches it, it also makes it serialized, which means Unity will save the default value in the scene file, which will overwrite whatever default is written here (although these two in particular doesn't set a default, other public variables in this file do)."}}