Search Unity

Setting All Bits to Dirty

Discussion in 'Multiplayer' started by powdered_swords, Jul 1, 2015.

  1. powdered_swords

    powdered_swords

    Joined:
    Mar 11, 2013
    Posts:
    28
    Does anyone know the quickest way to update all SyncVar values on a NetworkBehaviour?

    The Manual claims that syncVarDirtyBits contains the dirty mask when OnSerialize is called. Does this mean it contains all the bits that have been assigned to SyncVars or is it simply a reference to the currently dirty SyncVars?

    I'm a little confused about how I can use SetDirtyBit() if I don't know which SyncVar field is assigned to which bit in the mask.
     
  2. Hacky

    Hacky

    Joined:
    Mar 22, 2013
    Posts:
    28
    May be it works when you set the dirtyBit to int.MaxValue.
     
  3. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    why do you want to set all the bits to dirty?
     
  4. powdered_swords

    powdered_swords

    Joined:
    Mar 11, 2013
    Posts:
    28
    In order to force a refresh of all values in a NetworkBehaviour. Say for instance if I was simulating on the client end and needed to revert those variables to whatever was present on the server.
     
  5. SuperNeon

    SuperNeon

    Joined:
    Mar 16, 2014
    Posts:
    85
    You can try this SetDirtyBit(0xFFFFFFFF)
     
  6. powdered_swords

    powdered_swords

    Joined:
    Mar 11, 2013
    Posts:
    28
    Thx I'll see if that works
     
  7. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    that will make the object dirty for ALL clients...