It’s not because you are using Unity which was written in C++. Your scripts are only a part of your project.
I don’t think obfuscating the names of classes and methods would help
As aforementioned, the code will always be exposed. What I described could prevent a “hacker” from understanding your code at the first glance. “AddPointsToScore” can be understood even by a beginner while some cryptic name like “Blasjfjkdhgtdk” is meaningless without any context.
Or can you tell how lines like these would affect a game if you saw hundreds of them? You would probably have to use the trial and error approach to understand what’s going on there. That’ll take time, and maybe it is not worth it for the “hacker”.
unityInstance.SendMessage("dfsk","fdjgl",1000000);
unityInstance.SendMessage("glkjglsdgf","gfsdogtorgteroph",434);
Many programmers use encrypting scripts to prevent beginners from stealing their code. Depending on the complexity of their projects, an experienced programmer will need days to decrypt the scripts, and it might be that they give up early because developing their own solution is faster than grasping your code. That’s the idea behind the concept and a workaround for the insoluble problem.
Is there perhaps some way the Score
class could disclose a randomly generated secret token to the objects that call it (without using a public method)?
There are no secrets but you could certainly write an algorithm that passes on some token which can be verified by the receiving method before the points get added to the score. That algorithm will be exposed, too, though, so an experienced programmer who really wants to cheat, will be able to generate his own valid token.
You also could evaluate the current project state. Did the ball hit a block in that moment when the AddPointsToScore was called?
In a multiplayer game, you could other players evaluate the situation as well because if the cheater was able to pass on a different value to the AddPointsToScore method than the other players, there must be something wrong with the method call.
That will definitely have a negative impact on the performance of your project, and the question remains: Is it worth it?