Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Naming your component field "Type" crashes and messes up your project *Solution in Post

Discussion in 'Project Tiny' started by THAMATRIX, Oct 31, 2019.

  1. THAMATRIX

    THAMATRIX

    Joined:
    Sep 6, 2018
    Posts:
    6
    So i found this bugg when after releading my entitygroup, some entities suddenly dissapeared and in responce alot of reference where broken aswell.

    In the console i got this error:
    InvalidCastException: Invalid cast from 'System.String' to 'Unity.Properties.IPropertyContainer'.
    System.Convert.DefaultToType (System.IConvertible value, System.Type targetType, System.IFormatProvider provider) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    System.String.System.IConvertible.ToType (System.Type type, System.IFormatProvider provider) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    System.Convert.ChangeType (System.Object value, System.Type conversionType, System.IFormatProvider provider) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    System.Convert.ChangeType (System.Object value, System.Type conversionType) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
    Unity.Properties.TypeConversion.Convert[TDestination] (System.Object source) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/TypeConversion.cs:344)
    Unity.Properties.TypeConversionExtensions.GetValue[TValue] (Unity.Properties.IPropertyContainer container, System.String name) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/TypeConversion.cs:416)
    Unity.Tiny.TinyUpdater.UpdateObjectType (Unity.Properties.IPropertyContainer object) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Core/TinyUpdater.cs:99)
    Unity.Tiny.TinyUpdater+TinyObjectMigrationVisitor.BeginContainer[TContainer,TValue] (TContainer container, Unity.Properties.VisitContext`1[TValue] context) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Core/TinyUpdater.cs:141)
    Unity.Properties.ObjectContainer+Properties+ClassValueProperty.Accept (Unity.Properties.ObjectContainer container, Unity.Properties.IPropertyVisitor visitor) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/ObjectContainer.cs:229)
    Unity.Properties.ValueClassPropertyBase`2[TContainer,TValue].Accept (Unity.Properties.IPropertyContainer container, Unity.Properties.IPropertyVisitor visitor) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/Value/ValueProperty.cs:69)
    Unity.Properties.PropertyBag`1[TProperty].Visit[TContainer] (TContainer container, Unity.Properties.IPropertyVisitor visitor) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/PropertyBag.cs:94)
    Unity.Properties.PropertyContainer.Visit[TContainer] (TContainer container, Unity.Properties.IPropertyVisitor visitor) (at Library/PackageCache/com.unity.properties@0.4.0-preview/Unity.Properties/PropertyContainerVisit.cs:20)
    Unity.Tiny.TinyUpdater.UpdateObjectType (Unity.Properties.IPropertyContainer object) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Core/TinyUpdater.cs:95)
    Unity.Tiny.Serialization.CommandStream.CommandFrontEnd.AcceptEntity (Unity.Properties.ObjectContainer container, Unity.Tiny.IRegistry registry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Serialization/CommandStream/CommandFrontEnd.cs:361)
    Unity.Tiny.Serialization.CommandStream.CommandFrontEnd.Accept (System.IO.Stream input, Unity.Tiny.IRegistry registry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Serialization/CommandStream/CommandFrontEnd.cs:191)
    UnityEngine.Debug:LogException(Exception)
    Unity.Tiny.Serialization.CommandStream.CommandFrontEnd:Accept(Stream, IRegistry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Runtime/Runtime/Serialization/CommandStream/CommandFrontEnd.cs:230)
    Unity.Tiny.LoadTransaction:Commit(IRegistry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/Persistence/Persistence.cs:273)
    Unity.Tiny.Persistence:LoadMainAsset(String, IRegistry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/Persistence/Persistence.cs:904)
    Unity.Tiny.Persistence:LoadProject(String, IRegistry) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/Persistence/Persistence.cs:827)
    Unity.Tiny.TinyEditorApplication:LoadProject(String, TinyContext) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/Windows/TinyEditorApplication.cs:524)
    Unity.Tiny.TinyEditorApplication:LoadProject(String) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/Windows/TinyEditorApplication.cs:512)
    Unity.Tiny.UTProject:OnOpenAsset(Int32, Int32) (at Library/PackageCache/com.unity.tiny@0.14.5-preview/Editor/ScriptableObject/UTProject.cs:23)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    After some debugging/testing i found out what the problem was. Every single time i tried to add a component to an entity and tried to relead the entitygroup the same error popped up and the same entities got deleted as before. The only field on this component was a String field named "Type". I hope u guys can do something with this information.
     
  2. egonaraujo

    egonaraujo

    Joined:
    Jan 21, 2015
    Posts:
    11
    I do not know how the editor didn't warn you or something, but "Type" is a class and, as such, will cause errors when you compile (which unity does every time a script was changed and focus is back on the editor).

    It is roughly the same as creating:
    Code (CSharp):
    1. publict struct Example : IComponentData
    2. {
    3.     float String;
    4.     SceneReference ComponentSystem;
    5. }
    and so on.

    Why did this broke the Unity UI I have no idea, but a compilation error should have stopped the process of compilation in my opinion.

    P.S.: This "Type" class was found on Project Tiny 16.1, but I would assume the 14.5 also have this class (Is the parameter of "World.GetExistingSystem(Type t)")