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
2
Question by Silvio · Jul 18, 2010 at 08:12 AM · guitexture2dlaggui-button

GUI.Button - Texture, Text, dropdown - Go from 1,900 FPS to 19FPS when i click the "Buildings" button

Strange behavior When using the GUI buttons. (My fault not unity of course :) )

I have here, a Gui Script, That when "Buildings" is clicked, it drops down a list of "Buildings" that can be purchased.

Each one is linked to a 2D Texture. Now, the problem i am having is.

Clicking the button for Buildings - My game slows down to about 19 - 20 FPS. with nothing really rendering, but a capsule, a couple of boxes, and a small flat terrain.

Here is the Script:

var showMoreGui = false; var icon1 : Texture2D; var icon2 : Texture2D; var icon3 : Texture2D; var icon4 : Texture2D; var icon5 : Texture2D;

function OnGUI () { if (GUI.Button (Rect (10,10,100,20), "Buildings")) showMoreGui = true;

 if (showMoreGui) 
     ExtraGUI (); 

}

function ExtraGUI () { GUI.Button (Rect (10, 40,100,20), icon1, "Shack");

 GUI.Button (Rect (10, 60,100,20), icon2, "Cottage"); 

 GUI.Button (Rect (10, 80,100,20), icon3, "Cobblestone House"); 

 GUI.Button (Rect (10, 100,100,20), icon4, "Townhouse"); 

 GUI.Button (Rect (10, 120,100,20), icon5, "Windmill"); 

 if (GUI.Button (Rect (10, 140,100,20), "Close")) 
     showMoreGui = false; 

}

Now, during Runtime - I get the following Message:

Unable to find style 'Windmill' in skin 'GameSkin' repaint UnityEngine.Debug:LogWarning(Object) UnityEngine.GUISkin:GetStyle(String) UnityEngine.GUIStyle:op_Implicit(String) NewBehaviourScript:ExtraGUI() (at Assets\Scripts\NewBehaviourScript.js:27) NewBehaviourScript:OnGUI() (at Assets\Scripts\NewBehaviourScript.js:15) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) UnityEditor.GameView:OnGUI() System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:InternalInvoke(Object, Object[]) System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) System.Reflection.MethodBase:Invoke(Object, Object[]) UnityEditor.HostView:Invoke(String) UnityEditor.DockArea:OnGUI()


On a side note, i was looking through the Script Refernce Manual: Found the Style part, try to implement it, and I get syntax errors.. ACCKKK!!!!

Any help would be appreciated as always :)

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

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by qJake · Jul 18, 2010 at 08:38 AM

You aren't using GUI.Button right. You can't do this:

GUI.Button (Rect (10, 40,100,20), icon1, "Shack"); 

because that means it will use icon1 as the texture for the button itself, and then it will search inside the current GUI skin for the style named "Shack", and try to apply it. Since it doesn't exist, it's causing lag for your game.

There is no Button definition for "image + text", so you need to make a custom GUIContent object instead, like this:

GUI.Button (Rect (10, 40,100,20), new GUIContent("Shack", icon1)); 
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 Silvio · Jul 18, 2010 at 08:54 AM 0
Share

I have become enlightened! much thanks :)

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

Move the text in a GUI Button/Box 1 Answer

Screen.width and Screen.height does not cover screen. Why? 4 Answers

Select part of the texture in GUI.DrawTexture 2 Answers

Update Texture type to GUI during runtime 0 Answers

Same BackGroung For All Screen Resolution 1 Answer


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