Question by
Gaming-Dudester · Apr 27, 2016 at 01:31 AM ·
c#screenanchorfit
game not fitting in phone screen
I made a game for smartphones. it is free aspect. I play it on my iphone 4 and it fits fine. but on iphone 5 I can see my skybox behind the game. the gui parts are anchored fine so they work good. but not the game. is there a way to make anchors on my gameobjects that aren't gui?
Comment
Best Answer
Answer by birns92 · Apr 27, 2016 at 04:38 AM
Apply this script to your main camera:
using UnityEngine;
using System.Collections;
public class resolution : MonoBehaviour {
private float nearClipPlane = 0.3f ;
private float farClipPlane = 1000;
public float orthographicSize = 5;
public float aspect = 2.25f;
void Start ()
{
Camera.main.projectionMatrix = Matrix4x4.Ortho (
-orthographicSize * aspect, orthographicSize * aspect,
-orthographicSize, orthographicSize,
nearClipPlane, farClipPlane);
}
}
You may need to adjust the values of the orthographic size & aspect size to fit your camera but hopefully that does the trick for you!
Your answer
Follow this Question
Related Questions
Why my Scale Script don't work ? 1 Answer
Google play services won't start. 0 Answers
Setting anchors in RectTransform making panel appear to vanish 1 Answer
UnLock and Show Cursor 1 Answer
Scale a sprite horizontally as well. 1 Answer