Skip to content

Extending the Scene Transition Configuration

C. Plug edited this page Apr 26, 2023 · 4 revisions

You can extend the Switcher.SceneTransitionConfiguration class.

Why?

Extending the configuration class will enable you to control your transition effect. Sometimes, you may want to trigger a different transition depending on where you initiate a transition. Extending the config allows you to save and retrieve a flag to control the transition in your ITransitionBackgroundController implementation.

Where is this accessible?

You most likely want to access your extended class with those methods:

  • ITransitionBackgroundController.TriggerTransitionIn<T>(Switcher.SceneTransitionConfiguration<T> config);
  • ITransitionBackgroundController.TriggerTransitionOut<T>(Switcher.SceneTransitionConfiguration<T> config);

You want to check the type and downcast the extended configuration like so (note the "best practices" section, though!:)

if (config is ExtendedConfig exConfig) {
  // Use exConfig to trigger something
}

Best practices

  • Make sure your extensions don't get too complicated, like a situation where a class is extending another, and some other is extending another.
  • Using interfaces may be a good idea when you want to give multiple extensions different but shared kinds of flags.
    public interface IShowTipConfig {
      bool ShowTip { get; }
    }
  • When implementing your extensions, make use of method chains.
    public YourExtension EnableFlag() {
      Flag = true;
      return this;
    }