I am using Unity3D for this question, but this is a general software development issue.
Objects (interactive objects) in Unity3D are built with components or behavior. By combining the behavior with each other, you determine the exact behavior of the object.
I reflect on how different objects react differently when they click, based on the global state. For example, I have a tool that targets only circles around the scene; if I select this tool and click on the object, and if it is a circle, I will change it to a square. If it is not a circle, I will simply ignore it.
Using a component-based object design, I would define a behavior called IsCircle, and when it is clicked, I will check what should happen to it. However, what is the best way to access the global state of the entire application? Let's say I want to avoid any switch if-else, and I want the solution to be untied
(The problem is that the OnMouseDown () event handler does not pass any parameters).
I would appreciate it if the answer would mean the environment that I am using applies a compound template.
source share