playMaker

Author Topic: GUI index of (char) and CalcSize  (Read 9006 times)

kiriri

  • Hero Member
  • *****
  • Posts: 506
GUI index of (char) and CalcSize
« on: June 20, 2012, 04:26:01 PM »
hey,
I need to separate 1 string into 3 as following:
string 1 needs to be from the beginning of the string to the x-th space
string 2 needs to be from the x-th space to the n-th space.
string 3 needs to be the rest.

I thought I could realize this by first writing an index of (char) action, and then getting the substrings based on the index.
However, there's scarcely even a single sentence about this on the api reference and I am somehow not getting started :S .
On top of that I want to output the strings as if they were one string, so I need to calculate their size, which I recon GUIStyle.CalcSize can do. But how can I reference a GUI to it? It's not like there are any GUI-variables in PlayMaker, so I'm somewhat at a loss.
I would really appreciate some help :)

Thanks,
kiriri
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #1 on: June 21, 2012, 02:07:40 AM »
Hi,

 you should look at this thread for splitting string into an array and work with it then.

http://hutonggames.com/playmakerforum/index.php?topic=891.0

I would split your string in an array, and then access your 3 chunks conveniently with indexing in the array for the xth and nth split.

As for the calcsize, I guess i'ts going to be tricky in playmaker, I don't see right now how this can be achieved, maybe someone will step in with a solution.

bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: GUI index of (char) and CalcSize
« Reply #2 on: June 21, 2012, 12:46:45 PM »
wow that worked perfectly! I really have to learn all your awesome arrayMaker actions by heart :D
Now I'll just have to find a way to print the three strings as one flawless line... Anyways, thansk a lot, your action has brought me a lot closer to the goal :)
Best,
Sven

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: GUI index of (char) and CalcSize
« Reply #3 on: June 21, 2012, 02:47:50 PM »
since I desperately need this calcSize to work, I thought I could achieve it by implementing it directly into the GUILabel FSM. However, as always, I'm having a lot of difficulties. Why isn't the following working?
Code: [Select]
GUILayout.Label(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions);
GUIStyle go = style.Value;
Vector2 size = go.CalcSize(GUIContent);
Sorry about my incomprehension, I really haven't quite grasped the concept of converting variables between playmaker and unity and the lack of any example for this function doesn't make it easier :S
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #4 on: June 21, 2012, 03:42:04 PM »
Hi,

Yeah, ArrayMaker is mandatory in my opinion :) I made it because I needed it. Working with array is at the core of any programming whatever the subject.

 re calcsize, Allow me few days to work on that, I am sure we can work something out.

 bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: GUI index of (char) and CalcSize
« Reply #5 on: June 22, 2012, 10:29:09 AM »
sounds great! For now I'll just have to write a hardcode script for the GUI print, but I fear that my employer wouldn't like it so I really am glad you're giving everyone such a great support :)
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #6 on: June 23, 2012, 04:06:21 PM »
Thanks,

 and don't hesitate to get back to me if I forget, the forum and demand it getting bigger and bigger, can't keep up now  ;D

 bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: GUI index of (char) and CalcSize
« Reply #7 on: June 25, 2012, 10:20:35 AM »
undoubtably understandable ;)
That's btw also the reason why I'm bumping my posts all the time. I'm normally no bumper you see.
So asking bluntly: Has anyone created a way of doing this? I know I have some actions lying around which I never share because they're to specific to help anyone but me.. maybe someone has made this already ?  :-\
« Last Edit: June 25, 2012, 10:26:56 AM by kiriri »
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #8 on: June 26, 2012, 02:36:32 AM »
Hi,

 Ok, not really able to find a way out of this as a pur action because I can't access GUIStyles. the GUIStyle is not a type that can be displayed in the action interface and it's not a type we can reference in a FSMObject variable so currently I am stuck with this, I can't see a way to do this with playmaker only unfortunatly.

 Bye,

 Jean

kiriri

  • Hero Member
  • *****
  • Posts: 506
Re: GUI index of (char) and CalcSize
« Reply #9 on: June 26, 2012, 11:49:58 AM »
I see... maybe Alex can do something about this? Until then I surrender and stick to my hardcode for this :S
Is it possible to move this to the feature request forum?
Best,
Sven

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #10 on: June 26, 2012, 12:06:31 PM »
Hi,

 I sent an email about this to Alex already, we'll see.

 I hope for future update where we will have complete control over the action interface, that will open new perspective, basically allowing very powerful action ui.

bye,

 Jean

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 4003
  • Official Playmaker Support
    • LinkedIn
Re: GUI index of (char) and CalcSize
« Reply #11 on: July 01, 2012, 08:52:36 PM »
since I desperately need this calcSize to work, I thought I could achieve it by implementing it directly into the GUILabel FSM. However, as always, I'm having a lot of difficulties. Why isn't the following working?
Code: [Select]
GUILayout.Label(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions);
GUIStyle go = style.Value;
Vector2 size = go.CalcSize(GUIContent);
Sorry about my incomprehension, I really haven't quite grasped the concept of converting variables between playmaker and unity and the lack of any example for this function doesn't make it easier :S

Sorry for the delay. You're on the right track here, but you need to get the GUIStyle given its name:
http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle-operator_GUIStyle.html

So this should work (untested):
Code: [Select]
// create the GUIContent
GUIContent guiContent = new GUIContent(text.Value, image.Value, tooltip.Value);

// get the named style from the current skin
GUIStyle style = GUIStyle(style.Value);

// get the size of the content if drawn with this style
Vector2 size = style.CalcSize(guiContent);

When I get a chance I'll make a CalcSize action, or maybe add Store Size to the GUI actions...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: GUI index of (char) and CalcSize
« Reply #12 on: July 02, 2012, 03:26:55 AM »
Hi,


 Thanks Alex, I missed that operator! the action is now up:

http://hutonggames.com/playmakerforum/index.php?topic=1864.0

a series of similar function is available, if you need them, don't heistate to request them:
http://docs.unity3d.com/Documentation/ScriptReference/GUIStyle.html

Bye,

 Jean