playMaker

Author Topic: Get Screen size ratio  (Read 6378 times)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Get Screen size ratio
« on: August 28, 2012, 03:03:47 AM »
Hi,

 Following a request, please find a get screensize ratio action ( width/height)

Code: [Select]
// (c) Copyright HutongGames, LLC 2010-2012. All rights reserved.

using UnityEngine;

namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Application)]
[Tooltip("Gets the Screen size ratio (width/height).")]
public class GetScreenSizeRatio : FsmStateAction
{
[RequiredField]
[UIHint(UIHint.Variable)]
[Tooltip("The Screen size ratio (width/height).")]
public FsmFloat storeScreenSizeRatio;

public override void Reset()
{
storeScreenSizeRatio = null;
}

public override void OnEnter()
{
storeScreenSizeRatio.Value = 1f*Screen.height/Screen.width;
Finish();
}

}
}

 bye,

 Jean

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Get Screen size ratio
« Reply #1 on: August 28, 2012, 11:25:03 AM »
Woot! Thank you, Jean! :D

SubZero

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Get Screen size ratio
« Reply #2 on: August 30, 2012, 05:53:26 AM »
Thanks! But how can I now use this to scale the GUI?

Dev_Sebas

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 398
    • Blog
Re: Get Screen size ratio
« Reply #3 on: August 30, 2012, 11:31:04 AM »
Thank you Jean! :)
Bye

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Get Screen size ratio
« Reply #4 on: August 31, 2012, 03:46:22 AM »
Hi,

 scaling GUI : what gui system are you using and what kind of scaling you are after. do you need layout modifications or a true scaling completly tight to the screensize? It would be good if you can provide more precision on that so that we can answer something useful.

bye,

 Jean

SubZero

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Get Screen size ratio
« Reply #5 on: August 31, 2012, 06:28:48 PM »
Sure! Basically just using the built in OnGUI system provided by Playmaker and Unity.

Might be the case that I still don't have a clue how this all works (regarding the UI) but I did the following:

I setup an FSM to display a variety of buttons and labels to populate the main menu of my game. The hole setup was done in full hd resolution, however if I now switch the resolution to something lower than full hd the whole UI (Buttons, Labels and Sliders) kind of loose their screen positions and in rare cases are off screen.

I have to admit that I am a littlebit alone in the dark when it comes to GUI scripting and setup.

bye,
Sub

reedomatic

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Get Screen size ratio
« Reply #6 on: September 02, 2012, 10:00:32 AM »
Nice, this is an action I was just getting to needing, thx Jean!

markinjapan

  • Full Member
  • ***
  • Posts: 103
Re: Get Screen size ratio
« Reply #7 on: September 02, 2012, 12:26:27 PM »
Very useful for Android  :)

Thanks!