- Home /
 
               Question by 
               unity_cXA0pRWk7StwCA · Jan 24, 2019 at 11:16 AM · 
                unity 5guiunity5gui.buttongui.label  
              
 
              GUI.Label not displaying within GUI.BeginScrollView when GUI.Button is pressed what am I doing wrong?
Can someone help me please with the following problem. I can't seem to get the GUI.Label to display when I press the GUI.Button element. In my code, when the GUI.Button is pressed it disappears but doesn't get replaced with the GUI.Label element. Why is that? Help much appreciated. Thank you
   using UnityEngine;
   using System;
   using System.Collections;
   using UnityEngine.Experimental.UIElements;
  public class ExampleClass : MonoBehaviour {
  public Vector2 scrollPosition = Vector2.zero;
  public Boolean display = false;
  public Texture tex;
  void OnGUI() {
  scrollPosition = GUI.BeginScrollView(new Rect(100, 300, 500, 350), scrollPosition, new Rect(0, 0, 1220, 0));
  if (display == false) {
      if (GUI.Button (new Rect (0, 0, 300, 20), "Top-left")) {
          print ("TOP left PRESSED!!!");
          display = true;
          GUI.Label (new Rect (0, 0, 300, 20), "This is a box within a box.");
      }
  }
  if (GUI.Button(new Rect(320, 0, 300, 20), "Top-right")) {
      print ("TOP RIGHT PRESSED!!!");
  }
  if (GUI.Button(new Rect(640, 0, 300, 20), "Bottom-left")) {
      print ("bottom left PRESSED!!!");
  }
  if (GUI.Button(new Rect(960, 0, 300, 20), "Bottom-right")) {
      print ("bottom RIGHT PRESSED!!!");
  }
      
  GUI.EndScrollView();
    }
   }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Does Unity UI System have a foldable field? 0 Answers
Scrip cannot work after reloading the scene or reopen Unity 0 Answers
Why an Android build doesnt make a _Data file. 1 Answer
Latest update spawned weird errors in my console. 1 Answer
When I rotate the Camera XYZ coordinat arrows rotate too How to prevent that 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                