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 Jesus_Freak · Dec 30, 2010 at 10:15 PM · arrayvalueadd

Array value not changing?

it;s not changing for some reason, even though i tell it to add or subtract one when i press the buttons. can you tell me what i did wrong? (the message is displaying) but not changing.

script:

@script ExecuteInEditMode static var pages : Array; var levelToLoad : String = "Level1"; var first : String; var second : String; var third : String; var fourth : String; var fifth : String; var sixth : String; var seventh : String; var rectangle : Rect; var Rectangle : Rect; var next : Rect; var back : Rect; var mssgRect : Rect; var windowRect : Rect = Rect((Screen.width / 2) - (X / 2), (Screen.height / 2) - (Y / 2), WIDTH, HEIGHT); var X : int; var Y : int; var X2 : int; var Y2 : int; var WIDTH : int; var HEIGHT : int; static var currentPage : int; private var showGUI = false;

function Awake() { currentPage = 0; showGUI = false; } function Start() { pages = Array(first, second, third, fourth, fifth, sixth, seventh); currentPage = 0; print(pages[currentPage]); } function GoUpPage() { if(currentPage < pages.length) { currentPage ++; print(pages[currentPage]); } if(currentPage > pages.length) { showGUI = true; } } function GoDownPage() { if(currentPage > 0) { currentPage --; print(pages[currentPage]); } } function OnGUI() { if(!showGUI) { windowRect = GUI.Window(0, windowRect, DoMyWindow, "Tutorial Info:"); } if(showGUI) { windowRect = GUI.Window(1, windowRect, ShowGUI, "First Level?"); } } function ShowGUI() { GUI.skin.button.wordWrap = true; if(GUI.Button(back, "<--Back")) { GoDownPage(); showGUI = false; } GUI.skin.button.wordWrap = true; if(GUI.Button(next, "Level 1-->")) { Application.LoadLevel(levelToLoad); }

GUI.DragWindow(); } function DoMyWindow() { if(!showGUI) { GUI.skin.label.wordWrap = true; GUI.Label(Rect(X2,Y2,10000000, 50), "" + System.DateTime.Now); GUI.skin.button.wordWrap = true; if(GUI.Button(rectangle, "Next")) { GoUpPage(); } GUI.skin.label.wordWrap = true; GUI.Label(mssgRect, pages[currentPage].ToString()); GUI.skin.button.wordWrap = true; if(GUI.Button(Rectangle, "Back")) { GoDownPage(); } } GUI.DragWindow(); }

thanks in advance!

(all the rects where to get the GUI positioning correct.)

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
0

Answer by Mike 3 · Dec 30, 2010 at 10:50 PM

If you're trying to get it rendering the GUI properly in editor mode, it probably won't work - unity doesn't update OnGUI much when it's not playing (Generally only does something when something happens to force a refresh)

If that's not the case and you're trying to get it to work at runtime, I'm not sure - your code works for me

Comment
Add comment · Show 3 · 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 Jesus_Freak · Dec 31, 2010 at 12:55 AM 0
Share

for some reason, when i press the first next button, it stays on the first message, im okay with the rendering, in both times- runtime and edit mode, but the message doesn't change (i'll see if it) does the message change in your case? like mssg 1 turns to messg 2 when u click the next button, then back to mssg 1 when you clkick the back button? if so... that's great.. if not... i'll go from there.

avatar image Mike 3 · Dec 31, 2010 at 02:02 AM 0
Share

it works fine at runtime , in edit mode it renders once then doesn't change

avatar image Jesus_Freak · Dec 31, 2010 at 02:12 AM 0
Share

yeah, the rendering is great, put the UpPage and DownPage functions dont seem to be working for me.

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

Add values to Int[] (SetTriangles) 1 Answer

Dividing add value in a += statement makes it not add at all 1 Answer

How to Show Random.Range in the Console when used in an Array? 0 Answers

Array doesn't increase or add element 1 Answer

Keep adding targets to a list 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