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 Wylie-Modro · Oct 30, 2016 at 07:57 PM · uiinstantiateanimatorrenderingtext

UI Text sometimes renders when instantiated, yet sometimes does not.

Every time I shoot an object in the game it destroys itself and the PopUpPairParent(Clone) is instantiated through a separate object and script called "FloatingTextManger" (see below). The PopUpPairParent(Clone) has a different component script "FloatingText" (see below) which takes in the animator component of PopUpPairParent(Clone)'s child, called PopUpPair. PopUpPair's child is PopUpTextC which is a UIText object. The animation moves the PopUpPair up and starts to decrease its alpha until 0 and at the end of the clip length PopUpPairParent(Clone) is destroyed.

This works perfectly ...... sometimes. A significant amount of the time the PopUpPairParent(Clone) is instantiated, PopUpPair animates with PopUpTextC but PopUpTextC's text never renders.

Here is some comparison screenshots of when it does and doesn't render:

Does Render: alt text

Doesn't Render:

alt text

 public class FloatingTextManager: MonoBehaviour {
 
     public FloatingText popUPTextPairParent;
     public GameObject canvas;
 
     public void CreateFloatingText(Transform location) {
         FloatingText instanceOfPopUPTextPair = Instantiate(popUPTextPairParent);
 
         if (instanceOfPopUPTextPair) {
             Debug.Log ("instanceOfPopUPTextPair exists");
         }
 
         Vector2 screenPosition = Camera.main.WorldToScreenPoint (location.position);
 
         instanceOfPopUPTextPair.transform.SetParent(canvas.transform, false);
         if (canvas) {
             Debug.Log ("There is a canvas");
         }
         instanceOfPopUPTextPair.transform.position = new Vector2 (screenPosition.x, screenPosition.y + 80f);
 
         Debug.Log ("CreateFloatingText Called");
     }
 }




 public class FloatingText : MonoBehaviour {
 
     public Animator floatingTextAnimator;
     private Text floatingText;
 
     void Start () {
         AnimatorClipInfo[] clipInfo = floatingTextAnimator.GetCurrentAnimatorClipInfo (0);
         Destroy (gameObject, clipInfo[0].clip.length);
         Debug.Log ("clip length: " + clipInfo [0].clip.length.ToString ());
 
         floatingText = floatingTextAnimator.GetComponentInChildren<Text> ();
         if (floatingText) {
             Debug.Log ("GOT TEXT COMPONENT FROM THE CHILD: " + floatingText.ToString());
         }
     }
 }

PopUpPairParent(Clone) is the prefab that is being instantiated so they have the same layers and as you can see they are set to the same canvas, "WordAnimationsCanvas". Furthermore you can see from the Debug.Log() messages that the code seems to run in exactly the same way regardless of whether the text renders or not.

Lastly CreateFloatingText() is called in the DestroyObjects Script attached to the destructible objects and goes something like this:

 public class DestroyableObjects : MonoBehaviour {
 
 private FloatingTextManager floatingTextManager;
 
 void Start () {
          floatingTextManager = FindObjectOfType<FloatingTextManager> ();
 }
 
 void OnTriggerEnter2D (Collider2D collider) {
          floatingTextManager.CreateFloatingText (gameObject.transform);
          Destroy (gameObject);
         }
 }

At this point I have no idea why this is happening and any help would be appreciated. Thank you.

Edit: Oddly enough, if I run the game in an Android Studio emulator the problem is resolved and all the instantiated UIText is rendered.

majorbugnotext.png (94.6 kB)
majorbugrenderedtext.png (103.5 kB)
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 hexagonius · Oct 31, 2016 at 02:18 PM 0
Share

have you checked on the component what's the cause? Is the alpha at 0 right from the start, or is the text just too long to fit into your Text field?

avatar image Wylie-Modro hexagonius · Oct 31, 2016 at 07:45 PM 0
Share

Ultimately the rendering and non-rendering text element are the same prefab so all the components should be the same. But yes I did check manually and both the rendering and the non-rendering texts starts with an alpha of 255. I have also adjusted the size of the text box, the font size, and the colour of the non-rendering text it just refuses to show up.

avatar image hexagonius Wylie-Modro · Nov 01, 2016 at 06:35 PM 0
Share

then maybe it's outside the camera's clipping plane if you use one?

1 Reply

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

Answer by Wylie-Modro · Dec 25, 2016 at 10:46 PM

If I run my game in iOS or Android emulator, or on a Android or iPhone the problem seems to be resolved.

Some friends and I have concluded that this is an annoying but relatively harmless bug inside the Unity Editor.

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

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

Related Questions

Dynamically added UI text is not displaying 2 Answers

UI Text component is not rendering correctly on MAC (sub pixel issue) 0 Answers

Instantiating UI element at mouse position on click 1 Answer

How do I Iterate through child UI buttons to change their images? 0 Answers

Screen space overlay canvas 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