Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by nOne · Mar 15, 2011 at 10:11 PM · errorstylebce0023guicontent

BeginVertical won't compile when no style is provided

Hi,

i'm trying to create a very simple GUI with Unity, here is my javascript code:

function OnGUI() {
  GUILayout.BeginVertical(GUIContent("test"));
  GUILayout.EndVertical();
}

when the script is 'compiled' it gives me the following error:

Assets/NewBehaviourScript.js(2,40): BCE0023: No appropriate version of 'UnityEngine.GUILayout.BeginVertical' for the argument list '(UnityEngine.GUIContent)' was found.

when i add a style to the BeginVertical constructor, like this:

function OnGUI() {
  GUILayout.BeginVertical(GUIContent("test"), "box");
  GUILayout.EndVertical();
}

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mike 3 · Mar 15, 2011 at 10:26 PM

According to the script reference, it's not optional:

http://unity3d.com/support/documentation/ScriptReference/GUILayout.BeginVertical.html

static function BeginVertical (params options : GUILayoutOption[]) : void
static function BeginVertical (style : GUIStyle, params options : GUILayoutOption[]) : void
static function BeginVertical (text : string, style : GUIStyle, params options : GUILayoutOption[]) : void
static function BeginVertical (image : Texture, style : GUIStyle, params options : GUILayoutOption[]) : void
static function BeginVertical (content : GUIContent, style : GUIStyle, params options : GUILayoutOption[]) : void

The one in question being the last one, which takes a GUIContent, a style, and a variable number of GUILayoutOptions

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nOne · Mar 15, 2011 at 11:13 PM 0
Share

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!

avatar image
0

Answer by nOne · Mar 16, 2011 at 09:36 AM

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:

The style to use for background image and padding values. If left out, the background is transparent

and when i use the text/style/options constructor, like this:

function OnGUI() {
  GUILayout.BeginVertical("test");
  GUILayout.EndVertical();
}

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?

Comment
Add comment · Show 7 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Mike 3 · Mar 16, 2011 at 10:08 AM 0
Share

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)

avatar image nOne · Mar 16, 2011 at 10:17 AM 0
Share

Thanks again $$anonymous$$ike, 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?

avatar image nOne · Mar 16, 2011 at 10:20 AM 0
Share

or does "left out" means that i must provide an empty string for the style argument? (ins$$anonymous$$d of no style argument at all)

avatar image Mike 3 · Mar 16, 2011 at 10:21 AM 0
Share

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

avatar image nOne · Mar 16, 2011 at 10:27 AM 0
Share

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?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

No one has followed this question yet.

Related Questions

Script error: No appropriate version of 'UnityEngine.Transform.TransformDirection' for the argument list '(System.Type)' was found 2 Answers

Instantiate GameObjects, brings an error to the log... 2 Answers

Unity ERROR BCE0023 1 Answer

how to change content offset of a style 1 Answer

script gets this error: (6,20): BCE0023: No appropriate version of 'UnityEngine.Object.Instantiate' for the argument list '(UnityEngine.Transform, System.Object)' was found. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges