VTubeTiny icon indicating copy to clipboard operation
VTubeTiny copied to clipboard

Components under a "Publisher" will not get a published value

Open HugoVG opened this issue 2 years ago • 1 comments

let's say we this stack of components image it should notify CharacterAnimatorComponent and SpeakingColorChangerComponent image but currently it will not notify SpeakingColorChangerComponent image Why does it do that? most components will Start once, and that's when they are made

public override void Start()
{
    _components = GetComponents<ISpeakingAwareComponent>(); //<--- 
    //...
}

after that they will never update.

Solution

On new Component Update all previous components.

Potentential issues

A component might do a "Should only happen once" event twice

HugoVG avatar Apr 16 '23 14:04 HugoVG

Hmm, a potential solution I can think of, is that when we initialize all of the components for an actor, we call Start for all of them only after we've created all of them. This way, we can ensure that all of the components have been created before we call the Start methods for them, which would solve this issue for the case when we load in a scene.

For the editor however, we can potentially create some sort of ICreationAwareComponent interface, where components that implement it will get updates whenever a new component gets created within the actor.

purifetchi avatar Apr 16 '23 16:04 purifetchi