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 /
  • Help Room /
This question was closed Jan 17, 2016 at 11:58 AM by hexagonius for the following reason:

User answered question himself

avatar image
0
Question by Yetter · Jan 17, 2016 at 07:52 AM · textbuttons

instancing several buttons with different text

Still pretty new to Unity makeing a turnbased game and I'm trying to spawn my ability menus which is a series of vertical buttons based on how many abilities that have been unlocked. I can't quite figure out why this isn't working.

public void ActionMenuActivate (int selection) {

     int abilitiesUlck = player.GetComponent<ShipController> ().crewMan[selection].GetComponent<CrewValues> ().abilitiesUnlocked;

     Vector3 targetPlace = new Vector3 (220, 110, 0);

     for (var i =0;i<abilitiesUlck;i++)
     {
         string abilityName = player.GetComponent<ShipController>    ().crewMan[selection].GetComponent<CrewValues> ().abilities[i]; 
         GameObject button =Instantiate (actionButton);
         button.transform.SetParent (orderMenu.transform, false);
         button.transform.localPosition = targetPlace;
         GameObject btnText = GameObject.Find ("AbilityText");
         Debug.Log(abilityName);
         btnText.GetComponent<Text> ().text = abilityName;
         targetPlace.y -=20f;
         button.gameObject.SetActive (true);
     }

 }

The buttons spawn properly but only the first button is labeled with anything at all and its the last ability name. I'm pretty sure the problem is GameObject.Find("AbilityText") but I can't figure out a better way to look up the text I want to set. I've been trying to use button.transform.GetChild(0) but its not working out and I'm stumped

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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

36 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 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 link up instantiated text in list to allow buttons to adjust number shown, c# 1 Answer

Several objects, same script, different values with no duplications 1 Answer

Dialogue Skipping Issues? 0 Answers

How do I swap the text within a button with another button's text? 1 Answer

Changing text through a cursor hover trigger 0 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