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 /
avatar image
2
Question by horiadev · Sep 27, 2014 at 12:39 PM · unity 4.6inputfieldscrollbar

How to create a scrollable inputfield

I am trying to add a scroll bar to an input field with no success so far.

The main issue is that the text component size doesn't change with the amount of text, which would allow for the scroll bar to detect what to scroll properly. Also when i change the size of the text area, the input field starts to get buggy.

Another option is to invoke a scroll directly when detecting a scroll wheel event. Any ideas how this might be accomplished?

Comment
Add comment · Show 3
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 Steffen D E · Feb 03, 2015 at 04:21 PM 0
Share

I'm trying to do the same, please update this if you find a solution.

avatar image Ylor · Apr 07, 2015 at 08:43 PM 0
Share

$$anonymous$$e too, anyone knows?

avatar image Orion_78 · Dec 01, 2015 at 02:57 PM 0
Share

I got exactly the same problem

I do try mixing with Scroll View with no success.

The problem is input field is not extending the text field size so my scollbar has nothing to show...

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by BadUser · May 06, 2015 at 12:48 PM

Hello horiadev,

  1. Create ScrollBar

  2. Create InputField

  3. Add ScrollRect component to InputField

  4. Add ScrollBar to ScrollRect component (field "Horizontal/Vertical scrollbar)

  5. Resize Text (Child of InputField) to your needs

  6. Add Text to ScrollRect component (field "Content")

  7. Add Mask Component to Inputfield

Comment
Add comment · Show 1 · 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 dval · Sep 17, 2015 at 05:16 PM 0
Share

This is kindof useless for accepting user input. The concept works only if you have a existing text string and know it's size, but if your accepting user input, then how can you set the size of the text rect before hand? You would have to know how much text a user is going to enter. The problem with this solution, is that the textbox inside the InputField does not accept a ContentSizeFitter and does not automatically update it's own height when text is added. It only sizes to text that exists before it is rendered. And at that point, you may as well just use a panel with a text component, and not worry about the InputField container.

avatar image
1

Answer by Orion_78 · Jan 05, 2016 at 03:22 PM

Ok, here is my solution for now :

 using UnityEngine;
 using System.Collections;
 using UnityEngine.UI;
 
 /// <summary>
 /// Display text with a scrollbar if you are not in edition mode
 /// Display an editable text (without scrollbar until Unity fix it) if IsEdition is true 
 /// </summary>
 public class UIScrollableInputField : MonoBehaviour {
 
     private bool _isEdition;
     public bool IsEdition
     {
         get
         {
             return _isEdition;
         }
         set
         {
             _isEdition = value;
 
             if (_isEdition)
             {
                 _inputFieldEditeMode.text = TextToDisplay;
                 _textViewMode.text = "";
                 _inputFieldEditeMode.gameObject.SetActive(true);
                 _scrollView.gameObject.SetActive(true);
                 _scrollbar.gameObject.SetActive(false);
             }
             else
             {
                 _inputFieldEditeMode.text = "";
                 _textViewMode.text = TextToDisplay;
                 _inputFieldEditeMode.gameObject.SetActive(false);
                 _scrollView.gameObject.SetActive(!string.IsNullOrEmpty(TextToDisplay));
             }
         }
     }
 
     private string _textToDisplay = "";
     public string TextToDisplay
     {
         get
         {
             return _textToDisplay;
         }
         set
         {
             if (TextToDisplay != value)
             {
                 if (_textToDisplay == null)
                 {
                     _textToDisplay = "";
                 }
                 else
                 {
                     _textToDisplay = value;
                 }
                 
 
                 Debug.Log("display: " + TextToDisplay);
 
                 if (IsEdition)
                 {
                     _inputFieldEditeMode.text = TextToDisplay;
                 }
                 else
                 {
                     _textViewMode.text = TextToDisplay;
                     // Hide the dialogue is nothing to display
                     _scrollView.gameObject.SetActive(!string.IsNullOrEmpty(TextToDisplay));
                 }
             }
         }
     }
 
     [SerializeField]
     private Text _textViewMode;
     [SerializeField]
     private InputField _inputFieldEditeMode;
     [SerializeField]
     private ScrollRect _scrollView;
     [SerializeField]
     private Scrollbar _scrollbar;
 }

Comment
Add comment · 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
1

Answer by illa3d · Feb 09, 2017 at 02:04 PM

Posted a hacky solution to InputField with scrollbar here:

http://answers.unity3d.com/questions/932607/putting-a-multiline-inputfield-in-a-scroll-rect.html

Comment
Add comment · 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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

How to prevent scroll from moving on text update? 1 Answer

Text Mesh Pro Input field cannot scroll to last line of inserted text. 0 Answers

How can I create a Multi line Input Field with Scrollbar? 0 Answers

Animation through Animator in unity 1 Answer

How can I divide www.texture data into multiple Texture2Ds? 0 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