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 /
avatar image
0
Question by MihajloNen · Mar 12, 2016 at 05:52 PM · uieditorandroid buildbuttons

Android build does not show UI buttons after SetActive

I am working on a project where multiple questions have to be answered by choosing a option(Text on Button). 1st Question(2 option-UI buttons) are SetActive(true). Then 2nd question the Buttons go SetActive(false) and then they should appear at the 3rd question again. Sometimes SetActive did not work well and I used the CanvasGroup-component and set *kursiv*intractable=false and *kursiv*alpha=0. In the Editor it all works well to the point I worked with Unity 5.1. After I updated to 5.3.3 the Buttons at question 3 do not show up after entering the anwer in the Inputfield. BUT ONLY IN ANDROID BUILD! in the editor inside unity it all works fine. Hope someone can help me quickly. TY

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 public class HideShowButtons : MonoBehaviour {
 
     public bool showNachthimmel = false;
     public float fadeWartezeit;
     public GameObject Button_Erde;
     public GameObject Button_Alter;
     public GameObject Button_E_Text;
     public GameObject Button_A_Text;
     public GameObject Inputfield_Frage;
     public GameObject Nachthimmel;
     private bool Inputfiel_SetActiveFalse = false;
     //private bool hideButton = true;
     public float ZeitBisButtonSHOW;
     public SpriteRenderer sprite;
     //Referezenen
     private Boli_Start Boliscript;
     private Dialogbox Dialog;
     private FadeScript Fadescript;
 
     //Fade in and Out
 
 
     // Use this for initialization
     void Start () 
     {
         Boliscript = GameObject.FindGameObjectWithTag ("Schnecke").GetComponent<Boli_Start> (); //hier: Boli mit "Schnecke" betagged
         Dialog = GameObject.FindGameObjectWithTag("CanvasTag").GetComponent<Dialogbox>();
         Button_Erde.GetComponent<CanvasGroup>().alpha = 0;
         Button_Erde.GetComponent<CanvasGroup> ().interactable = false;
         Inputfield_Frage.GetComponent<CanvasGroup> ().alpha = 0;
         Inputfield_Frage.GetComponent<CanvasGroup> ().interactable = false;
         Fadescript = GameObject.Find ("BLACK").GetComponent<FadeScript> ();
 
 
     }
     
     // Update is called once per frame
     void Update () 
     {
         if (Boliscript.redenB)
         {
             if (Dialog.NextOK == 0) 
             {
                 Button_E_Text.GetComponent<Text> ().text = Dialog.ButtonE_Text_NextOK00;
                 Button_A_Text.GetComponent<Text> ().text = Dialog.ButtonA_Text_NextOK00;
             }
             StartCoroutine ("WaitANDShowButtons");
             if (Dialog.NextOK == 1) 
             {
                 
                 StartCoroutine ("WaitANDShowInputfield");
                 if (Inputfiel_SetActiveFalse)
                 {
                     Inputfield_Frage.GetComponent<CanvasGroup> ().alpha = 1;
                     Inputfield_Frage.GetComponent<CanvasGroup> ().interactable = true;
                     Button_Erde.GetComponent<CanvasGroup> ().interactable = false;
                     Button_Alter.GetComponent<CanvasGroup> ().interactable = false;
                     Button_Erde.GetComponent<CanvasGroup> ().alpha = 0;
                     Button_Alter.GetComponent<CanvasGroup> ().alpha = 0;
                 }
 
                 Button_Erde.SetActive (false);
                 Button_Alter.SetActive (false);
             }
 
                 
         }
         //Boli redet nicht mehr
 
 
         if (Dialog.NextOK == 2)  
         {
             Inputfield_Frage.SetActive (false);
 
             StartCoroutine ("SetButtonsActiveAgain");
 
         }
 
         if (Dialog.NextOK == 3) 
         {
             StartCoroutine ("ShowNightskyAfterSeconds");
             if (showNachthimmel) 
             {
                 //lässt Nachthimmel auf die Bildschirmgrösse verändern und Position perfekt an MainCamera anpassen.
                 var NachtSR = Nachthimmel.GetComponent<SpriteRenderer> (); //sr steht für Sprite Renderer
                 Nachthimmel.transform.localScale = new Vector3 (1, 1, 1); // Zuerst eine einheitliche Grösse machen
                 var width = NachtSR.sprite.bounds.size.x;
                 var height = NachtSR.sprite.bounds.size.y;
                 var worldScreenHeight = Camera.main.orthographicSize * 2.5f;//2.5f ist ein random Wert. halt so, dass dei Höhe passt.
                 var worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;
                 double NachthimmelScaleX = Nachthimmel.transform.localScale.x;
                 double NachthimmelScaleY = Nachthimmel.transform.localScale.y;
                 NachthimmelScaleX = worldScreenWidth / width;
                 NachthimmelScaleY = worldScreenHeight / height;
                 Nachthimmel.transform.localScale = new Vector2 ((float)worldScreenWidth, (float)worldScreenHeight);
                 Nachthimmel.transform.position = new Vector2 (Camera.main.transform.position.x, Camera.main.transform.position.y);
             }
             showNachthimmel = false;
         }
     
     }
     //Da der Text erst nach dem clicken auf den Button geändert wird, ist das die beste Lösung(Text ändert als Funktion bei Button Click der vorherigen NextOK-Phase)
     public void ButtonTextChanger()
     {
         if (Dialog.NextOK == 1) 
         {
             Button_E_Text.GetComponent<Text> ().text = Dialog.ButtonE_Text_NextOK1;
             Button_A_Text.GetComponent<Text> ().text = Dialog.ButtonA_Text_NextOK1;
         }
     }
 
     IEnumerator WaitANDShowButtons()
     {
         if (Dialog.NextOK == 0) 
         {
             yield return new WaitForSeconds (ZeitBisButtonSHOW);
             Button_Erde.GetComponent<CanvasGroup> ().alpha = 1;
             Button_Erde.GetComponent<CanvasGroup> ().interactable = true;
 
             Button_Alter.GetComponent<CanvasGroup> ().alpha = 1;
             Button_Alter.GetComponent<CanvasGroup> ().interactable = true;
         }
     }
     IEnumerator WaitANDShowInputfield()
     {
         yield return new WaitForSeconds (ZeitBisButtonSHOW);
         Inputfiel_SetActiveFalse = true;
     }
 
     IEnumerator ShowNightskyAfterSeconds()
     {
         yield return new WaitForSeconds (3);
         Fadescript.fadeBlack = true;
         yield return new WaitForSeconds (fadeWartezeit);
         showNachthimmel = true;
     }
     IEnumerator SetButtonsActiveAgain()
     {
         yield return new WaitForSeconds (2);
         Button_Erde.GetComponent<CanvasGroup> ().alpha = 1;
         Button_Erde.GetComponent<CanvasGroup> ().interactable = true;
         Button_Alter.GetComponent<CanvasGroup> ().alpha = 1;
         Button_Alter.GetComponent<CanvasGroup> ().interactable = true;
         Button_E_Text.GetComponent<Text>().text = Dialog.ButtonE_Text_NextOK1;
         Button_A_Text.GetComponent<Text>().text = Dialog.ButtonA_Text_NextOK1;
     }
 
 }
 


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

· Add your reply
  • Sort: 

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

56 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

Related Questions

Unity Tabs is Empty or Broken someTimes 0 Answers

Setting a button navigation mode throug code 1 Answer

How do switch control for canvas using joystick? 0 Answers

Failed to export android project in U3D 2020.2.2f1c1 1 Answer

How to instantiate multiple sprites without creating animation? 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