Playmaker Forum
PlayMaker Updates & Downloads => Share New Actions => Topic started by: jeanfabre on August 28, 2012, 03:03:47 AM
-
Hi,
Following a request, please find a get screensize ratio action ( width/height)
// (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
-
Woot! Thank you, Jean! :D
-
Thanks! But how can I now use this to scale the GUI?
-
Thank you Jean! :)
Bye
-
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
-
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
-
Nice, this is an action I was just getting to needing, thx Jean!
-
Very useful for Android :)
Thanks!