Search Issue Tracker

Fixed in 0.2.0

Votes

1

Found in [Package]

0.1.0

Issue ID

1176847

Regression

No

InvalidCastException is thrown when GameObject with Physics Shape component is selected in Entity Debugger

Package: Entity Component System (ECS)

-

How to reproduce:
1. Open the attached project ("PhysicsBug.zip") and open SampleScene
2. Open Entity Debugger window (Window->Analysis->Entity Debugger)
3. Enter PlayMode
4. In Entity Debugger window select Plane GameObject

Expected result: No exception is thrown
Actual result: InvalidCastException is thrown

Reproducible with: 2019.2.2f1 (Unity Physics 0.2.0), 2019.3.0a12 (0.2.0), 2020.1.0a1 (0.2.0)
Not reproducible with: 2017.4.32f1 (Packet Manager was not present), 2018.4.7f1 (Unity Physics was not present), 2019.2.0a14 (Errors in collections package), 2019.3.0a9 (Errors in Render Pipeline and dependencies)

Comments (2)

  1. shiroto

    Dec 16, 2019 14:21

    For anyone looking for a quick fix (this will not let you see the data of the PhysicsCollider, but at least you can see all the other data):
    1. Find the PropertyVisitor.cs in Packages/Properties/Runtime/Unity.Properties.
    2. Open it in an editor.
    3. Find the method with the following signature (should be around line 45): public VisitStatus VisitProperty<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref ChangeTracker changeTracker) where TProperty : IProperty<TContainer, TValue>
    4. Replace the entire method with the following code:
    public VisitStatus VisitProperty<TProperty, TContainer, TValue>(TProperty property, ref TContainer container, ref ChangeTracker changeTracker)
    where TProperty : IProperty<TContainer, TValue>
    {
    try
    {
    // Give users a chance to filter based on the data.
    if (IsExcluded<TProperty, TContainer, TValue>(property, ref container))
    {
    return VisitStatus.Handled;
    }

    var value = property.GetValue(ref container);
    var valueChangeTracker = new ChangeTracker(changeTracker.VersionStorage);

    var status = property.IsContainer
    ? TryVisitContainerWithAdapters(property, ref container, ref value, ref valueChangeTracker)
    : TryVisitValueWithAdapters(property, ref container, ref value, ref valueChangeTracker);

    if (property.IsReadOnly)
    {
    return status;
    }

    property.SetValue(ref container, value);

    if (valueChangeTracker.IsChanged())
    {
    changeTracker.IncrementVersion<TProperty, TContainer, TValue>(property, ref container);
    }

    return status;
    }
    catch (System.Exception ex)
    {
    UnityEngine.Debug.LogWarning(ex.ToString());
    return VisitStatus.Unhandled;
    }
    }

    5. The exception is now caught and you can use the inspector on entities with a PhysicsCollider component.

  2. xontik

    Oct 17, 2019 21:03

    Same issue in 2019.3.7b

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.