public void SetPlayerLooksAndColour(GameObject playerInstance, int playerNumber) { playerInstance.GetComponent <EntityStatsController>().characterColour = _playerSlots[playerNumber].characterColour; Material playerMaterial = new Material(Shader.Find("Custom/Outline")); playerMaterial.SetFloat("_Outline", 0.0005f); playerMaterial.SetColor("_OutlineColor", colours.GetColour(_playerSlots[playerNumber].characterColour)); playerMaterial.SetTexture("_MainTex", _playerSlots[playerNumber].characterChoice.skin); playerInstance.GetComponentInChildren <Renderer>().sharedMaterial = playerMaterial; }
private void Start() { // Assign players their correct colour outline // TODO Perhaps materials should be dynamically assigned elsewhere? foreach (GameObject player in Players) { // Dynamically assign each player their respective outline texture Color playerColour = colours.GetColour(player.GetComponent <EntityStatsController>().characterColour); Material playerMaterial = new Material(Shader.Find("Custom/Outline")); playerMaterial.SetFloat("_Outline", 0.0005f); playerMaterial.SetColor("_OutlineColor", playerColour); playerMaterial.SetTexture("_MainTex", testPlayerTexture); player.GetComponentInChildren <Renderer>().sharedMaterial = playerMaterial; } }