Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can I export a text report?

Discussion in 'Editor & General Support' started by WillowWake, Sep 30, 2020.

  1. WillowWake

    WillowWake

    Joined:
    Apr 9, 2014
    Posts:
    8
    Hi, a simple question if anyone has time -- can I get Unity to capture a series of text strings and output this as a text document (.doc, pdf, any format is fine)?

    What I'm trying to do is allow the user to export a kind of text doc report based on text they've typed in to different fields. I can't see anything suitable in the asset store.

    I'm currently working with Playmaker/Behaviour Designer because I don't have much coding experience. I want to establish whether this is at all possible before I start my planned project.

    Sorry if this is really basic stuff! Many thanks for your time.
     
  2. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Are you trying to build regular business software that looks like for example WinForms? Labels and input fields and a button that starts some processing and then saves a text file onto the hard drive? This can be done in Unity but requires knowledge about the UI system and scripting. Visual scripting can help with a lot of logic, but I'd say you will still need at least some custom code to handle the file export.

    I'd go with a simple text file export (txt or rtf) since doc and pdf is more difficult to get right and you would need a library for that, but possible.
     
    WillowWake likes this.
  3. WillowWake

    WillowWake

    Joined:
    Apr 9, 2014
    Posts:
    8
    Hi, many thanks for the reply. Yes, those functions are what I'm looking for. My aim isn't a business app as such but a creative writing tool with some game elements. I'd need the player/user to be able to export what they've written in the input fields to a text document.

    I really need to learn more about scripting and UI, but before I got into that I just wanted to see whether it was at all possible in Unity...you've answered my question. Much appreciated!
     
  4. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Here is a quick sample of how something like this can work in Unity:

    upload_2020-9-30_20-36-56.png

    And see the attached project if you like. Basically, with two lines of code and hooking up a button to a text input field, you can save a text file on any desktop platform.
     

    Attached Files:

    WillowWake likes this.
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Unity can do all the regular C# text and binary file reading/writing any other C# application can. So you can look at any C# tutorial on the topic, or any thread on any other C# related forum.

    If you're wanting to do this entirely through visual scripting, I don't believe you'll be able to.
     
    WillowWake likes this.
  6. WillowWake

    WillowWake

    Joined:
    Apr 9, 2014
    Posts:
    8
    That's exactly what I'm looking for!

    Thanks so much for your help on this.
     
    Joe-Censored likes this.
  7. WillowWake

    WillowWake

    Joined:
    Apr 9, 2014
    Posts:
    8
    Thanks. Yes, I need to educate myself on C# because they'll be plenty of other challenges along the way. I just wanted to make sure I wasn't expecting the impossible to begin with :)
     
    Joe-Censored likes this.
  8. RiRiM

    RiRiM

    Joined:
    Aug 23, 2021
    Posts:
    1
    I am very curious as to what exactly you are trying to create. Is it business software or is it a very innovative game? Upon reading this I immediately thought about this digital vault platform that we use for file sharing and safekeeping in the company that is my main job. However, it also gave me a sudden surge of very innovative and interesting ideas for indie games. That is why I am asking, this functionality is pretty versatile and I’m not quite sure what it might be that you are making. I have never heard about someone using Unity to develop something other than games. Is it a common practice? Is it even suitable for something like this?
     
    Last edited: Aug 25, 2021