Skip to content

Extending the Scene Transition Configuration

Collapsed Plug edited this page May 26, 2022 · 4 revisions

You mcan 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 transitions depending on where you trigger a transition. By extending the config, you can save retrieve a flag to control the transition in your ITransitionBackgroundController implementation.

Where is this accessible?

You most likely want to access your extended class in 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 class extending another and some other 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;
    }
Clone this wiki locally