Search Unity

[HACK/Solved] Entities Preview-8 : InputSystem:data Length must use the "readonly" keyword

Discussion in 'Entity Component System' started by JohnHudeski, Jul 29, 2018.

  1. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    126
    I have been having horrible luck with EQS
    This is the latest one

    ArgumentException: InputSystem:data Length must use the "readonly" keyword
    Unity.Entities.InjectComponentGroupData.CreateInjection (System.Type injectedGroupType, System.Reflection.FieldInfo groupField, Unity.Entities.ComponentSystemBase system) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Injection/InjectComponentGroup.cs:148)
    Unity.Entities.ComponentSystemInjection.Inject (Unity.Entities.ComponentSystemBase componentSystem, Unity.Entities.World world, Unity.Entities.EntityManager entityManager, Unity.Entities.InjectComponentGroupData[]& outInjectGroups, Unity.Entities.InjectFromEntityData& outInjectFromEntityData) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Injection/ComponentSystemInjection.cs:45)
    Unity.Entities.ComponentSystemBase.OnBeforeCreateManagerInternal (Unity.Entities.World world, System.Int32 capacity) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/ComponentSystem.cs:78)
    Unity.Entities.ComponentSystem.OnBeforeCreateManagerInternal (Unity.Entities.World world, System.Int32 capacity) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/ComponentSystem.cs:310)
    Unity.Entities.ScriptBehaviourManager.CreateInstance (Unity.Entities.World world, System.Int32 capacity) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/ScriptBehaviourManager.cs:21)
    Unity.Entities.World.CreateManagerInternal (System.Type type, System.Int32 capacity, System.Object[] constructorArguments) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Injection/World.cs:162)
    Unity.Entities.World.GetOrCreateManagerInternal (System.Type type) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Injection/World.cs:190)
    Unity.Entities.World.GetOrCreateManager (System.Type type) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Injection/World.cs:243)
    Unity.Entities.DefaultWorldInitialization.GetBehaviourManagerAndLogException (Unity.Entities.World world, System.Type type) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:21)
    UnityEngine.Debug:LogException(Exception)
    Unity.Debug:LogException(Exception) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities/Stubs/Unity/Debug.cs:25)
    Unity.Entities.DefaultWorldInitialization:GetBehaviourManagerAndLogException(World, Type) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:25)
    Unity.Entities.DefaultWorldInitialization:CreateBehaviourManagersForMatchingTypes(Boolean, IEnumerable`1, World) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:91)
    Unity.Entities.DefaultWorldInitialization:Initialize(String, Boolean) (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities.Hybrid/Injection/DefaultWorldInitialization.cs:57)
    Unity.Entities.AutomaticWorldBootstrap:Initialize() (at C:/Users/Mephisto's Place/AppData/Local/Unity/cache/packages/packages.unity.com/com.unity.entities@0.0.12-preview.8/Unity.Entities.Hybrid/Injection/AutomaticWorldBootstrap.cs:11)


    The only place I make reference to Input is here

    Code (csharp):
    1.  
    2. public class InputSystem : ComponentSystem
    3. {
    4.     struct Data
    5.     {
    6.         public int Length;
    7.         public ComponentArray<InputComponent> InputComponents;
    8.     }
    9.  
    10.     [Inject]
    11.     Data data;
    12.  
    13.     protected override void OnUpdate()
    14.     {
    15.         //Optimization. Cache the result outside the loop
    16.         var h = Input.GetAxis("Horizontal");
    17.         var v = Input.GetAxis("Vertical");
    18.  
    19.         for (int i =0; i < data.Length; ++i)
    20.         {
    21.             data.InputComponents[i].horizontal = h;
    22.             data.InputComponents[i].vertical = v;
    23.         }
    24.     }
    25. }
    26.  
    27.  
    Code works fine in Preview-6

    Time between hitting the play button and actually playing is also noticeable
    and every play begins with this error

    System.ComponentModel.Win32Exception (0x80004005): ApplicationName='"C:\Users\Mephisto's Place\AppData\Local\Unity\cache\packages\packages.unity.com\com.unity.incrementalcompiler@0.0.42-preview.12\.bin\csc.exe"', CommandLine='--server --watchdog=12124 --port=5047 --workingDirectory="E:\Unity Projects\ECS-AI"', CurrentDirectory='E:\Unity Projects\ECS-AI', Native error= The system cannot find the file specified.

    at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002dc] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at System.Diagnostics.Process.Start () [0x0003a] in <343bdfbb3c2d4d21b745a87548c1a7cd>:0
    at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    at UnityEditor.Compilation.CompilerConnection.StartIncrementalCompilerProcess () [0x0009a] in <7f5896f986c54cae8a8ba335f1aca335>:0
    at UnityEditor.Compilation.CompilerConnection.InitializeSingleton () [0x00041] in <7f5896f986c54cae8a8ba335f1aca335>:0
    at UnityEditor.Compilation.RoslynCompilerBootstrap..cctor () [0x0000a] in <7f5896f986c54cae8a8ba335f1aca335>:0
    UnityEditor.EditorAssemblies:processInitializeOnLoadAttributes()
     
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    I can diagnose your first issue, at least.

    They changed the injection setup in newer releases so that the length field is now required to be marked as readonly

    Code (CSharp):
    1. struct Data
    2. {
    3.     //...
    4.     public readonly int Length; // must now be marked as readonly if present
    5.     public readonly int GroupIndex; // optional, can use it to define the component group via injection, but still use the filtering options via the ComponentGroups indexer now accessible in JobComponentSystem and ComponentSystem, I don't recall exactly which preview it was added in, but I have the latest working.
    6. }
    See if that helps on preview-8
     
    JohnHudeski likes this.
  3. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    126
    To get any package working i have to delete the library folder each time

    If not i get these
     
  4. JohnHudeski

    JohnHudeski

    Joined:
    Nov 18, 2017
    Posts:
    126
    HAHAHAHAHAHA
    I cheated the system. I just dumped all the files I needed into the asset folder and it worked
    Down with the package manager

    This is the only Error you get and it doesn't seem to matter

     
    recursive likes this.