- Home /
Question by
aidangig56 · Jun 04, 2015 at 02:09 PM ·
c#guitexturematerial
How to change texture of Gameobject/Player
Hey,
I am wanting to change my player's material of his face,the player is a gameobject. The GameObject "Player is linked to his face. It has texture variables for the GUIButton. Look at the code below:
using UnityEngine;
using System.Collections;
public class PlayerCusomtization : MonoBehaviour {
public GameObject Player;
public Texture btnsteve;
public Material steve;
public Material creeper;
public Texture btncreeper;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnGUI() {
if (GUI.Button(new Rect(10, 10, 50, 50), btnsteve))
Debug.Log("Clicked the button with an steve");
if (GUI.Button(new Rect(75, 10, 50, 50), btncreeper))
Debug.Log("Clicked the button with an creeper");
Player = Material (steve);
}
}
How do I get the OnGUI Button steve to be clicked to change his face mat.
Comment
Your answer
Follow this Question
Related Questions
Help with understanding UV's in script created mesh 0 Answers
GUI Label "flash a Arrow" 1 Answer
Texture2D not showing in build, but shows up in editor 1 Answer
C# GUI Button 2 Answers