Something like this should work: Code (CSharp): public GameObject SomeObject; float NewScaleX = 0.5f; float NewScaleY = 2.0f; SomeObject.transform.localScale = new Vector2(NewScaleX, NewScaleY);
hmm but I want scale objects to fit on any resolution phone. ( Scale with screen size). Sorry for the vague question.
How about this, then?: Code (CSharp): public GameObject SomeObject; float NewScale1 = 0.2f; float NewScale2 = 0.4f; int ScreenWidth = Screen.width; int ScreenHeight = Screen.height; void Update () { if (Input.GetKeyDown(KeyCode.DownArrow)) { SomeObject.transform.localScale = new Vector2( NewScale1*ScreenWidth, NewScale1*ScreenHeight); } if (Input.GetKeyDown(KeyCode.UpArrow)) { SomeObject.transform.localScale = new Vector2( NewScale2*ScreenWidth, NewScale2*ScreenHeight); } }
It does not work because I need the scripts on the phone, so that game objects scale all in accordance with the size of the screen.
What do you mean by that? Are you trying to run it on iOS? It should get the resolution of the device that it runs on.
I try to run it on Android, but i really don't know how to rescale game objects to work on any size phone. I made a 2D game.
Drop this line on your camera object my friend It will do the trick Code (CSharp): GetComponent<Camera>().orthographicSize = (20.0f / Screen.width * Screen.height / 2.0f);