Пример #1
0
        public static void Init()
        {
            GameObject netCanv = NetworkManager.main.gameObject;

            main = netCanv.AddComponent <ModUI>();

            if (PlayerPrefs.HasKey("ShowButton"))
            {
                main.showButton = PlayerPrefs.GetInt("ShowButton") == 1;
            }
        }
        // Init methods
        public void Awake()
        {
            main = this;
            InitializePhoton();
            GameHooks.Init();
            ModUI.Init();
            PhotonNetwork.OnEventCall += NetworkCallbacks.OnPhotonEvent;
            if (SteamAPI.IsSteamRunning())
            {
                PhotonNetwork.playerName = SteamFriends.GetPersonaName();
                ModUI.main.playerName    = PhotonNetwork.playerName;

                int friendCount = SteamFriends.GetFriendCount(EFriendFlags.k_EFriendFlagImmediate);
                friends = new List <string>();
                for (int i = 0; i < friendCount; i++)
                {
                    CSteamID friend = SteamFriends.GetFriendByIndex(i, EFriendFlags.k_EFriendFlagImmediate);
                    string   name   = SteamFriends.GetFriendPersonaName(friend);
                    friends.Add(name);
                    steamFriendNames.Add(name);
                }
            }
            if (PlayerPrefs.HasKey("NonSteamFriends"))
            {
                try
                {
                    nonSteamFriendNames = JsonUtility.FromJson <FriendList>(PlayerPrefs.GetString("NonSteamFriends")).friendNames.ToList();

                    friends.AddRange(nonSteamFriendNames);
                }
                catch
                {
                }
            }

            PhotonNetwork.AuthValues = new AuthenticationValues(PhotonNetwork.playerName);
            ConnectToLobby();
        }