After adding Request For Mirror to your project, it’s time to make your first request!

Creating Requests

To create a basic module, simply derive from Module class. As we imagine, a module should represent a relatively small self-contained part of your bigger entity/behaviour. Some examples, these things could become good modules:

  • Engine/Transmission of a car
  • Camera setup for the player
  • Shooting logic for guns in your awesome FPS ;)

I’ve made a blog post, which uses less formal language and also digs deeper into the concept. Could really recommend reading it, especially if you want the answers to these questions:

  • What’s the concept in easy words
  • These concepts are easy as a self-made solutions, why Modula?

Read post

Making example behaviour

Step 1 - create new main script that supports modules:

  • Create new MonoBehaviour script
  • use namespace Modula
  • change inheritance to ModularBehaviour
using Modula;


public class ModularExample : ModularBehaviour
{

}

Step 2 - create your first module

  • Create new MonoBehaviour script
  • use namespace Modula
  • change inheritance to Module
using Modula;


public class ExampleModule : Module
{

}

Step 3 - add support for ExampleModule in ModularExample

  • Get back to your behaviour script
  • Override AvailableModules field
public class ModularExample : ModularBehaviour
{
    public override TypeList AvailableModules { get; } 
        = new TypeList()
        .Add(typeof(ExampleModule));
}

Step 4 - create GameObject for your new behaviour

  • in Unity, go to Hierarchy window > “+” > Create Empty
  • select the created object
  • click “Add Component” > ModularExample

Done! now you can add or remove your module in Inspector window by clicking “Add ExampleModule” / “Remove”

Result

result image