1
\$\begingroup\$

I have recently updated my forked project from .NET 3.5 to .NET 4.6, and for some reason (even though Unity3D advises that there isn't any problem) my project doesn't load things correctly:

By default nothing should change about how Unity behaves or what .NET functionality is available.

Nothing should change, but now ground doesn't load in some parts of the same.

I have inspecting code, and well, I found that some functions aren't behaving as expected. (I didn't debugged them succesfully because if use Debug class, Unity stucks, and if use breakpoints I never find something relevant).

I have realized that some objects are disabled once they are loaded.

...

For example roads aren't loaded.

...

We select a object to know where it's located.

...

And here it is.

...

As we can see it's disabled. (I couldn't find any object under the player)

Trying to understand what's happening

This fact notices me that something is setting Gameobject field enabled to false or SetActive(false).

So, I searched in all the project and I found this:

...

The most probable case is the one from StaticGeometry:

https://github.com/z3nth10n/SanAndreasUnity/blob/40b95f56feb021aac13364d055424283b695d1bb/Assets/Scripts/Behaviours/World/StaticGeometry.cs#L65

In this case, the object is disabled once it's loaded (as I can see).

https://github.com/z3nth10n/SanAndreasUnity/blob/40b95f56feb021aac13364d055424283b695d1bb/Assets/Scripts/Behaviours/World/StaticGeometry.cs#L178

In this case if the object isn't visible it doesn't display.

And as you can see in line 31, if _isVisible is the same value as value then we exit, so, keeping in mind that _isVisible is false from the beginning we can say, that somewhere the IsVisible variable is being setted as false, and that happens on line 186 (Hide() method), that is called on:

...

This method is called in:

https://github.com/z3nth10n/SanAndreasUnity/blob/40b95f56feb021aac13364d055424283b695d1bb/Assets/Scripts/Behaviours/World/StaticGeometry.cs#L109

... if ShouldBeVisible() returns false.

https://github.com/z3nth10n/SanAndreasUnity/blob/40b95f56feb021aac13364d055424283b695d1bb/Assets/Scripts/Behaviours/World/StaticGeometry.cs#L70

In line 72, line 83, line 86, line 94.

... or in the same IsVisible property.

https://github.com/z3nth10n/SanAndreasUnity/blob/40b95f56feb021aac13364d055424283b695d1bb/Assets/Scripts/Behaviours/World/StaticGeometry.cs#L40

if the value that is being setted is true and LodChild is not null then we have to hide LodChild, why? I can't continue here, because I don't understand this logic.

My assumptions on what's going on

Returning back to the road photo:

...

If we look in it's localPosition it looks weird.

But this is more weird:

...

Splits (that are baically chunks) are loaded so far away. (That's more weird, there is an unit problem as I can see).

But weirdest things are happening, for example, roads under other positions load correctly.


Other issue for example is that cars doesn't spawn, I think that is because there isn't any ground, when there is ground they spawn, but they pass through it, so the ground doesn't load or if it loads it's not solid where the player stands (maybe because of ShouldBeVisible() issue?)

If we spawn a vehicle using V key, they spawn, but it's wheels are very big.

...

If we watch its scale is about 10, if we set it to 1 then we recover the normal shape.

...

(I don't have photo of scale = 1, but I have already test it)

So, I said my assumptions is that something is returning bad numbers, they are multiplied.

I have looked into float.Parse, and yes, I found something, but I can't debug it due to big amount of data.

And there is the value... So, a possible problem is that because of my Culture, .NET is parsing this value as millions instead of thousands. And in .NET 3.5 this feature isn't available. I will search how to fix it.

Another fact is sustains my assumption is this:

...

...

As you can see position number on the X axis is very big.

So, I will ty to search it on the GTA SA files.


I have checked for empty catch statments, but I found nothing.

The project is being builded correctly. And If you return the version back to 3.5, everything works again well.

So, what can be happening here? I need to know if I have to keep in mind some fact after upgrading, also, I have searched in:

https://unity3d.com/es/search?refinement=issues&gq=.net%204.x

But didn't find anything.

\$\endgroup\$
0
\$\begingroup\$

Well, as it's not documented, I want to contribute with my own discoverties.

The first thing I realized is that when you convert to a string a float float.ToString, the output is the following -> 1,4050 for 1.4050f...

That fact said me that float.Parse has to work on a similar way: http://rextester.com/RPFNFS6685

...

...

...

This is causes because I'm spanish and my system CultureInfo is ES-ES, so if we force it to EN-US, the problem is solved. (This feature seemsn that isn't available on .NET 3.5)

    private static CultureInfo _enUs;

    private static CultureInfo enUs
    {
        get
        {
            if (_enUs == null) _enUs = new CultureInfo("en-US");
            return _enUs;
        }
    }

public float GetSingle(int index)
{
    return float.Parse(_parts[index], enUS);
}

Test: http://rextester.com/ENU16738

...

Now it works correctly.

PD: I will keep this updated as I find more issues.

\$\endgroup\$
  • 1
    \$\begingroup\$ You should use CultureInfo.InvariantCulture instead of an instance of EN-US. \$\endgroup\$ – Ed Marty May 27 '18 at 16:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.