Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How properly organize workspace in Unity?

Example: there are objects A and B. Object A must connect with object B (by Script) and object B must connect with object A (by Script).
How to do it more properly:

  1. Create Scripts for each objects.
  2. Create Empty Object and add one Script to it, and then in this Script to create two references (for A and B)?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What you describe at section 2 is known as Mediator pattern. You should definitely use it or you can also use Observer pattern. The difference between them is there’s a mediator between them which causes loosely coupling.

The common part between them is whenever an event happens to the object itself, it throws a callback and the other objects gets notified and do their own jobs.

To even make a better organization you can look at MVC(S) and ECS architectural pattern.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading