Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

InvalidProgramException: Invalid IL code

Discussion in 'Scripting' started by Acatist, Apr 8, 2020.

  1. Acatist

    Acatist

    Joined:
    Jun 7, 2016
    Posts:
    45
    Code (CSharp):
    1.  
    2. InvalidProgramException: Invalid IL code in CharacterGFXData/<GetGearData>d__43:MoveNext (): IL_01c7: call      0x0a000503
    3.  
    4.  
    5. System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) (at <437ba245d8404784b9fbab9b439ac908>:0)
    6. CharacterGFXData.GetGearData (System.String GearID, ACATIST.ClothData+BodyPart bodyPart) (at <5a8d385d4f91432eb1f08543dd7f02ed>:0)
    7. ACATIST.CharacterSelectionManager+<SetTorsoGear>d__40.MoveNext () (at Assets/Acatist/System/CharacterSystem/Scripts/CharacterSelection/CharacterSelectionManager.cs:622)
    8. --- End of stack trace from previous location where exception was thrown ---
    9. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <437ba245d8404784b9fbab9b439ac908>:0)
    10. System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <437ba245d8404784b9fbab9b439ac908>:0)
    11. UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <1245d947a91b4a14b7c7e2c7335512b2>:0)
    12. UnityEngine.UnitySynchronizationContext:ExecuteTasks()
    13.  
    I am trying to access some functions to get the clothes for my character as Addressales through my script and I get several errors like the one above. The error happens on the function call, it does not even get into the function

    I have no idea what the problem may be, which is that if I remove a few lines of code, it works again, but those lines of code are necessary so that the character does not get naked while changing from one clothes to another. .

    The really strange thing is that to instantiate the character's hair I use a very similar code (saving the differences). And yet, in the case of hair, it does work.

    I attach the two pieces of code, the one with the hairs (the one that works) and the one with the clothes (the one that doesn't work):

    Code (CSharp):
    1.  
    2. public async Task GetGearData(string GearID, ClothData.BodyPart bodyPart) //Clothes
    3.     {
    4.         if (Gender == 0)
    5.         {
    6.             switch (bodyPart)
    7.             {
    8.                 case ClothData.BodyPart.Head:
    9.                     for (int i = 0; i < data.RaceData.MaleHeadClothes.Count; i++)
    10.                     {
    11.                         if(data.RaceData.MaleHeadClothes[i].AssetReferenceID == GearID)
    12.                         {
    13.                             if(CustomAddresses.instance.headCloth.IsDone && CustomAddresses.instance.headCloth.DebugName != invalid)
    14.                             {
    15.                                 CustomAddresses.instance.oldHeadCloth = CustomAddresses.instance.oldHeadReference
    16.                                     .LoadAssetAsync<ClothData>();
    17.                                 await CustomAddresses.instance.oldHeadCloth;
    18.                                 Addressables.Release(CustomAddresses.instance.headCloth);
    19.                             }
    20.                             CustomAddresses.instance.headCloth = data.RaceData.MaleHeadClothes[i]
    21.                                 .assetReference.LoadAssetAsync<ClothData>();
    22.                             CustomAddresses.instance.oldHeadReference = data.RaceData.MaleHeadClothes[i]
    23.                                 .assetReference;
    24.                             await CustomAddresses.instance.headCloth.Task;
    25.                             data.currentGearIDs.headClothID = CustomAddresses.instance.headCloth.Result.clothID;
    26.                             data.currentGearIDs.headData = CustomAddresses.instance.headCloth.Result;
    27.                             data.currentGearIDs.headClothVariant = "C01";
    28.                             data.currentGearIDs.currentHeadPrefab =
    29.                                 GetPrefab(data.currentGearIDs.headData, data.currentGearIDs.headClothVariant);
    30.                             if (CustomAddresses.instance.oldHeadCloth.DebugName != invalid && CustomAddresses.instance.oldHeadCloth.IsDone)
    31.                             {
    32.                                 Addressables.Release(CustomAddresses.instance.oldHeadCloth);
    33.                             }
    34.                         }
    35.                     }
    36.                     break;
    37.                 case ClothData.BodyPart.Torso:
    38.                     for (int i = 0; i < data.RaceData.MaleTorsoClothes.Count; i++)
    39.                     {
    40.                         if (data.RaceData.MaleTorsoClothes[i].AssetReferenceID == GearID)
    41.                         {
    42.                             if(CustomAddresses.instance.chestCloth.IsDone && CustomAddresses.instance.chestCloth.DebugName != invalid)
    43.                             {
    44.                                 CustomAddresses.instance.oldChestCloth = CustomAddresses.instance
    45.                                     .oldChestReference.LoadAssetAsync<ClothData>();
    46.                                 await CustomAddresses.instance.oldChestCloth;
    47.                                 Addressables.Release(CustomAddresses.instance.chestCloth);
    48.                             }
    49.                             CustomAddresses.instance.chestCloth = data.RaceData.MaleTorsoClothes[i]
    50.                                 .assetReference.LoadAssetAsync<ClothData>();
    51.                             CustomAddresses.instance.oldChestReference = data.RaceData.MaleTorsoClothes[i]
    52.                                 .assetReference;
    53.                             await CustomAddresses.instance.chestCloth.Task;
    54.                             data.currentGearIDs.torsoClothID = CustomAddresses.instance.chestCloth.Result.clothID;
    55.                             data.currentGearIDs.torsoData = CustomAddresses.instance.chestCloth.Result;
    56.                             data.currentGearIDs.torsoClothVariant = "C01";
    57.                             data.currentGearIDs.currentTorsoPrefab =
    58.                                 GetPrefab(data.currentGearIDs.torsoData, data.currentGearIDs.torsoClothVariant);
    59.                             if (CustomAddresses.instance.oldChestCloth.DebugName != invalid && CustomAddresses.instance.oldChestCloth.IsDone)
    60.                             {
    61.                                 Addressables.Release(CustomAddresses.instance.oldHeadCloth);
    62.                             }
    63.                         }
    64.                     }
    65.                     break;
    66.                 case ClothData.BodyPart.Hands:
    67.                     for (int i = 0; i < data.RaceData.MaleHandsClothes.Count; i++)
    68.                     {
    69.                         if (data.RaceData.MaleHandsClothes[i].AssetReferenceID == GearID)
    70.                         {
    71.                             if(CustomAddresses.instance.handsCloth.IsDone && CustomAddresses.instance.handsCloth.DebugName != invalid)
    72.                             {
    73.                                 CustomAddresses.instance.oldHandsCloth = CustomAddresses.instance.oldHandsReference
    74.                                     .LoadAssetAsync<ClothData>();
    75.                                 await CustomAddresses.instance.oldHandsCloth;
    76.                                 Addressables.Release(CustomAddresses.instance.handsCloth);
    77.                             }
    78.                             CustomAddresses.instance.handsCloth = data.RaceData.MaleHandsClothes[i]
    79.                                 .assetReference.LoadAssetAsync<ClothData>();
    80.                             CustomAddresses.instance.oldHandsReference = data.RaceData.MaleHandsClothes[i]
    81.                                 .assetReference;
    82.                             await CustomAddresses.instance.handsCloth.Task;
    83.                             data.currentGearIDs.handsClothID = CustomAddresses.instance.handsCloth.Result.clothID;
    84.                             data.currentGearIDs.handsData = CustomAddresses.instance.handsCloth.Result;
    85.                             data.currentGearIDs.handsClothVariant = "C01";
    86.                             data.currentGearIDs.currentHandsPrefab =
    87.                                 GetPrefab(data.currentGearIDs.handsData, data.currentGearIDs.handsClothVariant);
    88.                             if (CustomAddresses.instance.oldHandsCloth.DebugName != invalid && CustomAddresses.instance.oldHandsCloth.IsDone)
    89.                             {
    90.                                 Addressables.Release(CustomAddresses.instance.oldHandsCloth);
    91.                             }
    92.                         }
    93.                     }
    94.                     break;
    95.                 case ClothData.BodyPart.Legs:
    96.                     for (int i = 0; i < data.RaceData.MaleLegsClothes.Count; i++)
    97.                     {
    98.                         if (data.RaceData.MaleLegsClothes[i].AssetReferenceID == GearID)
    99.                         {
    100.                             if(CustomAddresses.instance.legsCloth.IsDone && CustomAddresses.instance.legsCloth.DebugName != invalid)
    101.                             {
    102.                                 CustomAddresses.instance.oldLegsCloth = CustomAddresses.instance.
    103.                                     oldLegsReference.LoadAssetAsync<ClothData>();
    104.                                 await CustomAddresses.instance.oldLegsCloth;
    105.                                 Addressables.Release(CustomAddresses.instance.legsCloth);
    106.                             }
    107.                             CustomAddresses.instance.legsCloth = data.RaceData.MaleLegsClothes[i]
    108.                                 .assetReference.LoadAssetAsync<ClothData>();
    109.                             CustomAddresses.instance.oldLegsReference = data.RaceData.MaleLegsClothes[i]
    110.                                 .assetReference;
    111.                             await CustomAddresses.instance.legsCloth.Task;
    112.                             data.currentGearIDs.legsClothID = CustomAddresses.instance.legsCloth.Result.clothID;
    113.                             data.currentGearIDs.legsData = CustomAddresses.instance.legsCloth.Result;
    114.                             data.currentGearIDs.legsClothVariant = "C01";
    115.                             data.currentGearIDs.currentLegsPrefab =
    116.                                 GetPrefab(data.currentGearIDs.legsData, data.currentGearIDs.legsClothVariant);
    117.                             if (CustomAddresses.instance.oldLegsCloth.DebugName != invalid && CustomAddresses.instance.oldLegsCloth.IsDone)
    118.                             {
    119.                                 Addressables.Release(CustomAddresses.instance.oldLegsCloth);
    120.                             }
    121.                         }
    122.                     }
    123.                     break;
    124.                 case ClothData.BodyPart.Feet:
    125.                     for (int i = 0; i < data.RaceData.MaleFeetClothes.Count; i++)
    126.                     {
    127.                         if (data.RaceData.MaleFeetClothes[i].AssetReferenceID == GearID)
    128.                         {
    129.                             if(CustomAddresses.instance.feetCloth.IsDone && CustomAddresses.instance.feetCloth.DebugName!=invalid)
    130.                             {
    131.                                 CustomAddresses.instance.oldFeetCloth = CustomAddresses.instance.oldFeetReference
    132.                                     .LoadAssetAsync<ClothData>();
    133.                                 await CustomAddresses.instance.oldFeetCloth;
    134.                                 Addressables.Release(CustomAddresses.instance.feetCloth);
    135.                             }
    136.                             CustomAddresses.instance.feetCloth = data.RaceData.MaleFeetClothes[i]
    137.                                 .assetReference.LoadAssetAsync<ClothData>();
    138.                             CustomAddresses.instance.oldFeetReference = data.RaceData.MaleFeetClothes[i]
    139.                                 .assetReference;
    140.                             await CustomAddresses.instance.feetCloth.Task;
    141.                             data.currentGearIDs.feetClothID = CustomAddresses.instance.feetCloth.Result.clothID;
    142.                             data.currentGearIDs.feetData = CustomAddresses.instance.feetCloth.Result;
    143.                             data.currentGearIDs.feetClothVariant = "C01";
    144.                             data.currentGearIDs.currentFeetPrefab =
    145.                                 GetPrefab(data.currentGearIDs.feetData, data.currentGearIDs.feetClothVariant);
    146.                             if (CustomAddresses.instance.oldFeetCloth.DebugName != invalid && CustomAddresses.instance.oldFeetCloth.IsDone)
    147.                             {
    148.                                 Addressables.Release(CustomAddresses.instance.oldFeetCloth);
    149.                             }
    150.                         }
    151.                     }
    152.                     break;
    153.                 case ClothData.BodyPart.Underwear:
    154.                     for (int i = 0; i < data.RaceData.MaleUnderwearClothes.Count; i++)
    155.                     {
    156.                         if (data.RaceData.MaleUnderwearClothes[i].AssetReferenceID == GearID)
    157.                         {
    158.                             if(CustomAddresses.instance.underwearCloth.IsDone && CustomAddresses.instance.underwearCloth.DebugName != invalid)
    159.                             {
    160.                                 CustomAddresses.instance.oldUnderwearCloth = CustomAddresses.instance
    161.                                     .oldUnderwearReference.LoadAssetAsync<ClothData>();
    162.                                 await CustomAddresses.instance.oldUnderwearCloth;
    163.                                 Addressables.Release(CustomAddresses.instance.underwearCloth);
    164.                             }
    165.                             CustomAddresses.instance.underwearCloth = data.RaceData.MaleUnderwearClothes[i]
    166.                                 .assetReference.LoadAssetAsync<ClothData>();
    167.                             CustomAddresses.instance.oldUnderwearReference = data.RaceData.MaleUnderwearClothes[i]
    168.                                 .assetReference;
    169.                             await CustomAddresses.instance.underwearCloth.Task;
    170.                             data.currentGearIDs.underwearID = CustomAddresses.instance.underwearCloth.Result.clothID;
    171.                             data.currentGearIDs.underwearData = CustomAddresses.instance.underwearCloth.Result;
    172.                             data.currentGearIDs.underwearVariant = "C01";
    173.                             data.currentGearIDs.underwearPrefab =
    174.                                 GetPrefab(data.currentGearIDs.underwearData, data.currentGearIDs.underwearVariant);
    175.                             if (CustomAddresses.instance.oldUnderwearCloth.DebugName != invalid && CustomAddresses.instance.oldUnderwearCloth.IsDone)
    176.                             {
    177.                                 Addressables.Release(CustomAddresses.instance.oldUnderwearCloth);
    178.                             }
    179.                         }
    180.                     }
    181.                     break;
    182.             }
    183.         }
    184.         else
    185.         {
    186.             switch (bodyPart)
    187.             {
    188.                 case ClothData.BodyPart.Head:
    189.                     for (int i = 0; i < data.RaceData.FemaleHeadClothes.Count; i++)
    190.                     {
    191.                         if (data.RaceData.FemaleHeadClothes[i].AssetReferenceID == GearID)
    192.                         {
    193.                             if(CustomAddresses.instance.headCloth.IsDone && CustomAddresses.instance.headCloth.DebugName != invalid)
    194.                             {
    195.                                 CustomAddresses.instance.oldHeadCloth = CustomAddresses.instance
    196.                                     .oldHeadReference.LoadAssetAsync<ClothData>();
    197.                                 await CustomAddresses.instance.oldHeadCloth;
    198.                                 Addressables.Release(CustomAddresses.instance.headCloth);
    199.                             }
    200.                             CustomAddresses.instance.headCloth = data.RaceData.FemaleHeadClothes[i]
    201.                                 .assetReference.LoadAssetAsync<ClothData>();
    202.                             CustomAddresses.instance.oldHeadReference = data.RaceData.FemaleHeadClothes[i]
    203.                                 .assetReference;
    204.                             await CustomAddresses.instance.headCloth.Task;
    205.                             data.currentGearIDs.headClothID = CustomAddresses.instance.headCloth.Result.clothID;
    206.                             data.currentGearIDs.headData = CustomAddresses.instance.headCloth.Result;
    207.                             data.currentGearIDs.headClothVariant = "C01";
    208.                             data.currentGearIDs.currentHeadPrefab =
    209.                                 GetPrefab(data.currentGearIDs.headData, data.currentGearIDs.headClothVariant);
    210.                             if (CustomAddresses.instance.oldHeadCloth.DebugName != invalid && CustomAddresses.instance.oldHeadCloth.IsDone)
    211.                             {
    212.                                 Addressables.Release(CustomAddresses.instance.oldHeadCloth);
    213.                             }
    214.                         }
    215.                     }
    216.                     break;
    217.                 case ClothData.BodyPart.Torso:
    218.                     for (int i = 0; i < data.RaceData.FemaleTorsoClothes.Count; i++)
    219.                     {
    220.                         if (data.RaceData.FemaleTorsoClothes[i].AssetReferenceID == GearID)
    221.                         {
    222.                             if(CustomAddresses.instance.chestCloth.IsDone && CustomAddresses.instance.chestCloth.DebugName != invalid)
    223.                             {
    224.                                 CustomAddresses.instance.oldChestCloth = CustomAddresses.instance.oldChestReference
    225.                                     .LoadAssetAsync<ClothData>();
    226.                                 await CustomAddresses.instance.oldChestCloth;
    227.                                 Addressables.Release(CustomAddresses.instance.chestCloth);
    228.                             }
    229.                             CustomAddresses.instance.chestCloth = data.RaceData.FemaleTorsoClothes[i]
    230.                                 .assetReference.LoadAssetAsync<ClothData>();
    231.                             CustomAddresses.instance.oldChestReference = data.RaceData.FemaleTorsoClothes[i]
    232.                                 .assetReference;
    233.                             await CustomAddresses.instance.chestCloth.Task;
    234.                             data.currentGearIDs.torsoClothID = CustomAddresses.instance.chestCloth.Result.clothID;
    235.                             data.currentGearIDs.torsoData = CustomAddresses.instance.chestCloth.Result;
    236.                             data.currentGearIDs.torsoClothVariant = "C01";
    237.                             data.currentGearIDs.currentTorsoPrefab =
    238.                                 GetPrefab(data.currentGearIDs.torsoData, data.currentGearIDs.torsoClothVariant);
    239.                             if (CustomAddresses.instance.oldChestCloth.DebugName != invalid && CustomAddresses.instance.oldChestCloth.IsDone)
    240.                             {
    241.                                 Addressables.Release(CustomAddresses.instance.oldChestCloth);
    242.                             }
    243.                         }
    244.                     }
    245.                     break;
    246.                 case ClothData.BodyPart.Hands:
    247.                     for (int i = 0; i < data.RaceData.FemaleHandsClothes.Count; i++)
    248.                     {
    249.                         if (data.RaceData.FemaleHandsClothes[i].AssetReferenceID == GearID)
    250.                         {
    251.                             if(CustomAddresses.instance.handsCloth.IsDone && CustomAddresses.instance.handsCloth.DebugName != invalid)
    252.                             {
    253.                                 CustomAddresses.instance.oldHandsCloth = CustomAddresses.instance
    254.                                     .oldHandsReference.LoadAssetAsync<ClothData>();
    255.                                 await CustomAddresses.instance.oldHandsCloth;
    256.                                 Addressables.Release(CustomAddresses.instance.handsCloth);
    257.                             }
    258.                             CustomAddresses.instance.handsCloth = data.RaceData.FemaleHandsClothes[i]
    259.                                 .assetReference.LoadAssetAsync<ClothData>();
    260.                             CustomAddresses.instance.oldHandsReference = data.RaceData.FemaleHandsClothes[i]
    261.                                 .assetReference;
    262.                             await CustomAddresses.instance.handsCloth.Task;
    263.                             data.currentGearIDs.handsClothID = CustomAddresses.instance.handsCloth.Result.clothID;
    264.                             data.currentGearIDs.handsData = CustomAddresses.instance.handsCloth.Result;
    265.                             data.currentGearIDs.handsClothVariant = "C01";
    266.                             data.currentGearIDs.currentHandsPrefab =
    267.                                 GetPrefab(data.currentGearIDs.handsData, data.currentGearIDs.handsClothVariant);
    268.                             if (CustomAddresses.instance.oldHandsCloth.DebugName != invalid && CustomAddresses.instance.oldHandsCloth.IsDone)
    269.                             {
    270.                                 Addressables.Release(CustomAddresses.instance.oldHandsCloth);
    271.                             }
    272.                         }
    273.                     }
    274.                     break;
    275.                 case ClothData.BodyPart.Legs:
    276.                     for (int i = 0; i < data.RaceData.FemaleLegsClothes.Count; i++)
    277.                     {
    278.                         if (data.RaceData.FemaleLegsClothes[i].AssetReferenceID == GearID)
    279.                         {
    280.                             if(CustomAddresses.instance.legsCloth.IsDone && CustomAddresses.instance.legsCloth.DebugName != invalid)
    281.                             {
    282.                                 CustomAddresses.instance.oldLegsCloth = CustomAddresses.instance.oldLegsReference
    283.                                     .LoadAssetAsync<ClothData>();
    284.                                 await CustomAddresses.instance.oldLegsCloth;
    285.                                 Addressables.Release(CustomAddresses.instance.legsCloth);
    286.                             }
    287.                             CustomAddresses.instance.legsCloth = data.RaceData.FemaleLegsClothes[i]
    288.                                 .assetReference.LoadAssetAsync<ClothData>();
    289.                             CustomAddresses.instance.oldLegsReference = data.RaceData.FemaleLegsClothes[i]
    290.                                 .assetReference;
    291.                             await CustomAddresses.instance.legsCloth.Task;
    292.                             data.currentGearIDs.legsClothID = CustomAddresses.instance.legsCloth.Result.clothID;
    293.                             data.currentGearIDs.legsData = CustomAddresses.instance.legsCloth.Result;
    294.                             data.currentGearIDs.legsClothVariant = "C01";
    295.                             data.currentGearIDs.currentLegsPrefab =
    296.                                 GetPrefab(data.currentGearIDs.legsData, data.currentGearIDs.legsClothVariant);
    297.                             if (CustomAddresses.instance.oldLegsCloth.DebugName != invalid && CustomAddresses.instance.oldLegsCloth.IsDone)
    298.                             {
    299.                                 Addressables.Release(CustomAddresses.instance.oldLegsCloth);
    300.                             }
    301.                         }
    302.                     }
    303.                     break;
    304.                 case ClothData.BodyPart.Feet:
    305.                     for (int i = 0; i < data.RaceData.FemaleFeetClothes.Count; i++)
    306.                     {
    307.                         if (data.RaceData.FemaleFeetClothes[i].AssetReferenceID == GearID)
    308.                         {
    309.                             if(CustomAddresses.instance.feetCloth.IsDone && CustomAddresses.instance.feetCloth.DebugName != invalid)
    310.                             {
    311.                                 CustomAddresses.instance.oldFeetCloth = CustomAddresses.instance.oldFeetReference
    312.                                     .LoadAssetAsync<ClothData>();
    313.                                 await CustomAddresses.instance.oldFeetCloth;
    314.                                 Addressables.Release(CustomAddresses.instance.feetCloth);
    315.                             }
    316.                             CustomAddresses.instance.feetCloth = data.RaceData.FemaleFeetClothes[i]
    317.                                 .assetReference.LoadAssetAsync<ClothData>();
    318.                             CustomAddresses.instance.oldFeetReference = data.RaceData.FemaleFeetClothes[i]
    319.                                 .assetReference;
    320.                             await CustomAddresses.instance.feetCloth.Task;
    321.                             data.currentGearIDs.feetClothID = CustomAddresses.instance.feetCloth.Result.clothID;
    322.                             data.currentGearIDs.feetData = CustomAddresses.instance.feetCloth.Result;
    323.                             data.currentGearIDs.feetClothVariant = "C01";
    324.                             data.currentGearIDs.currentFeetPrefab =
    325.                                 GetPrefab(data.currentGearIDs.feetData, data.currentGearIDs.feetClothVariant);
    326.                             if (CustomAddresses.instance.oldFeetCloth.DebugName != invalid && CustomAddresses.instance.oldFeetCloth.IsDone)
    327.                             {
    328.                                 Addressables.Release(CustomAddresses.instance.oldFeetCloth);
    329.                             }
    330.                         }
    331.                     }
    332.                     break;
    333.                 case ClothData.BodyPart.Underwear:
    334.                     for (int i = 0; i < data.RaceData.FemaleUnderwearClothes.Count; i++)
    335.                     {  
    336.                         if (data.RaceData.FemaleUnderwearClothes[i].AssetReferenceID == GearID)
    337.                         {
    338.                             if(CustomAddresses.instance.underwearCloth.IsDone && CustomAddresses.instance.underwearCloth.DebugName != invalid)
    339.                             {
    340.                                 CustomAddresses.instance.oldUnderwearCloth = CustomAddresses.instance
    341.                                     .oldUnderwearReference.LoadAssetAsync<ClothData>();
    342.                                 await CustomAddresses.instance.oldUnderwearCloth;
    343.                                 Addressables.Release(CustomAddresses.instance.underwearCloth);
    344.                             }
    345.                             CustomAddresses.instance.underwearCloth = data.RaceData.FemaleUnderwearClothes[i]
    346.                                 .assetReference.LoadAssetAsync<ClothData>();
    347.                             CustomAddresses.instance.oldUnderwearReference = data.RaceData.FemaleUnderwearClothes[i]
    348.                                 .assetReference;
    349.                             await CustomAddresses.instance.underwearCloth.Task;
    350.                             data.currentGearIDs.underwearID = CustomAddresses.instance.underwearCloth.Result.clothID;
    351.                             data.currentGearIDs.underwearData = CustomAddresses.instance.underwearCloth.Result;
    352.                             data.currentGearIDs.underwearVariant = "C01";
    353.                             data.currentGearIDs.underwearPrefab =
    354.                                 GetPrefab(data.currentGearIDs.underwearData, data.currentGearIDs.underwearVariant);
    355.                             if (CustomAddresses.instance.oldUnderwearCloth.DebugName != invalid && CustomAddresses.instance.oldUnderwearCloth.IsDone)
    356.                             {
    357.                                 Addressables.Release(CustomAddresses.instance.oldUnderwearCloth);
    358.                             }
    359.                         }
    360.                     }
    361.                     break;
    362.             }
    363.         }
    364.     }
    Code (CSharp):
    1.  
    2. public async Task ApplyHair(string HairID) //Hairs
    3.     {
    4.         if (Gender == 0)
    5.         {
    6.             for (int i = 0; i < data.RaceData.MaleHairTypes.Count; i++)
    7.             {
    8.                 if (data.RaceData.MaleHairTypes[i].AssetReferenceID == HairID)
    9.                 {
    10.                    
    11.                     if (CustomAddresses.instance.hairStyle.IsDone && CustomAddresses.instance.hairStyle.DebugName!=invalid)
    12.                     {
    13.                         CustomAddresses.instance.oldHairStyle = CustomAddresses.instance.oldHairReference.LoadAssetAsync<Hairs>();
    14.                         await CustomAddresses.instance.oldHairStyle.Task;
    15.                         Addressables.Release(CustomAddresses.instance.hairStyle);
    16.                     }
    17.  
    18.                     CustomAddresses.instance.hairStyle = data.RaceData.MaleHairTypes[i]
    19.                         .assetReference.LoadAssetAsync<Hairs>();
    20.                     await CustomAddresses.instance.hairStyle.Task;
    21.                     CustomAddresses.instance.oldHairReference = data.RaceData.MaleHairTypes[i]
    22.                         .assetReference;
    23.                     currentHairData = CustomAddresses.instance.hairStyle.Result;
    24.                     if (currentHair != null)
    25.                     {
    26.                         Destroy(currentHair);
    27.                     }
    28.                     currentHair = Instantiate(currentHairData.hairColors[0].hairColorPrefab, hairSlot);
    29.  
    30.                     if (CustomAddresses.instance.oldHairStyle.DebugName != invalid && CustomAddresses.instance.oldHairStyle.IsDone)
    31.                     {
    32.                         Addressables.Release(CustomAddresses.instance.oldHairStyle);
    33.                     }
    34.                     data.HairID = CustomAddresses.instance.hairStyle.Result.hairStyleID;
    35.                 }
    36.             }
    37.         }
    38.         //currentHair = Instantiate (data.RaceData.MaleHairTypes[data.HairID], hairSlot);
    39.         else
    40.         {
    41.             for (int i = 0; i < data.RaceData.FemaleHairTypes.Count; i++)
    42.             {
    43.                 if (data.RaceData.FemaleHairTypes[i].AssetReferenceID == HairID)
    44.                 {
    45.                     if (CustomAddresses.instance.hairStyle.IsDone && CustomAddresses.instance.hairStyle.DebugName != invalid)
    46.                     {
    47.                         CustomAddresses.instance.oldHairStyle = CustomAddresses.instance.oldHairReference.LoadAssetAsync<Hairs>();
    48.                         await CustomAddresses.instance.oldHairStyle.Task;
    49.                         Addressables.Release(CustomAddresses.instance.hairStyle);
    50.                     }
    51.  
    52.                     CustomAddresses.instance.hairStyle = data.RaceData.FemaleHairTypes[i]
    53.                         .assetReference.LoadAssetAsync<Hairs>();
    54.                     await CustomAddresses.instance.hairStyle.Task;
    55.                     CustomAddresses.instance.oldHairReference = data.RaceData.FemaleHairTypes[i]
    56.                         .assetReference;
    57.                     currentHairData = CustomAddresses.instance.hairStyle.Result;
    58.                     if (currentHair != null)
    59.                     {
    60.                         Destroy(currentHair);
    61.                     }
    62.                     currentHair = Instantiate(currentHairData.hairColors[0].hairColorPrefab, hairSlot);
    63.  
    64.                     if (CustomAddresses.instance.oldHairStyle.DebugName != invalid && CustomAddresses.instance.oldHairStyle.IsDone)
    65.                     {
    66.                         Addressables.Release(CustomAddresses.instance.oldHairStyle);
    67.                     }
    68.                     data.HairID = CustomAddresses.instance.hairStyle.Result.hairStyleID;
    69.                 }
    70.             }
    71.         }
    72.     }
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,514
    Does it have to be async?!!! How many clothes are there? What happens if you refactor as non-async and invoke and just let it stall out?