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 /
This question was closed Sep 10, 2013 at 01:33 PM by DeadKenny for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by DeadKenny · Sep 10, 2013 at 12:13 PM · c#instantiatebuttonstring

How to Instantiate from correct Icon.

This related to my previous question.http: //answers.unity3d.com/questions/533360/how-to-link-string-to-gameobjectprefab-to-load-fro.html

So I got the correct Prefab GameObject to be linked to the correct Icon and name but now I can't figure out how to get the GUI to instantiate the linked object when clicking the icon.

So CreateTurret("TurretName"); This instantiates and works but I have to name it manually.

What I need is CreateTurret(name of icon and button clicked);

This is what I mean:

// This is the part where the GUI with the buttons and icons of the turrets are set and where the object is supposed to be instantiated using the function in the previous question. IE: CreateTurret(string name);

 //selectUIScript[cnt].Cameo is the Icon that I need to tell CreateTurret() to get by name... so when I click it creates the turret for that icon.  
 
 
 if(GUI.Button(new Rect(selectbuttonWidth * cnt, 30, selectbuttonWidth, selectbuttonHeight), new GUIContent(selectUIScript.baseList[cnt].Cameo, selectUIScript.baseList[cnt].ToolTipVehicle()))){
 
 
 constuctorScript.CreateTurret();
 

 
 }

// So basically what do I have to type in the brackets of CreateTurret() in order to instantiate by the name of the Icon which is linked to the prefab?

Comment
Add comment · Show 3
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 DeadKenny · Sep 10, 2013 at 01:19 PM 0
Share

Lol holy crap, I had tried all kinds of stuff but didn't try that. The same thing was right above the dam CreateTurret but for the Cameo.

$$anonymous$$an you guys are very useful.

Thanks man.

Not closing this question yet though because I have one more last issue that I might not be able to solve regarding this.

avatar image ArkaneX · Sep 10, 2013 at 01:27 PM 0
Share

:) Converted my comment to answer.

avatar image DeadKenny · Sep 10, 2013 at 01:32 PM 0
Share

Alright never $$anonymous$$d the other issue I sorted it.

Thanks again.

1 Reply

  • Sort: 
avatar image
1
Best Answer

Answer by ArkaneX · Sep 10, 2013 at 12:40 PM

Basing on the previous question - is selectUIScript.baseList a list of TurretClass? If yes, then you have to use:

 constuctorScript.CreateTurret(selectUIScript.baseList[cnt].Name);
Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

17 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

Related Questions

Multiple Cars not working 1 Answer

Creating an Object with a string C#! How? 1 Answer

Distribute terrain in zones 3 Answers

How do you Instantiate a button as a child object of a canvas? 0 Answers

Instantiate and Scale with Mouse Click. 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