- Home /
Texture2D Width problem - C# Android school project
Hello i am a Game Development Student from Media College Amsterdam.
I have a little problem with scaling my button texture...
I try'd jumpTexture = new Texture(Screen.Width/2, Screen.height/3);
when i use this it will remove my texture and will fill it with white..
if some one knows how i can scale my texture would be awesome! :D
my texture code is:
public GUIStyle style;
public Texture2D jumpTexture;
public Texture2D catchTexture;
void Start(){
jumpTexture = new Texture2D(Screen.width/2,Screen.height/3);
}
void OnGUI(){
GUI.skin.button = style;
GUILayout.RepeatButton ("");
if (GUI.RepeatButton (new Rect (20, 0,jumpTexture.width, jumpTexture.height),jumpTexture)) {
print("jumping");
}
}
Answer by kilian277 · Jun 05, 2014 at 11:13 AM
You can assign background texture to your button with a GUIStyle in the inspector
Can you complain wich one i need to use because if i use the normal and change the background texture it will looks like this:
there will be still a white box on it..
Remove the line of the jumpTexture at the Start method and assign ints to the width and height of the new Rect(x,y,width,height)
if i do that it wont be shown at a smaller android phone.. so that is why i want to scale it to Screen.width/2 because that will work on all devices..
Answer by JScotty · Jun 05, 2014 at 12:57 PM
I have found it i use Resize now but that didnt worked because i didnt made the settings readable.. Thanks for your help Killian227