playMaker

Author Topic: GUI text scroll  (Read 5504 times)

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
GUI text scroll
« 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.

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: GUI text scroll
« Reply #1 on: February 15, 2012, 06:28:15 PM »
Well I guess I have to answer my own question.
If you use normal script you can use following

Code: [Select]
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 :)

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: GUI text scroll
« Reply #2 on: February 15, 2012, 08:46:34 PM »
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.

elvis75k

  • Beta Group
  • Junior Playmaker
  • *
  • Posts: 97
    • nRender
Re: GUI text scroll
« Reply #3 on: February 16, 2012, 12:19:24 PM »
i start making custom action!

Code: [Select]
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!

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: GUI text scroll
« Reply #4 on: February 16, 2012, 12:38:23 PM »
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. :-)

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: GUI text scroll
« Reply #5 on: September 01, 2012, 02:13:58 PM »
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.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI text scroll
« Reply #6 on: September 03, 2012, 04:38:35 AM »
Hi,

 what kind of action you would need for vector2 control?

bye,

 Jean