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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by ZoomStar · Mar 18, 2014 at 02:53 AM · androidsizebackgroundunity-android

Android Auto scale backgorund for any resolution

hi...i hope to make now a good question because in 2 weeks i didn`t found a good Answard for this...

So, my 2d game in unity for android is almost ready, but...when i test this app on S4, and another 5 divices(with android) my background have a bad scale,

i mean or is too big, or too small i try to use sprites, GUItexture, code, Quad, cube, ALL stuff...

but is same everytime....

NOTE: my orthographic camere have size set to 10... Note(2): sorry for my bad english

Comment
Add comment · Show 5
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 Adamcbrz · Mar 18, 2014 at 03:32 AM 0
Share

Can you post some screen shots?

avatar image Santosh Patil · Mar 18, 2014 at 05:21 AM 0
Share

Follow the instruction below, GameObject->CreateOther->GUI Texure

You will see the UnityWatermark on screen, now select the the texture and goto inspector menu add your Texture to GUITexture.

To fit GUITexture to any screen size make x and y scale factor 1.

avatar image ZoomStar · Mar 18, 2014 at 08:23 AM 0
Share

I made this 2 days a go but the texuture is now over my character, and hazards, and i can't(or i don' now how) send to back....

avatar image Santosh Patil · Mar 18, 2014 at 08:39 AM 0
Share

make Texture's z position value greater than character.

avatar image ZoomStar · Mar 18, 2014 at 08:50 AM 0
Share

I made it, but nothing change

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by selvap · Mar 18, 2014 at 09:21 AM

the best way to fit the gui texture on every screen is :

Try the follwing this...its works for every screen aspect ratio even for both ios android.

Steps:

1.Create a GUITexture. 2.In GUITexture parameter keep pixel inset to 0.(for everything). 3.Adjust the position and scale value in in Transform inspector. 4.then use this script

using UnityEngine; using System.Collections;

public class GUI_Controller : MonoBehaviour { public Vector2 scaleOnRatio1 = new Vector2(0.1f, 0.1f); private Transform myTrans; private float widthHeightRatio;

void Start () { myTrans = transform; SetScale(); }

void SetScale() { //aspect ratio widthHeightRatio = (float)Screen.width/Screen.height;

 //Apply the scale. We only calculate y since our aspect ratio is x (width) authoritative: width/height (x/y)
 myTrans.localScale = new Vector3 (scaleOnRatio1.x, widthHeightRatio * scaleOnRatio1.y, 1);

}

} 5.Adjust the scale ratio in script transform... 6.TA ta i....i will works like boss..

thank u..

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 ZoomStar · Mar 18, 2014 at 11:10 AM 0
Share

I will try your script and come back here with my test resoults

avatar image
0

Answer by HariKrishnan · Mar 18, 2014 at 08:46 AM

first you will designed for small device. in script you will type the method in update Screen.SetResolution(480,800,true); then you will deployed in different devices then automatically resize.....

Comment
Add comment · Show 3 · 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 ZoomStar · Mar 18, 2014 at 08:49 AM 0
Share

i try that0 and when you plah my app on s4 s3 ....the graphics are very bad!!!!

avatar image Santosh Patil · Mar 18, 2014 at 09:02 AM 0
Share

@ZoomStar are you using sprite for bg? if yes then use bellow script, drag and drop bg sprite to BG GameObject. using UnityEngine; using System.Collections;

public class BgTest : $$anonymous$$onoBehaviour {

 // Use this for initialization
 public GameObject BG;
 void Start () 
 {
     BG.transform.localScale = new Vector3(Screen.width,Screen.height);
 }
 
 // Update is called once per frame
 void Update () {
 
 }

}

avatar image ZoomStar · Mar 18, 2014 at 09:12 AM 0
Share

I put this script and now the bg is huge....not fit in my screen size

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

23 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 avatar image

Related Questions

AndroidJavaProxy no such method exception,AndroidJavaProxy no such proxy method error 2 Answers

Android APK size way too large 2 Answers

Could a mobile app have a service application compiled targetting a higher version of .net? 0 Answers

Can I make my Android game close if you leave the game on the title screen? 1 Answer

How to make my game fit into my droid? 1 Answer


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