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 /
This question was closed Feb 09, 2015 at 10:10 PM by meat5000 for the following reason:

Self Answered

avatar image
1
Question by Xtro · Feb 09, 2015 at 07:04 PM · raycasteventsystem

Where did EventSystem.GetCurrentPointerData go?

I remember I was able to get last raycast info from the new eventsystem when it was in beta version. Now I can't find how to do it. Is this functionality removed in 4.6 release?

I want this to avoid to make an additional raycast to the scene. Since EventSystem is already making a raycast via PhysicsRaycaster component, I should be able to reach its cached data without making another raycast. Right?

Can you guys remember how to do this?

--EDIT--

After some search in my SVN repository, I found this old code piece which worked very well in 4.6 beta... I was trying to simulate MouseMove events which is the same behavior that I want to achieve now :)

I also updated the title of the question.

in Update event:

     // Simulate MouseMove event
     /*
     var PointerData = EventSystem.instance.GetCurrentPointerData().FirstOrDefault();
     if (PointerData != null && PointerData.pointerEnter == gameObject)
     {
         if (Input.mousePosition != LastMousePosition)
         {
             SendMouseMoveEvent();
             LastMousePosition = Input.mousePosition;
         }
     }
     else LastMousePosition = -Vector3.one;
     */
Comment
Add comment · Show 7
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 meat5000 ♦ · Feb 09, 2015 at 07:29 PM 0
Share

You can implement this yourself. Just store the hitinfo after you make the raycast :) Sorry, it doesnt mention the EventSystem but I like to cheat at program$$anonymous$$g.

avatar image Xtro · Feb 09, 2015 at 08:11 PM 0
Share

It's not about cheating program$$anonymous$$g or not. As I mentioned in the question, I don't want to make a redundant raycast because EventSystem already does one. Its data was accessible in 4.6 beta.

avatar image meat5000 ♦ · Feb 09, 2015 at 08:29 PM 0
Share

Ok I see, the hitinfo doesnt appear to be exposed in the above.

Do you remember what the calls looked like before?

The only trace I can find is that lastHit is a member of NGUI's UICamera.

What data is it you would like to retrieve, specifically?

http://docs.unity3d.com/ScriptReference/EventSystems.RaycastResult.html

avatar image Xtro · Feb 09, 2015 at 08:39 PM 0
Share

Unfortunately I can't :(

$$anonymous$$aybe it was something like EventSystem.current.getLastsomething something. I hate my self because I lost that example code in my library.

avatar image Xtro · Feb 09, 2015 at 08:55 PM 0
Share

YESS!!!! I found the beta test code from old SVN commits. I love SVN :)

I'll update my question with the old code...

Show more comments

1 Reply

  • Sort: 
avatar image
3
Best Answer

Answer by Xtro · Feb 09, 2015 at 09:16 PM

Now I found out that StandaloneInputModule class has GetMousePointerEventData method but it's protected. Maybe I can inherit that class to be able to access the GetMousePointerEventData method...

--EDIT--

I solved my problem by inheriting the standalone input class.

 public class CustomStandaloneInputModule : StandaloneInputModule
 {
     public PointerEventData GetPointerData()
     {
         return m_PointerData[kMouseLeftId];
     }
 }


Now I can attach this custom component onto EventSystem gameobject instead of standalone component and I can call GetPointerData method on it.

     var StandaloneInputModule = (CustomStandaloneInputModule)EventSystem.current.currentInputModule;
     print(StandaloneInputModule.GetPointerData().pointerEnter);

It works and I can get the gameobject which mouse pointer hovers over... :)

I definitely would prefer that standalone input class would have GetPointerData implemented as public.

Comment
Add comment · Show 7 · 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
avatar image meat5000 ♦ · Feb 09, 2015 at 09:20 PM 0
Share

Does Pointer Event Data have what you need? This is used by both the Touch and Standalone modules.

PointerInput$$anonymous$$odule actually has a bunch of cached information, current and last.

avatar image Xtro · Feb 09, 2015 at 09:58 PM 0
Share

$$anonymous$$ost of them are protected. I inherited the Standalone input class and solved my problem. I'll update my answer.

avatar image caesarpena · Aug 03, 2016 at 05:49 PM 0
Share

i tried this, trying to debug log the " Debug.Log(StandaloneInput$$anonymous$$odule.GetPointerData().pointerPress);"

from another class but nothing is happening, can anyone help?

avatar image luislodosm · May 08, 2017 at 02:46 PM 0
Share

I get InvalidCastException.

Custom$$anonymous$$odule custom$$anonymous$$odule = (Custom$$anonymous$$odule) EventSystem.current.currentInput$$anonymous$$odule;

avatar image Xtro luislodosm · May 08, 2017 at 04:55 PM 0
Share

I posted this long time ago and Unity API might have been changed. Are you sure you inherited your Custom$$anonymous$$odule class from StandaloneInput$$anonymous$$odule class?

avatar image HunterAhlquist luislodosm · Mar 11, 2019 at 03:10 AM 0
Share

Having the same problem too, it appears that this method no longer works.

avatar image Nicokam · Nov 13, 2020 at 07:26 PM 0
Share

$$anonymous$$e too. I would appreciate if someone else that found a solution to this could share it!

Follow this Question

Answers Answers and Comments

25 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

Related Questions

understand how "Raycast Target" works on UI elements 2 Answers

TMPro UI elements not blocking raycasts 2 Answers

Help, Use event system IPointerClickHandler 1 Answer

Unity 4.6 UI - Ignore raycast -1 Answers

How do you perform a Graphic Raycast? 3 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