Hi everyone,
I'm a bit of a StrangeIOC newbie, but I've been getting up to speed on everything recently, and understand the fundamentals.
I've encountered a Problem I'm sure is a very simple one yet i'm not able to see why i'm running into it.
Lets say In a small game i have a CreateMonsterSignal that is bound to a CreateMonsterCommad .
The signal is dispatched when i Click a button.
the CreateMosterCommand instantiates a prefab from my resources
The Prefab has a MosterVIew attached to it .I've bound the view to MonsterMediator in my game context.
The problem is My MonsterMediator is not attached to the prefab after i call CreateMosterCommand.
I am under the impression that Strange automatically binds and attaches the Mediator to the view i.e It get attached to the GameObject. Please point out my mistake.
Game Context
public class GameContext : SignalContext
{
public GameContext (MonoBehaviour contextView) : base (contextView)
{
}
protected override void mapBindings ()
{
base.mapBindings ();
//other commands and signals
commandBinder.Bind<CreateMonsterSignal> ().To<CreateMonsterCommand> ();
mediationBinder.Bind<MonsterView> ().To<MonsterMediator> ();
}
public override void Launch ()
{
injectionBinder.GetInstance<StartGameSignal> ().Dispatch ();
}
}
MonsterMediator
using System;
using strange.extensions.mediation.impl;
public class MonsterMediator: Mediator
{
[Inject]
public MonsterView MonsterView { get; set; }
[Inject]
public PlayMonsterAnimationSignal PlayMonsterAnimationSignal { get; set;}
public override void OnRegister ()
{
MonsterView.Initialize ();
PlayMonsterAnimationSignal.AddListener (PlayMonsterAnimation);
}
public override void OnRemove ()
{
PlayMonsterlAnimationSignal.RemoveListener (PlayMonsterAnimation);
}
public void PlayMonsterAnimation()
{
// Do some animation
}
}