Announcement

Collapse
No announcement yet.

Print String in VR easy

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

    Print String in VR easy

    Heyo all;
    Just did something that is a cheap trick but it makes it so you can print string to send messages to your VR HMD
    - Create a regular Print String
    - In the "In String" box hit "shift + Enter" about 35 times then enter your message
    - Now the print string will show up right in the middle of your VR HMD

    hacky but cheap and woot ^_^
    Lenny Gordon
    lenny@hammer-on.com
    http://www.hammer-on.com

    #2
    I can add to this, that i also added like 50 spaces on the last line to center it on screen too... I like hacky

    Comment


      #3
      Haha thanks! That's useful =)
      Easy colorgrading LOOKBROWSER.com

      Comment


        #4
        There is a better way to do it, but keeps it that simple:

        Setup a Widget that is a simple vertical Box with background. Make another widget that represents a textline/block. In the first widget make a function AddText. This function has a String as input and creates a widget of the textline class. Then sets the text of the created widget and adds the new create textline to the vertical box of its own (VerticalBox->Add Child)

        Make an actor, add WidgetComponent, set the widget class to the new component, attach it to the controller.

        Write a FunctionLibrary function that gets the widget with the vertical box (GetAllWidgetOfClass) and calls the AddText function of the widget.

        Now, from where ever you need debug text, call the library function.

        To go more advanced, add a time (float) to the AddText function. That time is then passed on to the textline widget. The textline subtracts the deltaTime from tick each tick and calls RemoveFromParent when time <= 0.

        Having a floating widget with the text in front of you is much more useable as the normal PrintString.

        This is just the idea, you can change and adjust what ever you need, e.g. add color to the textline or set the background to the textline instead of the vertical box. So there is nothing visible when there is no text.

        Cheers
        Last edited by Rumbleball; 01-12-2017, 03:55 PM.
        NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

        Comment


          #5
          Originally posted by Rumbleball View Post
          There is a better way to do it, but keeps it that simple:

          Setup a Widget that is a simple vertical Box with background. Make another widget that represents a textline/block. In the first widget make a function AddText. This function has a String as input and creates a widget of the textline class. Then sets the text of the created widget and adds the new create textline to the vertical box of its own (VerticalBox->Add Child)

          Make an actor, add WidgetComponent, set the widget class to the new component, attach it to the controller.

          Write a FunctionLibrary function that gets the widget with the vertical box (GetAllWidgetOfClass) and calls the AddText function of the widget.

          Now, from where ever you need debug text, call the library function.

          To go more advanced, add a time (float) to the AddText function. That time is then passed on to the textline widget. The textline subtracts the deltaTime from tick each tick and calls RemoveFromParent when time <= 0.

          Having a floating widget with the text in front of you is much more useable as the normal PrintString.

          This is just the idea, you can change and adjust what ever you need, e.g. add color to the textline or set the background to the textline instead of the vertical box. So there is nothing visible when there is no text.

          Cheers
          Setting this up tonight! Ty ty
          Lenny Gordon
          lenny@hammer-on.com
          http://www.hammer-on.com

          Comment


            #6
            Always happy when able to help

            Edit: In the library function u can also forward the DebugText and other data to PrintString in case GetAllWidgetOfClass returns nothing. This makes printstring obsolete for your project and u can stick to one node.
            Last edited by Rumbleball; 01-13-2017, 01:04 PM.
            NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

            Comment


              #7
              Originally posted by Rumbleball View Post
              There is a better way to do it, but keeps it that simple:

              Setup a Widget that is a simple vertical Box with background. Make another widget that represents a textline/block. In the first widget make a function AddText. This function has a String as input and creates a widget of the textline class. Then sets the text of the created widget and adds the new create textline to the vertical box of its own (VerticalBox->Add Child)

              Make an actor, add WidgetComponent, set the widget class to the new component, attach it to the controller.

              Write a FunctionLibrary function that gets the widget with the vertical box (GetAllWidgetOfClass) and calls the AddText function of the widget.

              Now, from where ever you need debug text, call the library function.

              To go more advanced, add a time (float) to the AddText function. That time is then passed on to the textline widget. The textline subtracts the deltaTime from tick each tick and calls RemoveFromParent when time <= 0.

              Having a floating widget with the text in front of you is much more useable as the normal PrintString.

              This is just the idea, you can change and adjust what ever you need, e.g. add color to the textline or set the background to the textline instead of the vertical box. So there is nothing visible when there is no text.

              Cheers
              I'm trying to implement this but I'm stuck with the blueprint library function. I have managed to get a reference to the character, but I don't know how to then get a reference to the widget that is attached to it so I can call the function. Here is my code from my blueprint library function:

              Code:
              	TObjectIterator<APlayerController> Itr;
              	if (!Itr) return;
              
              	UWorld* TheWorld = Itr->GetWorld();
              	if (!TheWorld) return;
              
              	ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(Itr->GetWorld(), 0);
              Would you be able to point me in the right direction please?

              Comment


                #8
                A better solution is to use the text render component and attach it to the actor you want to get data about. Then, you just use the "Set Text" method and you'll get whatever text you wanted. I usually like to attach my text render components to the associated characters or objects, or I have a few attached to my motion controllers.

                Alternatively, you can also use the "Print" command to spit output into your log file. This may be more helpful when you're trying to sift through lots of data or track down a sequence of events because the output is a lot more persistent.

                If you want to be *really* hard core, you can create a replay of your gameplay and then replay the game and reproduce any errors. I haven't done this yet, but I've wanted to.

                Comment


                  #9
                  I hope they release one button in Print String node - VRtoggle
                  Where should we send this request? Please do!

                  Comment


                    #10
                    Originally posted by matter3d View Post
                    I'm trying to implement this but I'm stuck with the blueprint library function. I have managed to get a reference to the character, but I don't know how to then get a reference to the widget that is attached to it so I can call the function. Here is my code from my blueprint library function:

                    Code:
                    	TObjectIterator<APlayerController> Itr;
                    	if (!Itr) return;
                    
                    	UWorld* TheWorld = Itr->GetWorld();
                    	if (!TheWorld) return;
                    
                    	ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(Itr->GetWorld(), 0);
                    Would you be able to point me in the right direction please?
                    I did it in Blueprint and UMG. You can look how the blueprint node 'GetAllWidgetOfClass' is set up, maybe there is something like 'TWidgetInterator'? However you would need to get the UMG class type in c++, no idea how to do this, would like to know that as well.
                    As far as I know, it is not possible to access editor created stuff in c++ (at least not possible with blueprint), see Link.

                    Originally posted by Slayemin View Post
                    A better solution is to use the text render component and attach it to the actor you want to get data about. Then, you just use the "Set Text" method and you'll get whatever text you wanted. I usually like to attach my text render components to the associated characters or objects, or I have a few attached to my motion controllers.
                    ...
                    With that solution you can only display one text at a time. You sure could write an extended component that manages a list of messages, but still you only get a single color, and now it's not that easy. You as well need to have the object visible from the right perspective to see the text. That solution may come in handy in some situations, but does not replace the default 'PrintString'. In addition you always need to place the component, and position it on every actor class. That way you have a component you dont actually need. I simply call my library function from wherever I want.
                    NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

                    Comment


                      #11
                      Thanks for posting this. I thought i was crazy that I couldn't see my messages!

                      Comment


                        #12
                        If you are using the source version you can also modify DrawOnScreenDebugMessages inside UnrealEngine.cpp. Just add this at the beginning of the function:
                        Code:
                        	if (GEngine->IsStereoscopic3D(Viewport))
                        	{
                        		MessageX += 100.0f;
                        		MessageY += 200.0f;
                        	}
                        I'm currently looking for a way to do this without having to modify the source...

                        Comment


                          #13
                          Originally posted by Rumbleball View Post
                          There is a better way to do it, but keeps it that simple:

                          Setup a Widget that is a simple vertical Box with background. Make another widget that represents a textline/block. In the first widget make a function AddText. This function has a String as input and creates a widget of the textline class. Then sets the text of the created widget and adds the new create textline to the vertical box of its own (VerticalBox->Add Child)

                          Make an actor, add WidgetComponent, set the widget class to the new component, attach it to the controller.

                          Write a FunctionLibrary function that gets the widget with the vertical box (GetAllWidgetOfClass) and calls the AddText function of the widget.

                          Now, from where ever you need debug text, call the library function.

                          To go more advanced, add a time (float) to the AddText function. That time is then passed on to the textline widget. The textline subtracts the deltaTime from tick each tick and calls RemoveFromParent when time <= 0.

                          Having a floating widget with the text in front of you is much more useable as the normal PrintString.

                          This is just the idea, you can change and adjust what ever you need, e.g. add color to the textline or set the background to the textline instead of the vertical box. So there is nothing visible when there is no text.

                          Cheers
                          I made this to a pure C++ plugin myself and improved on it. Link: https://forums.unrealengine.com/show...debugging-(VR)
                          NodePrefabs | PluginBuilder | NotificationBackbone | WidgetBox | RuntimeMeshImportExport | DebugWidget | SteamWorkshopAccessor

                          Comment

                          Working...
                          X