/// <summary> /// Sets the session information associated with this button /// </summary> /// <param Name="sessionInfo">The session info</param> public void SetSessionInfo(NetworkDiscoveryWithAnchors.SessionInfo sessionInfo) { SessionInfo = sessionInfo; if (SessionInfo != null) { textMesh.text = string.Format("{0}\n{1}", SessionInfo.SessionName, SessionInfo.SessionIp); if (SessionInfo == scrollingUIController.SelectedSession) { textMaterial.SetColor(textColorId, Color.blue); textMesh.color = Color.blue; } else { textMaterial.SetColor(textColorId, Color.yellow); textMesh.color = Color.yellow; } } }
/// <summary> /// Updates which session is the 'top' session in the list, and sets the /// session buttons accordingly /// </summary> /// <param Name="Direction">are we scrolling up, down, or not scrolling</param> public void ScrollSessions(int Direction) { int sessionCount = sessionList == null ? 0 : sessionList.Count; // Update the session index SessionIndex = Mathf.Clamp(SessionIndex + Direction, 0, Mathf.Max(0, sessionCount - SessionControls.Length)); // Update all of the controls for (int index = 0; index < SessionControls.Length; index++) { if (SessionIndex + index < sessionCount) { SessionControls[index].gameObject.SetActive(true); NetworkDiscoveryWithAnchors.SessionInfo sessionInfo = sessionList.Values.ElementAt(SessionIndex + index); SessionControls[index].SetSessionInfo(sessionInfo); } else { SessionControls[index].gameObject.SetActive(false); } } }
/// <summary> /// Sets the selected session /// </summary> /// <param Name="sessionInfo">The session to set as selected</param> public void SetSelectedSession(NetworkDiscoveryWithAnchors.SessionInfo sessionInfo) { SelectedSession = sessionInfo; // Recalculating the session list so we can update the text colors. ScrollSessions(0); }