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 /
This question was closed Sep 04, 2015 at 08:46 AM by Mallen_ for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Mallen_ · Sep 03, 2015 at 04:45 AM · sprite2d-gameplaymouseover

Mouse over system not destroying mouse over after object death, fix?

ok so im working on a 2d space game where players can hover over other objects and see details about them and i cant for the life of me figure out a little bug that has appeared, here's the code for Reference:
`

 public class MouseHover : MonoBehaviour
 {
     public GameObject MouseCircle;
     GameObject Tracked;
     bool Good = false;
     void OnMouseOver()
     {
         if (Tracked == null)
         {
             Tracked = (GameObject)Instantiate(MouseCircle, gameObject.transform.position, Quaternion.identity);
         }
         else
         {
             Tracked.transform.position = gameObject.transform.position;
         }
         Good = true;
     }
     void LateUpdate()
     {
         if (Tracked.transform.position != gameObject.transform.position || Good == false )
         {
             Destroy(Tracked);
         }
         Good = false;
     }
 }

the problem is, is that if the object gets destroyed the mouse over is never destroyed leaving a rather ugly circle just sitting there.

any help would be much appreciated

-Mallen

Comment
Add comment · Show 2
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 getyour411 · Sep 03, 2015 at 04:45 AM 0
Share

Do you get NullRef errors from LateUpdate()? "Tracked" is null until a $$anonymous$$ouseOver.

avatar image Mallen_ · Sep 03, 2015 at 01:46 PM 0
Share

No i don't actually get any error, it just doesn't destroy the mouse over if the Parent is destroyed

1 Reply

  • Sort: 
avatar image
0

Answer by Mallen_ · Sep 04, 2015 at 08:37 AM

ok i fixed this myself by having the mouseover destroy itself on update and have it spawned on late update by the enemy, if more details are needed contact me

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

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

2D Sprite rotation 180 degrees 0 Answers

Hello :) I'm trying to detect gaze input on a sprite image. How to do it? 0 Answers

Sprite not showing up (Tried common mistakes, Z-line, size, place, etc),Sprite is not showing up in 2D ( checked on Z, Layer order, size of the sprite) 0 Answers

Sprite image on UI appears much darker than actual image file. Please help! 1 Answer

Default Sprite Mask 2D not working on mobile 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