- Home /
The question is locked til example of what have you tried is added to the question. "I only require a C# script from you" wont do here.
Unity 5.3 - How do you Grab textfrom InputField in C# Script?
A Quick Note
I have changed the description of what I'm doing so that it is easier to grasp the basic information. I am also a complete beginner at Unity, so please correct me if I go wrong anywhere.
The Topic
The question title is very broad, but the main goal is to get a user to enter their username in the first InputField, their email in the second InputField, and the chat server in the third InputField. The "chat server" is really just a folder consisting of text documents of which are logs.
The Goal
The goal for me is to have a C# script that when a button is pressed, it grabs the information from the 3 InputFields, and write to "D:[ChatServer]\log.txt" a join message, such as:"[Username] contacted at [Email] Joined!"
What I Require
I only require a C# script from you that just has to have the code for grabbing information from 3 InputFields when a button is pressed. It would be very nice of you if you would specify where to put and attach the script as well.
How the Project has been Setup
The project consists of a Canvas first being created using the UI within the unity editor. The first InputField created was the username, the second being the email, and the third being the chat server. Then a button was created, and attached to the button is a script that detects when the button has been pressed.
The Project's Looks
I have uploaded some images for you to look at, for reference. Image 1 - The Hierarchy: http://prntscr.com/bejy4n Image 2 - The First InputField [Username] : http://prntscr.com/bejyea Image 3 - The Second InputField [Email] : http://prntscr.com/bejyks Image 4 - The Third InputField [ChatServer] : http://prntscr.com/bejysr
My Apologies and Thanks
I thank you for your reply, as it might provide some light to my problem, and if you fixed the problem, my congratulations and thanks for you being a dedicated Unity user, and helping others just as you would like them to help you, and giving complete beginners at Unity a helping hand, even when their message doesn't quite make sense.
My apologies to all who think of my question to be very precise and demanding on the result, I am sorry for being rude, as I do not wish for myself to come off rude or demanding. I also apologize for my question coming off as some sort of "License Agreement" with sections, as I wouldn't like to have a simple question I am going to answer look like a license agreement.
This has been asked before, on both answers.unity3d.com and stackoverflow.com. Good luck!
@jlmakes The thing is however, I made my InputField with the Unity UI Editor. I don't know how to rename it, if you could please tell me how, I'd be satisfied :)
Answer by xXx12aithexXx · Jun 10, 2016 at 04:34 PM
you need to assign the the inputfield to a variable then you send the variable to the document.
Follow this Question
Related Questions
Why Is My Reset Button for my high score ? Here is my copied script. 0 Answers
Refresh panel with prefab contained value from json that created using array 0 Answers
Object reference not set to an instance of an object 1 Answer
My sphere is not moving in the unity? 1 Answer
How do I make the winning racer get a text saying Congrats? 1 Answer