Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JScotty · Jun 05, 2014 at 11:06 AM · c#androidtexturescalewidth

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");
                 
   }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by kilian277 · Jun 05, 2014 at 11:13 AM

You can assign background texture to your button with a GUIStyle in the inspector

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JScotty · Jun 05, 2014 at 11:24 AM 0
Share

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: alt text

there will be still a white box on it..

whitebox.png (226.7 kB)
avatar image kilian277 · Jun 05, 2014 at 11:27 AM 0
Share

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)

avatar image kilian277 · Jun 05, 2014 at 11:28 AM 0
Share

And keep the texture on the normal section

avatar image JScotty · Jun 05, 2014 at 11:36 AM 0
Share

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..

avatar image
0

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image kilian277 · Jun 05, 2014 at 03:23 PM 0
Share

You should set this answer as "solution" ;)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Texture not covering whole paddle after built 1 Answer

Unity5.0 material not assigned on android 1 Answer

Distribute terrain in zones 3 Answers

how to make high quality textures with low size of downlaod 1 Answer

Set width and height of 2D gameobject in PIXELS 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges