Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unexpected error during execution

Discussion in 'Project Tiny' started by DiegoDiKronos, May 14, 2019.

  1. DiegoDiKronos

    DiegoDiKronos

    Joined:
    Apr 26, 2019
    Posts:
    5
    I have a simple code that changes the color of a button and saves it as "selected" to compare later with an array if is a correct answer, the problem is that i always have this error:

    uncaught exception: abort("Assertion failed: ut::ComponentRegistry::getComponentInfo(type).sizeInChunk == byteSize

    At first i thought it was because i have a lot of world.foreach over the same elements, but i changed the code avoiding it and the error keeps happening.
     
  2. reallyhexln

    reallyhexln

    Joined:
    Jun 18, 2018
    Posts:
    69
    Could you please describe how you save button "selected" state?
    For now it's a difficult to determine why such issue can occurs. It seems you use Tiny component api in some unexpected way.
     
  3. DiegoDiKronos

    DiegoDiKronos

    Joined:
    Apr 26, 2019
    Posts:
    5
    I use a copy of the button component in Tiny Arms, for the "selected" i use a custom component with a boolean but now i simply use a copy of the entity to compare later so i have to remove it.
    These two are the metods that fails:

    Code (JavaScript):
    1. static setAnswer(ansCol: number, ansLine: number, field: ut.Entity, world: ut.World): void {
    2.             world.setComponentData(field, world.getComponentData(field, ut.Core2D.Sprite2DRenderer).color = selColor);
    3.             world.setComponentData(field, world.getComponentData(field, game.G1_TextID).isSelected = true);
    4.             switch (ansCol) {
    5.                 case 0:
    6.                     if (choosenFirst == null) {
    7.                         choosenFirst = field;
    8.                     } else {
    9.                         world.setComponentData(choosenFirst, world.getComponentData(choosenFirst, ut.Core2D.Sprite2DRenderer).color = clearColor);
    10.                         world.setComponentData(choosenFirst, world.getComponentData(choosenFirst, game.G1_TextID).isSelected = false);
    11.                         choosenFirst = field;
    12.                     }
    13.                     break;
    14.                 case 1:
    15.                     if (choosenSecond == null) {
    16.                         choosenSecond = field;
    17.                     } else {
    18.                         world.setComponentData(choosenSecond, world.getComponentData(choosenSecond, ut.Core2D.Sprite2DRenderer).color = clearColor);
    19.                         world.setComponentData(choosenSecond, world.getComponentData(choosenSecond, game.G1_TextID).isSelected = false);
    20.                         choosenSecond = field;
    21.                     }
    22.                     break;
    23.                 case 2:
    24.                     if (choosenThird == null) {
    25.                         choosenThird = field;
    26.                     } else {
    27.                         world.setComponentData(choosenThird, world.getComponentData(choosenThird, ut.Core2D.Sprite2DRenderer).color = clearColor);
    28.                         world.setComponentData(choosenThird, world.getComponentData(choosenThird, game.G1_TextID).isSelected = false);
    29.                         choosenThird = field;
    30.                     }
    31.                     break;
    32.             }
    33.             if (this.checkAnswers(world) == true) {
    34.                 this.moveColumn(ansCol, 0);
    35.                 world.setComponentData(choosenFirst, world.getComponentData(choosenFirst, ut.Core2D.Sprite2DRenderer).color = ansColor);
    36.                 world.setComponentData(choosenFirst, world.getComponentData(choosenFirst, game.G1_TextID).isSelected = false);
    37.                 world.setComponentData(choosenFirst, world.getComponentData(choosenFirst, game.CustomB).IsInteractable = false);
    38.                 choosenFirst = null;
    39.                 world.setComponentData(choosenSecond, world.getComponentData(choosenSecond, ut.Core2D.Sprite2DRenderer).color = ansColor);
    40.                 world.setComponentData(choosenSecond, world.getComponentData(choosenSecond, game.G1_TextID).isSelected = false);
    41.                 world.setComponentData(choosenSecond, world.getComponentData(choosenSecond, game.CustomB).IsInteractable = false);
    42.                 choosenSecond = null;
    43.                 world.setComponentData(choosenThird, world.getComponentData(choosenThird, ut.Core2D.Sprite2DRenderer).color = ansColor);
    44.                 world.setComponentData(choosenThird, world.getComponentData(choosenThird, game.G1_TextID).isSelected = false);
    45.                 world.setComponentData(choosenThird, world.getComponentData(choosenThird, game.CustomB).IsInteractable = false);
    46.                 choosenThird = null;
    47.                 WinCounter++;
    48.             } else {
    49.                 if (ansCol <= 1) {
    50.                     this.moveColumn(ansCol, ansCol + 1);
    51.                 }
    52.             }
    53.         }
    54.         static checkAnswers(world: ut.World): boolean {
    55.             let check1: boolean = false;
    56.             let check2: boolean = false;
    57.             let ansID = null;
    58.             console.log("Primer array :\n"+firstColAns);
    59.             console.log("Segundo array :\n"+secondColAns);
    60.             console.log("Tercer array :\n"+thirdColAns);
    61.             if (choosenFirst != null && choosenSecond != null && choosenThird != null) {
    62.                 ansID = firstColAns[world.getComponentData(choosenFirst, game.G1_TextID).File];
    63.                 if (secondColAns[world.getComponentData(choosenSecond, game.G1_TextID).File] == ansID) {
    64.                     check1 = true;
    65.                     if (thirdColAns[world.getComponentData(choosenThird, game.G1_TextID).File] == ansID) {
    66.                         check2 = true;
    67.                     }
    68.                 }
    69.             }
    70.             return check1 && check2;
    71.         }
     
  4. Zionisias

    Zionisias

    Joined:
    Apr 23, 2019
    Posts:
    40
    I don't think you can use the world.setComponent() like the way you are using. The second parameter of the function requires a reference to a component, however the code you insert does not match this type:
    world.getComponentData(choosenFirst, ut.Core2D.Sprite2DRenderer).color = clearColor
    The code above does not return your component, you would need to split up your code like this:
    Code (CSharp):
    1. let renderer = world.getComponentData(choosenFirst, ut.Core2D.Sprite2DRenderer);
    2. renderer.color = clearColor; //The return value of this line of code is not a component.
    3. world.setComponentData(choosenFirst, renderer);
    I know this might be a bummer for readability, and can recommend you to look into this post: https://forum.unity.com/threads/a-question-about-best-practice-for-using-components-data.677227/
    It is about this.world.usingComponentData() which you might prefer. However it has some minor drawbacks, but you can read about it in that post.
     
    reallyhexln likes this.