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 sarusian · Feb 20, 2017 at 03:29 AM · javascriptguireferencing

Closing GUI of another Script

I cant manage to close the GUI in Country.js from CanadaCore.js and since Country.js is a catch all GUI script for displaying country info and referencing CanadaCore.js would have to be repeated 130 times for each country so CanadaCore.js HAS to be the one to close the GUI

 #pragma strict
 //CanadaCore.js
         //Technical Stuff
         var obj : GameObject;
         var isClicked : boolean = Country.isClicked;
 
     // Population Stats
         // Canada Population In Ones
             static var CanadaPop : int = 36503478;
         // Canada GDP In Millions
             static var CanadaGDP = 1550536520000;
         // Canada GDP Per Head
             static var CanadaPPP;
         // Population Dispalced In Canada
             static var CanadianRefugees;
         // Number Of Empty Canadian Rooms
             static var CanadaHouses = 3578;
         // Number Of Active Canadian Troops
             static var CanadaTroops = 68250;
         // Tonnes Of Stockpiled Food
             static var CanadaFood = 12;
 
 // Government Definitions: Democracy:0, Monarchy:1, Communist:2, Facist:3, Theocracy: 4
 // FreeMovement dictates the probability of transmission of disease
 // OpenBorders increases transmission risk from neighboring nations as well as increase incoming refugee numbers
 
 
     // Politics
             static var CanadaName : String = "Canada";
             var Government = 0;
             var OpenBorders = true;
             var Funding = 0;
             var Approval = 50;
             var Generosity : float = .50;
 
 
     // Geography
             // Region 0 is North America
             var Region = 0;
             // 1% Chance of earthquake
             var EarthquakeRisk = 1;
             // 3% Chance of Pandemic
             var PandemicChance = 3;
 
 
     
 
 function Start () {
 
 }
 
 function Update () {
 if (isClicked == false) {
     Debug.Log("Closing DisplayCountryInfo");
 }
 }
 
 function OnMouseDown() {
     Debug.Log("Getting Data");
     isClicked = true;
 }
 
 function OnGUI () {
     if (isClicked == true) {
         obj.GetComponent(Country).DisplayCountryInfo(CanadaPop,CanadaGDP,CanadaPPP,CanadianRefugees,CanadaHouses,CanadaTroops,CanadaFood,CanadaName,Government,OpenBorders,Region,EarthquakeRisk,PandemicChance,Funding,isClicked);
 
     }
 }

The next script cannot call to CanadaCore.js

 #pragma strict
     var Skin :GUISkin;
     var exit : Texture;
     var isClicked;
 function Start () {
     
 }
 
 function Update () {
     
 }
 
 function DisplayCountryInfo(Population,GDP,PPP,Refugees,Houses,Troops,Food,Name,Government,Borders,Region,Earthquake,Pandemic,Funding,Closed) {
     GUI.skin = Skin;
 
     GUILayout.BeginArea(Rect (100,100,500,100));
     GUILayout.Box("GPD Per Head: " + PPP + "$");
     GUILayout.Box("Population: " + Population);
     GUILayout.Box("GDP: " + GDP + " Trillion Dollars");
     GUILayout.EndArea();
 
     GUILayout.BeginArea(Rect(1300,40,20,20));
         if(GUILayout.Button(exit)) {
             Debug.Log("Closing DisplayCountryInfo");
             isClicked = true;
 
         }
     GUILayout.EndArea();
 
Comment
Add comment · Show 1
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 JaredHD · Feb 20, 2017 at 07:23 PM 0
Share

You seem to be using the old UI system. It would be much easier to create a canvas. Add a panel for the information and set the panel to not be active.

For the information you could change a text UI on the panel to display the new information such as world GDP and what not....

It might be easier in the long run to use the new UI.

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

161 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 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

Level up system problem 0 Answers

Setting EventTrigger in Unity with JavaScript 0 Answers

Cannot figure out GetComponent for the life of me 1 Answer

How can I respond to a button click using GUI.Button? 1 Answer

How to make a GUI bar that counts items collected 0 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