Everyone knows the importance of “reusable” components when it comes to effective software development. When defining a “reusable” component as Object-Oriented, it should be independent in accordance with a discipline I have mastered in OO.

Component Oriented Design

Whether client side or server side, we are used to the word “Component”. Regardless of platform, “Component” is object-oriented based. Because of these, when we design a framework for Unity3D, Componentization is the core of the design. Let’s summarize a number of disciplines to begin with:

  • If a method is called frequently in various situations, it makes sense to add it as abstract in the SubView (SubViewModel)
  • SubView (SubViewModel) should be able to be updated in accordance with high compatibility, low dependency discipline.
  • The SubViewModel should not be for specific business logic, it should be simple and be able to receive work through an external transaction Delegate.

Developing SubView and SubViewModel

Suppose a character’s information needs to fit into an icon. The image below illustrates this:

In Game Character Icon

This is a very common need. Create a MonoBehaviour script, declare variables as public and assign these controls, and assign the script to a GameObject. The Badge in the upper left corner will also be used in different scenes, so let’s consider the first SubView (BadgeView), where the Bage is placed inside the outermost FaceBoxView.

public class FaceBoxView:UnityUIView<FaceBoxViewModel>
	public Text nameText;
	public Text levelText;
	public Image faceImage;
	public BadgeView badgeView;

Let’s consider what BadgeView will need. The weapon color representing an icon and attribute, hence the BadgeView’s DataModel becomes as follows:

public class Badge
    public string Icon { get; set; }
    public string ElementColor { get; set; }

Speaking for the FaceBoxViewModel, the data it needs are: Name, Level, Face and Badge. Since each of the data here is another data model, we make each of them Bindable.

public class FaceBoxViewModel:ViewModelBase
    public readonly BindableProperty<string> Name=new BindableProperty<string>();
    public readonly BindableProperty<int> Level=new BindableProperty<int>();
    public readonly BindableProperty<string> Face=new BindableProperty<string>();
    public readonly BindableProperty<Badge> Badge=new BindableProperty<Badge>();

    public override void OnStartReveal()

    public void Initialization()
        Name.Value = "Adult Yellow Lamp Killer";
        Level.Value = 31;
        Face.Value = "OmerCECE_Istanbul_31";
        Badge.Value = new Badge() {Icon = "Icon_WeaponRod", ElementColor = "9999FFFF"};

As you can see, Componentization becomes very complicated as the operations increase. The more components of the components, the deeper the nesting becomes. So if an action is not used frequently, it is not recommended to make it “reusable”.