private GameObject m_CanvasGameObject; // Used to disable the world space UI during the Starting and Ending phases of each round. public void Setup() { // Get references to the components. m_Movement = m_Instance.GetComponent <TankMovement> (); m_Shooting = m_Instance.GetComponent <TankShooting> (); m_Percepts = m_Instance.GetComponent <TankPercepts> (); m_Health = m_Instance.GetComponent <TankHealth>(); m_CanvasGameObject = m_Instance.GetComponentInChildren <Canvas> ().gameObject; // Set the player numbers to be consistent across the scripts. m_Movement.m_PlayerNumber = m_PlayerNumber; m_Shooting.m_PlayerNumber = m_PlayerNumber; // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number. m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>"; // Get all of the renderers of the tank. MeshRenderer[] renderers = m_Instance.GetComponentsInChildren <MeshRenderer> (); // Go through all the renderers... for (int i = 0; i < renderers.Length; i++) { // ... set their material color to the color specific to this tank. renderers[i].material.color = m_PlayerColor; } }
public void Setup() { // Get references to the components. m_Movement = m_Instance.GetComponent<TankMovement> (); m_Shooting = m_Instance.GetComponent<TankShooting> (); m_Percepts = m_Instance.GetComponent<TankPercepts> (); m_Health = m_Instance.GetComponent<TankHealth>(); m_CanvasGameObject = m_Instance.GetComponentInChildren<Canvas> ().gameObject; // Set the player numbers to be consistent across the scripts. m_Movement.m_PlayerNumber = m_PlayerNumber; m_Shooting.m_PlayerNumber = m_PlayerNumber; // Create a string using the correct color that says 'PLAYER 1' etc based on the tank's color and the player's number. m_ColoredPlayerText = "<color=#" + ColorUtility.ToHtmlStringRGB(m_PlayerColor) + ">PLAYER " + m_PlayerNumber + "</color>"; // Get all of the renderers of the tank. MeshRenderer[] renderers = m_Instance.GetComponentsInChildren<MeshRenderer> (); // Go through all the renderers... for (int i = 0; i < renderers.Length; i++) { // ... set their material color to the color specific to this tank. renderers[i].material.color = m_PlayerColor; } }