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
0
Question by A13n · Dec 12, 2013 at 11:56 PM · destroygui-text

GUI text from destroyed object.

Hello. I have an inventory and i add items into it by picking up items from floor (Collision) and then this object is destroyed. I want to show GUI information for example "Coin taken" while i add this item to inventory. I already tried making other script that handle GUI and the item script just send static information to information showing script but it dont work as well. Propobly this is a easy taks but i dont have such knowlage. I belive i rewiewd my problem clearly. Sorry for my english and thank You for Your answers. Cheers!

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 Statement · Dec 13, 2013 at 12:41 AM 0
Share

I don't mean to be rude, but try to accept my apologies if it still comes across as it.

but it dont work as well [...] I belive i rewiewd my problem clearly

What is "it"? Can you show us some example code? Explain what you wanted to happen. Explain what happens ins$$anonymous$$d. If you have any errors in the console, let us know of those.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by A13n · Dec 13, 2013 at 10:22 PM

So I have a code that handles item looting and destroy it after pick up, so I want it to also show infomation on GUI that item was picked up. Here is the script: enter code hereimport System.Collections.Generic;

     var loot : ItemClass[];
     var Inventory : Inventory;
     var info : int = 0;
     var buttonTransform : Transform;
     var distToTake : float = 6;
     @HideInInspector
     var playerTransform : Transform;
     @HideInInspector
     var cameraTransform : Transform;
     function Start () 
     {
         Inventory = GetComponent("Inventory") as Inventory;
     
     }
     
     function Awake ()
     
     {
     
         playerTransform = GameObject.FindWithTag("Player").transform;
     
         cameraTransform = GameObject.FindWithTag("MainCamera").transform;
     
     }
     
      
     
     function Update () 
     
     {
     
         var angle : float = Vector3.Angle(buttonTransform.position - cameraTransform.position, buttonTransform.position + (cameraTransform.right * buttonTransform.localScale.magnitude) - cameraTransform.position);
         
         if (Vector3.Distance(playerTransform.position,buttonTransform.position) <= distToTake)
     
         if (Vector3.Angle(buttonTransform.position - cameraTransform.position, cameraTransform.forward) <= angle)
         
         if (Input.GetButtonDown("Use"))
         {
             Debug.Log("Use");
             if(Inventory.MainInventory.Count == 0)
                 {
                 info = 3;
                 }
             else
             for(var x = 0; x < Inventory.MainInventory.Count; x++)
             {
                 if(Inventory.MainInventory[x].id == 1)
                 {
                     info = 4;
                     giveloot();
                     renderer.enabled = false;
                     Destroy(gameObject,5);
                 }
                 if(x == 0)
                 {
                     info = 3;
                 }
             }
         }
     
     
     
     }
     function giveloot()
     {
         for(var x = 0; x < loot.length; x++)
         {
             Inventory.MainInventory.Add(loot[x]);
         }
     
     }
     function OnGUI()
 {
     if(info == 1)
     {
     GUILayout.BeginArea(Rect(Screen.width/2 - 250, Screen.height/2, 500, 500));
     GUILayout.BeginHorizontal();
     GUILayout.Box("You need a bronze set of keys.");
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     czekaj();
     }
     if(info == 2)
     {
     GUILayout.BeginArea(Rect(Screen.width/2 - 250, Screen.height/2, 500, 500));
     GUILayout.BeginHorizontal();
     GUILayout.Box("Well done!");
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     czekaj();
     }
     if(info == 3)
     {
     GUILayout.BeginArea(Rect(Screen.width/2 - 250, Screen.height/2, 500, 500));
     GUILayout.BeginHorizontal();
     GUILayout.Box("You can't reach the keys, they are too far. You need something long to grab them.");
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     czekaj();
     }
     if(info == 4)
     {
     GUILayout.BeginArea(Rect(Screen.width/2 - 250, Screen.height/2, 500, 500));
     GUILayout.BeginHorizontal();
     GUILayout.Box("Bronze Key Set taken.");
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     czekaj();
     }
     if(info == 5)
     {
     GUILayout.BeginArea(Rect(Screen.width/2 - 250, Screen.height/2, 500, 500));
     GUILayout.BeginHorizontal();
     GUILayout.Box("Metal bar taken.");
     GUILayout.EndHorizontal();
     GUILayout.EndArea();
     czekaj();
     }
 }
 
 function czekaj()
 {
 yield WaitForSeconds (5);
 info = 0;
 }
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

17 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

Related Questions

Coding Gui Text To Perform After GameObject Destroy? 1 Answer

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Create a text box that appears at start of game, then disappears with any player input 2 Answers

Instantiated GameObject being deleted when destroying original 1 Answer

Destroy script still works on 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