Search Unity

Resolved Baking Scene Object Network IDs

Discussion in 'Multiplayer' started by davej256, Dec 9, 2022.

  1. davej256

    davej256

    Joined:
    Nov 11, 2022
    Posts:
    17
    Quick question.

    The client and the server will need a way to differentiate existing scene objects between each other, for example doors on a building. When should these IDs get baked?

    Currently I just have an editor script that goes through every scene object, checks if it contains my network class, writes an ID to it and then saves the scene. Performance-wise, is it fine to run this on the EditorApplication.hierarchyChanged event? Or should I be doing this a different way?

    Any feedback is appreciated.
     
  2. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    Hi, what network framework are you using?
     
  3. davej256

    davej256

    Joined:
    Nov 11, 2022
    Posts:
    17
    I'm building one :)

    I think I found my answer after a few hours of digging last night. It seems that PostProcessSceneAttribute is where this should be done, since it gets called at the start of editor play mode, and right before a build.

    For anyone in the future confused about PostProcessSceneAttribute, When you assign a value to a scene object's class during this phase, the values get baked into the build itself, and NOT the editor as well. Took me a while to figure out what was happening since the docs don't mention anything about this.
     
    RikuTheFuffs-U likes this.