Skip to content

Continue to support dynamically adding new NetworkBehaviours via AddComponent<>() during Awake() #2744

@zachstronaut

Description

@zachstronaut

If you have Monster:NetworkBehaviour and during it's Awake() you call AddComponent<SkeletonModel>() for a SkeletonModel:NetworkBehaviour everything works out great as if this SkeletonModel was a NetworkBehaviour that already existed. RPCs and NetworkVariables work as expected.

This isn't documented as something you can do, but I'd love to know that y'all officially plan to continue to support this.

Why would somebody do this? Well... Unity Scenes are kind of a real bother for workflow with large teams and large projects. The less you have to change them the better. The less information you have to store in them, the better. This leads programmers to a pattern where the Components on the GameObjects in the Scene are rather non-specific and they dynamically instance their specificity via information stored outside the scene.

Isn't this was Spawning is for? I guess... but Spawning has latency on clients and Spawning requires a new NetworkObject / new Prefab. Being able to just AddComponent your specific NetworkBehaviours at runtime is actually a lot less overhead and less fragile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature, request or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions