1 usingUnityengine;2 usingSystem.Collections;3 4 Public classBgpicscript:monobehaviour {5 6 //Use this for initialization7 Publicuitexture BG;8 voidStart () {9 TenDebug.Log ("Device Height:"+ Screen.width +"_"+screen.height); One AUiroot root = gameobject.findobjectoftype<uiroot>(); - - if(Root! =NULL) the { - //Ultimate Big kill device overall resource scaling - floats = (float) Root.activeheight/Screen.height; - intHeight = mathf.ceiltoint (screen.height *s); + intwidth = mathf.ceiltoint (Screen.width *s); - +Debug.Log ("screen width By design Resolution ="+ width +"_height ="+height); A atDebug.Log ("background Image Design resolution Bgwidth:"+ Bg.width +"_bgheight:"+bg.height); - - floatBgratio = (float) Bg.width/Bg.height; - floatManualratio = (float) Width/height; - - in if(Bgratio < Manualratio)//to zoom in on the background image by width as the black edge appears on both sides of the screen height zoom level - { to //bg.width = width; + //bg.height = mathf.ceiltoint (width/); - the floatTargetscale = (float) Width/Bg.width; *Bg.transform.localScale =NewVector3 (Targetscale,targetscale,1); $ }Panax Notoginseng } - the + } A the //Update is called once per frame + voidUpdate () { - $ } $ } - - the - usingUnityengine;Wuyi usingSystem.Collections; the - Public classUirootscript:monobehaviour { Wu - //Use this for initialization About voidStart () { $ Adaptiveui (); - } - - //Update is called once per frame A voidUpdate () { + the } - $ Static Private voidAdaptiveui () the { the intManualwidth =1024x768; the intManualheight =768; theUiroot Uiroot = gameobject.findobjectoftype<uiroot>(); - if(Uiroot! =NULL) in { the if(System.Convert.ToSingle (screen.height)/screen.width > System.Convert.ToSingle (manualheight)/manualwidth) theUiroot.manualheight = Mathf.roundtoint (System.Convert.ToSingle (manualwidth)/screen.width *screen.height); About Else theUiroot.manualheight =Manualheight; the } theDebug.Log ("uiroot Height:"+uiroot.manualheight); + } -}
Full-screen background zoom in Unity