Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Damian on February 14, 2012, 10:21:10 AM
-
I try to figure out how to do this thing.
What I want to do is following.
I want to have a button and when I press it a GUItext shall fill the screen.
The GUItext will have a bigger text then the screen so it must have a scroll sidebar.
I hope I can use only playmaker for this. It would then be easy to copy it on every place I need it.
-
Well I guess I have to answer my own question.
If you use normal script you can use following
var scrollPosition : Vector2;
private var longString = "Here you write all the text you want to show";
function OnGUI () {
scrollPosition = GUILayout.BeginScrollView (
scrollPosition, GUILayout.Width(Screen.width), GUILayout.Height(Screen.height - 100));
GUILayout.Label (longString);
GUILayout.EndScrollView ();
if (GUILayout.Button ("Exit"))
Application.Quit();
}
This basic code do work like I wan to.
What it does is to fill the screen with the text and ad a side scroll if the text is to big.
If you use a different size on the view instead for the full screen I do you can use it in small info(popup) windows.
The GUILayout.BeginScrollView setup the windows and all things needed.
Bellow this you can add GUILayout.Label, GUILayout.Button or what you want to show.
Then you just end it with GUILayout.EndScrollView ().
I have looked through playmaker actions, but I do not find those anyway.
So I think those should be added to :)
-
it will be cool if you or someone else can build a custom action from the above code using the new Wizard tool! It will be good to show the power of this new tool.
-
i start making custom action!
using UnityEngine;
using System.Collections;
namespace HutongGames.PlayMaker.Actions{
public class GUILabelWithScroll_C : GUIContentAction {
Vector2 scrollPosition;
public bool center = false;
public override void OnGUI(){
base.OnGUI();
/*int width = Screen.width/2;
int height = Screen.height/2;
if ( this.height != 0 ) height = this.height;
if ( this.width != 0 ) width = this.width;*/
//Debug.Log(screenRect.Value.x + " " + screenRect.Value.y + " " + screenRect.Value.height +" " + screenRect.Value.width);
if ( rect.height > Screen.height ) rect.height = Screen.height-20;
/*
if ( center )
{
rect.y *= screenRect.Value.y*2;
//rect.height *= Screen.height;
}
*/
GUI.BeginGroup(rect);
scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUILayout.Width(rect.width), GUILayout.Height(rect.height));
GUILayout.Label (content);
GUILayout.EndScrollView ();
GUI.EndGroup();
/*
GUI.BeginScrollView(new Rect(100, 50, 400, 400), scrollPosition, new Rect(0, 0, 100, 200));
GUI.Label(new Rect(0, 0, 100, 100), content);
GUI.EndScrollView();
*/
}
}
}
It's a bit mess.. but is my first HACK!
-
Good you try it out.
But you should make it more flexible.
I think to use static value is not a good idea.
Also this action should be splitted up so you have one start action and one end action and you can then put all other things in between them.
The code script I did show is also very static, but it can easy be flexible.
But the playmaker has all action needed for this accept for the GUIscrollview stuff.
I do write an app now and I would love to have this in playmaker, but its very easy for me to use my script to.
But I would like that done in playmaker, so my whole app is made by playmaker. :-)
-
Have worked with this on a new project.
No most support is in Playmaker, but still I can not find anything to change Vector2 stuff.
There is vector3, but you can not use that.
If I use GUILayout Begin Scroll view I can use all stuff I need, but I can not find anything to change the Vector2 (Scroll Position), that I think is the scrollbar.
What I want is a way to change the scrollbar so the screen will move and show what is now hidden.
Right now I have no more idea how to scroll this view. The thing is that I want to use the touch controll to change the scroll view so you can swipe the screen and the gui will move.
Its kind of basic stuff that should be in playmaker. After all if you put a text in the scroll view you want a good way to scroll the text.
-
Hi,
what kind of action you would need for vector2 control?
bye,
Jean