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
-4
Question by junkdog8 · May 19, 2014 at 07:09 AM · guibuttonmonodevelopnot-working

GUISkin breakages

ok this script was working before i started adding on a GUISkin. now it doesn't work even after i removed all the changes...WTF is going on??? i know the placement problem im going to get around to it. if you have any suggestions go ahead. but i really just cannot figure out what i did to break it...oh and on top of that my monodevelop has stopped giving me the quick option for GUI.Label don't know if that is related.

 using UnityEngine;
 using System.Collections;
 using System;
 
 public class CharacterGenerator : MonoBehaviour
 {
     private PlayerCharacter _hero;
 
     //Stat information
     private const int STARTING_POINTS = 400;
     private const int MIN_STARTING_ATTRIBUTE_VALUE = 10;
     private const int STARTING_VALUE = 50;
     private int PointsLeft;
 
     // Use this for initialization
     void Start ()
     {
         _hero = new PlayerCharacter ();
         _hero.Awake ();
 
         PointsLeft = STARTING_POINTS;
 
         for (int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)
         {
             _hero.GetPrimaryAttribute(cnt).BaseValue = STARTING_VALUE;
             PointsLeft -= (STARTING_VALUE - MIN_STARTING_ATTRIBUTE_VALUE);
         }
 
         _hero.StatUpdate ();
     }
     
     // Update is called once per frame
     void Update ()
     {
         DisplayAttributes ();
     }
 
     void OnGUI()
     {
         DisplayName ();
         DisplayPointsLeft ();
         DisplayAttributes ();
         DisplayVitals ();
         DisplaySkills ();
     }
 
     private void DisplayName()
     {
         GUI.Label(new Rect(10, 10, 50, 25), "Name");
         _hero.Name = GUI.TextField  (new Rect (65, 10, 100, 25), _hero.Name);
     }
 
     private void DisplayAttributes()
     {
         for (int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)
         {
             GUI.Label(new Rect(5, 50 + ((cnt + 4) * 20), 100, 20), ((AttributeName)cnt).ToString());
 
             GUI.Label(new Rect(105, 50 + ((cnt + 4) * 20), 30, 20), _hero.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
 
             if(GUI.Button(new Rect(105 + 30, 50 + ((cnt + 4) * 20), 20, 20), "-"));                                    
             {
                 if(_hero.GetPrimaryAttribute(cnt).BaseValue > MIN_STARTING_ATTRIBUTE_VALUE)
                 {
                     _hero.GetPrimaryAttribute(cnt).BaseValue--;
                     PointsLeft++;
                     _hero.StatUpdate ();
 
                 }
             }
 
             if(GUI.Button(new Rect(165, 50 + ((cnt + 4) * 20), 20, 20), "+"));
             {
                 if(PointsLeft > 0)
                 {
                     _hero.GetPrimaryAttribute(cnt).BaseValue++;
                     PointsLeft--;
                     _hero.StatUpdate ();
 
                 }
             }
         }
     }
 
     private void DisplayVitals()
     {
         for (int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++)
         {
             GUI.Label(new Rect(5, 50 + (cnt * 20), 100, 20), ((VitalName)cnt).ToString());
 
             GUI.Label(new Rect(105, 50 + (cnt * 20), 30, 20), _hero.GetVital(cnt).AdjustedBaseValue.ToString());
         }
     }
 
     private void DisplaySkills()
     {
         for (int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++)
         {
             GUI.Label(new Rect(245, 50 + ((cnt + 4) * 20), 100, 20), ((SkillName)cnt).ToString());
             
             GUI.Label(new Rect(325, 50 + ((cnt + 4) * 20), 30, 20), _hero.GetSkill(cnt).AdjustedBaseValue.ToString());    
         }
     }
 
     private void DisplayPointsLeft()
     {
         GUI.Label(new Rect(250,10, 100, 25), "Points Left: " + PointsLeft);
     }
 }
Comment
Add comment · Show 16
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 Xitech_ · May 19, 2014 at 07:16 AM 0
Share

What is the error you are getting?

avatar image fafase · May 19, 2014 at 07:19 AM 3
Share

The pb here is the way you are announcing your problem, the title is not telling what is going on, the way you explain the problem (or not explaining it), the fact you throw your whole class without taking the time to isolate where it could be from. Even though you do not know where the issue is, you know where it does not come from, there are parts of your code that are irrelevant, don't post them. It is easier on us to help then.

avatar image fafase · May 19, 2014 at 07:20 AM 0
Share

First off you have DisplayAttributes called in the Update, it contains GUI methods so it won't work.

avatar image junkdog8 · May 19, 2014 at 05:13 PM 0
Share

first off there are no errors... secondly i know that the problem lies somewhere in this class but i am not sure where, and yes i did put that in the update just to see if it would work.. it is fairly hard to isolate something that i cannot find, if i could find it i wouldn't be here.

but you are right i did not announce my problem correctly and i apologize it was quite late. the problem is that i click on the + and - buttons but it does not add or subtract from the attributes or from the points remaining. i at first assumed that this had something to do with the gui.button section however i rewrote that script from scratch and it still is not working.

avatar image Loius · May 19, 2014 at 06:17 PM 0
Share

"stopped giving me the quick option for GUI.label"

When monodev stops providing autocomplete functionality, it usually means there's a compile error. Which shows up in next to a big red icon in Unity's Console (Window > Console)

Show more comments

1 Reply

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

Answer by junkdog8 · May 20, 2014 at 08:48 PM

answer: don't put a ; at the end of your if statements...

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 Kiwasi · May 20, 2014 at 10:10 PM 0
Share

Can't believe I missed that. $$anonymous$$y only excuse, and pretty weak at that, is my screen is not big enough to have the scroll bar and the if statement at the same time.

$$anonymous$$aybe next time you will only post the problem code and we can all get things sorted quicker. :) Glad you've got it working.

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

25 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to hook up the particle system to jump animation? 1 Answer

Make more buttons appear, on button click. 1 Answer

GUI Button Animation Cue 1 Answer

GUI window popup button 1 Answer

Android Button Screen 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