So I made a branch new project in Unity 5.3.5p3 (a little bit older than the one you’re using, but that’s what I had installed and they should be pretty close), attached this script to an object and built to UWP:
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
private string m_Name = string.Empty;
private Rect m_InputZone = new Rect(100, 100, 200, 80);
private void OnGUI()
{
m_Name = GUI.TextField(m_InputZone, m_Name);
}
}
Seems to work just fine… Do you have a sample demonstrating it being broken? Do you get any exception thrown?
I tried your small sample and it worked fine, so I dug deeper into my code and I found the culprit !
if (Event.current.button > 0
&& Event.current.type != EventType.Layout
&& Event.current.type != EventType.Repaint)
{
if (IsMouseOnGui())
Event.current.Use();
return;
}
It was at start of my OnGUI()
I’m not sure why I had done that, but it was likely for optimization and maybe to avoid clicking on 3D stuff behind the GUI.
I moved it at end of my OnGUI() and everything seems to be still working, so I’ll keep it like that.
Maybe it could be considered as an Unity bug as this GUI behavior isn’t the same on UWP.
@Tautvydas-Zilys ,
I found out why I did that and now I’m sure it’s a bug : it’s to catch right & middle mouse clicks, to prevent them to activate GUI Button & stuff.
To the best of my knowledge, this is the way to do that ; it matches this at least : Unity - Scripting API: Event.button & Unity - Scripting API: Event.Use . Plus it works in Debug, but fails in Master. Usually, I can enter 1 character before it stops to work. It fails both with and without the “return;”
But it’s not the main point of this message.
I got an exception with touch screen devices when the user click on the GUI.Textfield() input zone. It happened to my customer, to the Microsoft certification Team with the update I uploaded 3 days ago, and also when I run my game in the Visual Studio Simulator :
I reported the bug with a test project : # 959376 .
Please let me know if you think of a workaround, because I guess I can’t hope for a bug fix at this point for Unity 5.3…
How maybe I could fix something on the Visual Studio side…?
Despite the text input working in the simulator with a XAML build while it was causing an exception with a D3D build, the update still crashes for the Windows Certification Team, so I guess I’m back to square one…
No, I didn’t try that. I even didn’t succeed debugging C# when I hunted another bug (I had to fix it by using my brains, the horror ).
I could try, but to where would it lead me ? It’s relatively clear the crash is on Unity side as it’s working on 5.6, and I’m short on options now. I think the only thing left to do is to disable GUI.Textfield when there’s no physical keyboard (which is a bit problematic as I need the user to enter a name when creating custom characters).
The project in bug report shown above doesn’t use anything, only a script handling the GUI elements.
Anyway, I just converted my project to 5.6, and amazingly, except hundred of warning messages because I have negative scaling values for my colliders, it seems my game is still working…!
I’ll fix that bunch of colliders & play a couple of hours to be sure everything is alright, and hopefully I’ll be done with it…!
I’ll let you know if I finally pass the Windows AppStore checking…
Microsoft finally accepted the new version and it’s in the store now !
I had to remove support for Windows Mobile to get this result, but as of today, I guess no mobile is powerful enough to run the game.
According to Microsoft Team, the game was silently crashing during loading on Lumia 1520 & Lumia 950 ; none of them is meeting the minimum requirements I had specified in the App Details, but it didn’t stop them to refuse my game for that reason…