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
1
Question by B0RN2FISH · Jun 17, 2015 at 04:57 AM · labels

Help labeling a 3d object

I recently took over a project and need help labeling the parts of a 3d model of a heart.

Goal:The labels need to pop up when the corresponding part of the heart is clicked and turn off when I click off the heart or another part is clicked.

Currently:

The person before me made box colliders attached to the heart that when clicked make the label appear. (There are a multiple for every section of heart.

He used title bars for the text of the labels

The labels are called upon once clicked

The animator has 2 functions for this project, one helps the heart to beat and the other uses a mask to make the labels come up nicely.

Problem UPDATE The other problems have been resolved. The only problem right now is once a label is clicked and you click another part and then turn off the second one the first one is still on.

Ex. 1. Click aorta -> aorta label pops up-> 2. click left atrium -> left atrium label pops up (can't see the aorta label anymore) -> 3. click left atrium again to turn off labels -> left atrium turns off but aorta label shows still

UPDATE After completing the last step in the above example the label (canvas & text boxes) are still there they are just now blank.

I can think of 2 ways to solve this problem.(I just don't know how to do them)

Make it so that the space bar or middle mouse button turn off all of the labels

or

Is it possible to make another canvas that is blank that it changes to? and is it possible to swap between the blank and labeled one?

The current label manager script:

    public class ToggleLabel : MonoBehaviour {
 
     public string title = "Update this name";
     public string text = "Update this descriptive text";
     public bool isClicked = false;
 
     Animator anim;
     public GameObject titleText; //assign by dragging in editor
     public GameObject copyText; //assign by dragging in editor
     public GameObject NoLabel;
     void Awake()
     {
         anim = GameObject.FindGameObjectWithTag ("Canvas").GetComponentInChildren<Animator> ();
         //copyOptions = GameObject.FindGameObjectWithTag ("Canvas").GetComponentsInChildren<Text>();
     }
     
     void OnMouseUp()
     {
         if(!isClicked)
         {
             isClicked = true;
             titleText.GetComponent<Text>().text = title;
             copyText.GetComponent<Text>().text = text;
             anim.SetTrigger ("DrawLabel");
         }
         else
         {
             titleText.GetComponent<Text>().text = "";
             copyText.GetComponent<Text>().text = "";
             anim.SetTrigger ("RemoveLabel");
             isClicked = false;
         }
     }
 
 
 }


alt text

alt text

untitled.jpg (27.4 kB)
p.jpg (139.9 kB)
Comment
Add comment · Show 6
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 Cherno · Jun 22, 2015 at 04:53 PM 1
Share

I'm only starting to learn the new UI syste, but your project looks cool so I'm giving it a bump!

avatar image hnmikechan · Jun 26, 2015 at 05:30 PM 1
Share

Problem 1: is 'Horizontal Overflow' set to 'Wrap' in the Text component?

avatar image B0RN2FISH · Jun 26, 2015 at 06:52 PM 0
Share

Yup, it is set to Wrap

avatar image hnmikechan · Jun 26, 2015 at 06:58 PM 1
Share

I would also check to see if the text Rect Transforms' heights are large enough to fit multiple lines I guess.

avatar image B0RN2FISH · Jun 26, 2015 at 07:05 PM 0
Share

I changed the vertical overflow to overflow from truncated and that seemed to fix the issue there! Now it just look super pixelated

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by hnmikechan · Jun 26, 2015 at 07:09 PM

 Im not sure what the animator is doing, but I would do this for a simple case.  Assuming there is only one text object for title, and one for description in the scene:


          Animator anim;
          public GameObject titleText; //assign by dragging in editor
          public GameObject copyText; //assign by dragging in editor
          //Text[] copyOptions;
      
          void Awake()
          {
              anim = GameObject.FindGameObjectWithTag ("Canvas").GetComponentInChildren<Animator> ();
              //copyOptions = GameObject.FindGameObjectWithTag ("Canvas").GetComponentsInChildren<Text>();
          }
      
          void OnMouseUp()
          {
              if(!isClicked)
              {
                  isClicked = true;
                  //titleText = copyOptions [0];
                  //copyText = copyOptions [1];
                  titleText.GetComponent<Text>().text = title;
                  copyText.GetComponent<Text>().text = text;
                  anim.SetTrigger ("DrawLabel");
              }
              else
              {
                  titleText.GetComponent<Text>().text = "";
                  copyText.GetComponent<Text>().text = "";
                  anim.SetTrigger ("RemoveLabel");
                  isClicked = false;
              }
          }



Comment
Add comment · Show 8 · 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 hnmikechan · Jun 30, 2015 at 06:56 PM 1
Share

Did the above work at all? Did you solve the issue?

avatar image B0RN2FISH · Jun 30, 2015 at 08:21 PM 0
Share

Sorry for not getting to you sooner, from my understanding the animator in reference uses a mask to make the labels appear as a transition ins$$anonymous$$d of just appearing.

What do you mean by assign by dragging in editor?

Edit** This is the error I get(without dragging in the editor):

GetComponentInChild' of type `UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)

avatar image hnmikechan · Jun 30, 2015 at 09:16 PM 1
Share

I think I can imagine what the animation does. If you go into the animation tab of the 'Canvas' gameobject you'll maybe see animation keys for transforms that have titleText and copyText. Anyways, that shouldn't cause a problem.

For the assign by dragging in editor: when you set a variable to 'public' (ex. public GameObject titleText;), that will allow you to assign the public variables visually through the editor. So if you use the code I gave you, click on the gameobject that has that script and you should see the script as a component in the inspector. You'll also notice titleText and copyText as being unassigned. Just drag the titleText gameObject from the scene into the component to assign it. And repeat with copyText.

avatar image hnmikechan · Jul 01, 2015 at 08:49 PM 1
Share

Sorry I edited my answer. Just change both GetComponentsinChild() to GetComponent()

avatar image hnmikechan · Jul 02, 2015 at 03:16 PM 1
Share

Check my edited answer to see if that helps. It clears the labels values when clicked a 2nd time to turn them off.

Show more comments

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

positioning gui! 2 Answers

Can I customize the list of labels (tags) for assets in my scene? 2 Answers

What is that And How to use it? 1 Answer

Addressables: How to get a list of labels from loaded asset? 0 Answers

How to colour individual labels with UnityScript? 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