Announcement

Collapse
No announcement yet.

Get access to default cursor widget object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Get access to default cursor widget object

    Hi

    To control image and color of my cursor I need to get access to cursor widget which was created in initialization process (my cursor widget seted as default in project settings). How can I do that?
    Senior programmer from Snowforged Entertainment

    #2
    I've experienced that cursor widget BP code does not run in standalone / commandline versions of the game.

    So before you go full tilt on your planned objectives for your project, I recommend you verify that you can get any BP code to work for a cursor widget when game is run in Standalone/ commandline only / packaged game.

    This should save you a lot of time and effort if you get the same result I've been getting since cursor widget was released.

    I made an answerhub about this issue here:
    https://answers.unrealengine.com/que...struct-no.html

    ~~~

    Regarding your actual question, You can set up BP code in the cursor widget that sends a ref to itself over to your PC/game instance and is stored in a C++ BP-exposed variable.

    But as I've stated, I can't get BP code for cursors to work in packaged/standalone/commandline versions of the game.

    Good luck!

    Rama
    UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

    ♥ Rama

    Comment


      #3
      Cursor BP Code

      Dear Alanir,

      I've experienced that cursor widget BP code does not run in standalone / commandline versions of the game.

      So before you go full tilt on your planned objectives for your project, I recommend you verify that you can get any BP code to work for a cursor widget when game is run in Standalone/ commandline only / packaged game.

      This should save you a lot of time and effort if you get the same result I've been getting since cursor widget was released.

      I made an answerhub about this issue here:
      https://answers.unrealengine.com/que...struct-no.html

      ~~~

      Regarding your actual question, You can set up BP code in the cursor widget that sends a ref to itself ( "Get Reference To Self" ) over to your PC/game instance and is stored in a C++ BP-exposed variable.

      But as I've stated, I can't get BP code for cursors to work in packaged/standalone/commandline versions of the game (true as of 4.8).

      If anyone can verify cursor BP code, including things like delays and timers, working in a packaged/commandline version of the game I'd be very excited to know about it!

      Good luck!



      Rama
      Last edited by Rama; 08-17-2015, 07:03 PM.
      UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

      ♥ Rama

      Comment


        #4
        Hi Rama,
        Thank you for the answer. But I'm seeking some native solution without middle-saving actions. I hope it exists.
        I have just built project through shipping and I got my cursor's blueprint emplementable events works fine.
        Last edited by Alanir; 09-24-2015, 04:54 AM.
        Senior programmer from Snowforged Entertainment

        Comment


          #5
          Originally posted by Alanir View Post
          I have just builded project through shipping and I got my cursor's blueprint emplementable events works fine.
          Oh that's great to hear!

          ~~~

          Delay Nodes Not Working in Commandline/Standalone

          The issue I am having still is not resolved in 4.8.3, you can do a quick test by adding a delay and then a printstring to Construct event in the cursor widget, of say 2-3 seconds. If you run the game in PIE (in viewport) then the delay fires off and the message gets printed.

          But if I run the game in standalone, the print string never gets fired.

          I am mentioning this in the hopes it saves you and everyone some debugging time if you have issues using cursor blueprint code in standalone/commandline versions of the game.

          ~~~

          Looping Timers Do Work!


          I just tested and looping timers DO work in Standalone/commandline, it is only delay nodes that do not appear to be working.

          Enjoy!

          Rama
          UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

          ♥ Rama

          Comment


            #6
            Accessing OS Cursor Widgets

            Dear Alanir,

            The cursor widgets are stored in a private TMap in GameViewportClient

            Code:
            private:
              /** Map of Cursor Widgets*/
              TMap<EMouseCursor::Type, TSharedRef<SWidget>> CursorWidgets;
            The TMap is filled by AddCursor(), which is also private.

            ~~~

            TakeWidget

            Please note AddCursor extracts the inner SWidget of the BP-friendly UUserWidget:

            Code:
            CursorWidgets.Add(Cursor, UserWidget->TakeWidget());
            ~~~

            Accessing TMap

            The only way to access the TMap is a thankfully virtual function:

            Code:
            virtual TOptional<TSharedRef<SWidget>> MapCursor(FViewport* Viewport, const FCursorReply& CursorReply) override;
            CursorReply is used as follows in the .cpp

            Code:
            CursorWidgets.Find(CursorReply.GetCursorType());
            ~~~

            Solution

            You could construct your own CursorReply to obtain a SharedRef to the SWidget of your choosing.

            The issue at this point is you have the SWidget not the UUserWidget and you can't override AddCursor to modify any part of this process.

            Enjoy!



            Rama
            UE4 Marketplace: Melee Weapon Plugin & Compressed Binary Save System Plugin | Rama's C++ AI Jumping Videos | Vertex Snap Editor Plugin

            ♥ Rama

            Comment


              #7
              Thanks, Rama!
              Senior programmer from Snowforged Entertainment

              Comment

              Working...
              X