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 /
avatar image
0
Question by Adamhudson90 · May 06, 2016 at 06:07 PM · textureinstantiatedestroyeditor-scriptingdropdown

Mesh Selection in Dropdown??

I would like to be able to Load a Mesh from an Option in my Dropdown UI, I set the rows to about 7, Renamed them all. Ive been researching the "On Value Changed" VS On Click Event and realized they are quite different. Can I make a Selection of a dropdown option the Same as an "On Click"? and how...really I want two dropdown menus.. One to select a Mesh...Second to select a texture for that Mesh...Any help or direction would be greatly appreciated!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by TBruce · May 07, 2016 at 12:16 AM

@Adamhudson90

Here is a start. It allows you to create all the drop down items from script. In the inspector I clear out all the drop down items as well as the label. Now for the image you need to create a UI image as a child of the Item game object in the DropDown template. Then drag that image reference to Item Image Field on the DropDown component.

The sample code below should do the rest (note you do need to set up the properties in the class below in the inspector).

 using UnityEngine;
 using UnityEngine.UI;
 using System.Collections;
 using System.Collections.Generic;
 
 public class DropDownManager : MonoBehaviour
 {
     public Dropdown dropDown1;
     public Dropdown dropDown2;
     public Dropdown dropDown3;
     
     public List<string> strings = new List<string>();
     public List<Sprite> sprites = new List<Sprite>();
     public List<Dropdown.OptionData> optionData = new List<Dropdown.OptionData>();
 
     // Use this for initialization
     void Start ()
     {
         if (dropDown1 != null)
         {
             dropDown1.options.Clear();
             for (int i = 0; i < strings.Count; i++)
             {
                 dropDown1.options.Add(new Dropdown.OptionData(strings[i]));
             }
             dropDown1.value = 0;
         }
         if (dropDown2 != null)
         {
             dropDown2.options.Clear();
             for (int i = 0; i < strings.Count; i++)
             {
                 dropDown2.options.Add(new Dropdown.OptionData(sprites[i]));
             }
             dropDown2.value = 0;
         }
         if (dropDown3 != null)
         {
             dropDown3.options.Clear();
             for (int i = 0; i < optionData.Count; i++)
             {
                 dropDown3.options.Add(new Dropdown.OptionData(optionData[i].text, optionData[i].image));
             }
             dropDown3.value = 0;
         }
     }
 }

Above three DropDown examples are provided

  1. Drop down list 1 is a text only drop down

  2. Drop down list 2 is a sprite only drop down

  3. Drop down list 3 is a can be text only, sprite only or a combination

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
avatar image
0

Answer by Adamhudson90 · May 08, 2016 at 06:04 PM

Thank you so much for all of your help. I am definitely going to mess with all of this later^^ My other question is, is it possible in unity to select a mesh from the dropdown, instantiate it to the screen, then click a second dropdown of textures, and have that selected texture apply to the mesh. I need to be able to call models from the dropdown, while destroying the old model..then have a list of textures that can be used on any of the called models universally.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Several instances destroyed when one is shot by player 0 Answers

Instantiate an object and destroy it after given time 2 Answers

Unable to delete instance of GameObject 0 Answers

Destroy Instantiate is not working 0 Answers

Destroy the first instantiated clone after 4 have been instantiated 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