Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 ratchet01 · Dec 25, 2017 at 10:11 PM · uiinputlinuxubuntulinux editor

each character doubled in inputfield in build but not editor on ubuntu 16.04

Since upgrading to 2017.3.0f1 (from 2.0f3), I have a strange problem with an UI input field where each typed character is doubled:

"hello, world" --> "hheelllloo,, wwoorrlldd"

This is not happening when I play in the editor, but only when I build. I can reproduce the problem with a fresh game that consists of just the base scene and an input field. (happy to attach a file, but it's really simple to reproduce). The same minimal project works normally when compiled using 2017.2.0f3.

I'm reluctant to submit it as a bug because strangely enough the compiled game runs normally on an archlinux system (I mean the actual file compiled on the ubuntu machine works normally on the arch machine).

the game works normally when compiled for windows by a windows version of the 2017.3 editor.

So the setup with the weird behavior is running Ubuntu 16.04 with Unity 2017.3.0f1.

I don't really know where to begin trouble shooting this.

any suggestions greatly appreciated.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by lolisamurai · Jan 04, 2018 at 03:11 PM

same issue here. i tried debugging unity's InputField and it appears that the Event.PopEvent loop gets two keyDown events instead of one... i guess the problem is related to some change they did to the native code that deals with xlib events on linux. guess I'm gonna be opening a bug report since they don't have a public source to check and I'm not too good at reverse engineering /shrug

here is a temporary horrible workaround for the issue. if you want to be sure it doesn't break when they change InputField's internals you are better off making an entire copy of the class with the workaround.

 using UnityEngine.Events;
 using UnityEngine.EventSystems;
 using UnityEngine.UI;
 using System.Reflection;
 
 // a horrible hack to work around input duplication bugs on linux
 public class InputFieldWithWorkarounds : InputField {
 
     int keyDownCount = 0;
     bool workAroundDuplicatedKeystrokesBug = false;
 
     static FieldInfo GetPrivateFieldObject(string name) {
         return typeof(InputField).GetField (
             name, BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Instance
         );
     }
 
     void SetPrivateField(string name, System.Object value) {
         GetPrivateFieldObject (name).SetValue (this, value);
     }
 
     System.Object GetPrivateField(string name) {
         return GetPrivateFieldObject (name).GetValue (this);
     }
 
     bool m_ShouldActivateNextUpdate {
         set { SetPrivateField ("m_ShouldActivateNextUpdate", (System.Object)value); }
         get { return (bool)GetPrivateField ("m_ShouldActivateNextUpdate"); }
     }
 
     Event m_ProcessingEvent {
         set { SetPrivateField ("m_ProcessingEvent", (System.Object)value); }
         get { return (Event)GetPrivateField ("m_ProcessingEvent"); }
     }
 
     void ActivateInputFieldInternal() {
         MethodInfo method = typeof(InputField).GetMethod(
             "ActivateInputFieldInternal", BindingFlags.NonPublic | BindingFlags.Instance
         );
         method.Invoke(this, new object[] {});
     }
 
     protected override void Start () {
         base.Start ();
         workAroundDuplicatedKeystrokesBug = Application.unityVersion == "2017.3.0f1"
             && Application.platform == RuntimePlatform.LinuxPlayer;
     }
     
     public override void OnUpdateSelected(BaseEventData eventData)
     {
         if (!workAroundDuplicatedKeystrokesBug) {
             base.OnUpdateSelected (eventData);
             return;
         }
 
         // Only activate if we are not already activated.
         if (m_ShouldActivateNextUpdate)
         {
             if (!isFocused)
             {
                 ActivateInputFieldInternal();
                 m_ShouldActivateNextUpdate = false;
                 return;
             }
 
             // Reset as we are already activated.
             m_ShouldActivateNextUpdate = false;
         }
 
         if (!isFocused)
             return;
 
         bool consumedEvent = false;
         while (Event.PopEvent(m_ProcessingEvent))
         {
             Event ev = m_ProcessingEvent;
             if (ev.rawType == EventType.KeyDown)
             {
                 if (ev.keyCode != KeyCode.Return && keyDownCount++ % 2 != 0) {
                     continue;
                 }    
 
                 consumedEvent = true;
                 var shouldContinue = KeyPressed(ev);
                 if (shouldContinue == EditState.Finish)
                 {
                     DeactivateInputField();
                     break;
                 }
             }
         }
 
         if (consumedEvent)
             UpdateLabel();
 
         eventData.Use();
     }
 }

Comment
Add comment · Show 3 · 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 lolisamurai · Jan 04, 2018 at 04:09 PM 1
Share

I opened a bug report here: https://fogbugz.unity3d.com/default.asp?984740_fsdqmmud49i76sdo

avatar image MaxGuernseyIII · Jan 04, 2018 at 06:30 PM 0
Share

This seems like the answer...

avatar image lolisamurai MaxGuernseyIII · Jan 04, 2018 at 06:58 PM 0
Share

UPDATE: I updated the workaround with a few $$anonymous$$or fixes for bugs i encountered with further testing

avatar image
1

Answer by ratchet01 · Feb 15, 2018 at 05:13 PM

This is a known regression. The bug is tracked here: https://issuetracker.unity3d.com/issues/linux-keystrokes-recorded-twice If you are affected by this issue, please upvote the issuetracker page. (lolisamurai's bug report posted in comments was closed as a duplicate)

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

86 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to made VsCode default editor on Ubuntu? 2 Answers

Building asset bundles on an ubuntu docker container 1 Answer

Ubuntu Editor and "Dash To Panel" GNOME Shell extension issue 0 Answers

Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers

How to run the exported game on ubuntu 5 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