Closed slimshader closed 4 years ago
To clarify: it seems uREPL is missing the decimal point (making 1.73 into 173) but negative values seem to overflowed, could it be a conversion issue (possibly by default Locale)?
I've checked it with Unity 2018.4.3f1 in both Windows and Mac, but I couldn't reproduce the bug.
Could you provide some more information like Configulation? My setting is below:
Tried with uREPL 5.0 5.1 and 6.0 in Unity 2018.4.3 and 2018.4.8 in both Net Standard 2.0 and NET 4.x, problem persists for me.
Could you check the Content Type
of the Input Filed
-s?
I guess it accidentally changed to Integer Number
from Decimal Number
. If so, please fix
them in Resources > uREPL > Prefabs > Output > GameObject Item, or delete uREPL directory and import .unitypackage again (I've tested from an empty scene and it had no problem).
It is Decimal Number, re-imported to fresh project multiple times. But Text if Input Fields says for example "173" where transform value is 1.73
Sorry for giving many requests... but I'm very glad if you continue to try these items:
1.234
to the position field directly?InputField
-s in FieldInputTest
component?https://github.com/hecomi/uREPL/blob/086f03a29223b614c9a29f3e1763f841a0fd453f/Assets/uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs#L53-L59
(rotX
is UnityEngine.UI.InputField
)
So could you insert Debug.Log
-s just after the getter in uREPL/Scripts/Gui/OutputItems/GameObjectItem.cs like this?:
...
public Quaternion rotation
{
get
{
return Quaternion.Euler(
float.Parse(rotX.text),
float.Parse(rotY.text),
float.Parse(rotZ.text));
}
protected set
{
var euler = value.eulerAngles;
rotX.text = euler.x.ToString();
rotY.text = euler.y.ToString();
rotZ.text = euler.z.ToString();
Debug.Log(euler.x.ToString()); // <=== insert
Debug.Log(rotX.text); // <=== insert
}
}
...
No problem happy to help.
As I suspected, it seems to float <-> string conversion issue. float.Parse(rotX.text) throws for me because in my Culture it expects "1,73" instead of "1.73", problem is Unity InputField with Decimal Number settings does not allow to enter "," :/
The possible solution would be to use explicit "en_us" CultureInfo when Parse()/ToString()
var x = float.Parse(str, CultureInfo.GetCultureInfo("en-US"));
this indeed parses "1.73" correctly on my machine.
The solution (and the problem) is discussed in here:
Indeed, doing:
public Vector3 position
{
get
{
return new Vector3(
float.Parse(posX.text, CultureInfo.GetCultureInfo("en-US")),
float.Parse(posY.text, CultureInfo.GetCultureInfo("en-US")),
float.Parse(posZ.text, CultureInfo.GetCultureInfo("en-US")));
}
protected set
{
posX.text = value.x.ToString(CultureInfo.GetCultureInfo("en-US"));
posY.text = value.y.ToString(CultureInfo.GetCultureInfo("en-US"));
posZ.text = value.z.ToString(CultureInfo.GetCultureInfo("en-US"));
}
}
I know code is ugly and should have just write dedicated parse method (possible extension method) but it illustrates the point
fixes position values both ways:
Thank you very much for giving the solution! (and I overlooked your suggestion in https://github.com/hecomi/uREPL/issues/21#issuecomment-526483494).,,
I'll fix it in the next release soon.
I added some exntension methods that uses CultureInfo
and pushed the commit. Could you check it when you have time in your environment?
All looking good now :) Interesting artifact is only values of negative rotation values (wrapped to positive):
It works fine tho, just looks bit off
The positive value comes from transform.eulerAngles
directly and I haven't checked the difference between it and the rotation value in Transform
inspector. For now I'll release the current version as the next one but in the future if I understand the difference (or someone tells it), I'll fix this behavior (or not depending on the reason).
Thank you so much for reporting this bug and helping me fix it!
Latest version shows incorrect rtansform valies when using Inspect(), tested on Unity 2018.4.3