|
Hi, i'm trying to create a very simple GUI with Unity, here is my javascript code:
when the script is 'compiled' it gives me the following error:
when i add a style to the BeginVertical constructor, like this:
the error goes away... in the script reference guide, it is said that the style is an optional argument why do i have to explictly provide the style argument for it to work? i'm using Unity 3.1.0f3 (54715) if that can help Thanks a lot NB: i'm building a unity GUI generation framework so it's not just me not wanting to provide the "style" argument. The thing is: the framework isn't supposed to generate this argument when the user didn't supply a style attribute for a BeginVertical element
(comments are locked)
|
|
According to the script reference, it's not optional: http://unity3d.com/support/documentation/ScriptReference/GUILayout.BeginVertical.html
The one in question being the last one, which takes a GUIContent, a style, and a variable number of GUILayoutOptions but have a look at the style argument description: style The style to use for background image and padding values. +++If left out, the background is transparent.+++ so it actually appears to be optional! look at the "text/style/options" construct for example. If i just provide a text argument and no style, it works!
Mar 15 '11 at 11:13 PM
nOne
(comments are locked)
|
|
Thanks a lot for your help Mike, but it didn't really answer my question. As explained in my previous comment, the script reference guide says about the 'style' argument:
and when i use the text/style/options constructor, like this:
it works! i don't have to provide the style argument for it to work! why is there such a discrepancy between the two constructors? Oh I see your problem. Just use GUILayout.BeginVertical(); The one you're using right now is trying to parse Test as a GUIStyle (The second function I listed)
Mar 16 '11 at 10:08 AM
Mike 3
Thanks again Mike, but what about the scripting guide? It clearly says about the style argument: "If left out, the background is transparent". Is it just some random statement that has no value?
Mar 16 '11 at 10:17 AM
nOne
or does "left out" means that i must provide an empty string for the style argument? (instead of no style argument at all)
Mar 16 '11 at 10:20 AM
nOne
The one I used above is the only function you can leave it out of, the rest are mandatory. It has value in that you're calling BeginVertical without a style, the fact that it's internally a different overload doesn't change that
Mar 16 '11 at 10:21 AM
Mike 3
Ok, i think i understand better now! But what if i want to create a BeginVertical with a text and use the default transparent background for the style. Will BeginVertical("test", "") do the trick?
Mar 16 '11 at 10:27 AM
nOne
(comments are locked)
|
