Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by darkxcalibur · Sep 11, 2011 at 03:34 AM · javascriptenumfor-looptranslation

javascripts and Enum ( for loops get name)

pragma strict

public class Attributes extends BaseStat {

 public function Attribute() {
     SetExpToLevel(50);
     SetLevelModifier(1.05);
 }

}

//List of attributes in Game public enum AttributeName { Might, Constitution, Nimbleness, Speed, Concentration, Willpower, Charisma }

//then i want to get the gui function to return trough the for loop Might, Constitution, ect how can i achieve this on javescript??????

function OnGUI() { GUI.Label(Rect(10,10,50,25),"Name: "); _toon._name = GUI.TextArea(Rect(65,10,100,25),_toon._name);

 for(var cnt : int = 0; cnt < Enum.GetValues(AttributeName).Length; cnt++) {
     GUI.Label(Rect(10,40 + (cnt * 25),100,25), Enum.GetValues(AttributeName.ToString()));
     GUI.Label(Rect(115,40 + (cnt * 25),30,25),_toon.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
 }

}

heres a video tutorial how to do it in c# but i dont know how to translate it :( help me

http://www.youtube.com/watch?v=yQiEov5E2K0&feature=relmfu

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
1

Answer by cupsster · Jan 31, 2012 at 10:25 AM

 import System;

 enum positionInterpolation { easeInOutQuad = 0,
 easeInOutCubic = 1,
 easeInOutQuart = 2,
 easeInOutQuint = 3,
 easeInOutSine = 4,
 easeInOutExpo = 5,
 easeInOutCirc = 6,
 linear = 7};

 var curentInterpolation : positionInterpolation; 

then in your code do:

 for (var e:int=0; e < Enum.GetValues(typeof(positionInterpolation)).Length; e++){
     if (GUI.Button(Rect(95,50+p,105,18), Enum.GetValues(typeof(positionInterpolation))[e].ToString()))){
     // do your stuff here
     }  
 }

do not forget about "import System" at begining of your script.

Comment
Add comment · Show 2 · 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 cupsster · Jan 31, 2012 at 07:53 PM 0
Share

dont forget to mark as answered.. today I fought with same problem and this worked for me.. thank you

avatar image aviose · Apr 22, 2012 at 09:15 PM 0
Share

This answered the same question 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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Help with C#(Sharp) to Java Script :) !!! 1 Answer

changing a coroutine's argument at the coroutine's runtime? 1 Answer

Split() into a fixed length array? 1 Answer

Javascript for loops and Arrays. 2 Answers

For Loop GUILayout.Label Problems 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