Как синхронизировать двумерный массив в unity3d с помощью Photon?

public class UnitManager : MonoBehaviour
{
// массив юнитов
private Unit[,] unitPos;
PhotonView photonView;

private void Start()
    {
        PhotonView photonView = GetComponent<PhotonView>();
    }

public void CreatedUnits()
    {
        if (PhotonNetwork.IsMasterClient)
        {
            for (int x = 0; x < 7; x++)
            {
                for (int y = 0; y < 2; y++)
                {
                    GameObject currentGameObject = PhotonNetwork.Instantiate(_unitPrefab.name, new Vector2(x, y), Quaternion.identity);
                    Unit currentUnit = currentGameObject.GetComponent<Unit>();
                    currentUnit.isFriendly = true;
                    `friendlyUnits.Add(cu`rrentUnit);
                    unitPos[x, y] = currentUnit;
                }
            }
            
        }
        else
        {
            for (int x = 0; x < 7; x++)
            {
                for (int y = 4; y < 6; y++)
                {
                    GameObject currentGameObject = PhotonNetwork.Instantiate(_unitPrefab.name, new Vector2(x, y), Quaternion.identity);
                    Unit currentUnit = currentGameObject.GetComponent<Unit>();
                    currentUnit.isFriendly = false;
                    enemyUnits.Add(currentUnit);
                    unitPos[x, y] = currentUnit;
                }
            }
        }      
    }
}

// Подскажите, как мне сделать так, чтобы данные в массиве unitPos были одинаковые для всех игроков с помощью PhotonUnityNetwork?


Ответы (0 шт):