void OnPhotonCustomRoomPropertiesChanged(Hashtable props) { foreach (object key in props.Keys) { if (key is string) { var parts = key.ToString().Split('$'); if (parts.Length >= 3) { // Could be one of our properties string id = parts[0] + "$"; int parentId = int.Parse(parts[1]); string path = parts[2]; Hashtable content = (Hashtable)props[key]; NetworkReference nref = NetworkReference.FromIdAndPath(parentId, path); NetworkBehaviour[] comps = nref.FindComponents <NetworkBehaviour>(); foreach (NetworkBehaviour comp in comps) { if (comp.PropKey.StartsWith(id)) { Debug.Log("RVD PROPS: " + content.ToString()); comp.RecvState(content); } } } } } }
void UpdateParent() { var actualNref = NetworkReference.FromTransform(transform.parent); var newNref = NetworkReference.FromIdAndPath(newState.parentId, newState.path); if (actualNref != newNref) { //Debug.Log("Reparenting from " + actualNref + " to " + newNref); GameObject newParent = newNref.FindObject(); //Debug.Log("New parent " + newParent); transform.parent = newParent != null ? newParent.transform : null; } }