IllusionMods / IllusionFixes

A collection of fixes for common issues found in games by Illusion
GNU General Public License v3.0
157 stars 29 forks source link

[StudioOptimizations 21.4.1]Character cannot be loaded properly #57

Closed Makao1240 closed 6 months ago

Makao1240 commented 6 months ago

In Studio, characters may not load properly when they are replaced. This problem occurs when the character's hairstyle is different before and after the replacement. I lowered the version of [KK_Fix_StudioOptimizations] from 21.4.1 to 21.4 due to the following error and the problem did not occur.

NullReferenceException
at (wrapper managed-to-native) UnityEngine.Object.get_name () <0x00075>
at IllusionFixes.FindLoopAssistant.RegisterPath (UnityEngine.Transform,UnityEngine.Transform,string) <0x00066>
at IllusionFixes.FindLoopAssistant.FindChild (UnityEngine.Transform,string) <0x00168>
at IllusionFixes.StudioOptimizations.FindLoopNoAcc (UnityEngine.Transform,string) <0x00035>
at (wrapper dynamic-method) Studio.AddObjectAssist.DMD<Studio.AddObjectAssist..InitHairBone> (Studio.OCIChar,System.Collections.Generic.Dictionary`2<int, Studio.Info/BoneInfo>) <0x00145>
at (wrapper dynamic-method) Studio.OCIChar.DMD<Studio.OCIChar..ChangeChara> (Studio.OCIChar,string) <0x005f0>
at (wrapper dynamic-method) Studio.OCICharFemale.DMD<Studio.OCICharFemale..ChangeChara> (Studio.OCICharFemale,string) <0x00037>
at IllusionFixes.StudioOptimizations.CharaList_ChangeCharaFemale (Studio.CharaFileSort) <0x00129>
at (wrapper dynamic-method) Studio.CharaList.DMD<Studio.CharaList..ChangeCharaFemale> (Studio.CharaList) <0x00027>
at KK_OptimizeStudioUI.OptimizeStudioUI/Patches.Postfix (int,Studio.CharaList,int) <0x000d8>
at (wrapper dynamic-method) Studio.CharaList.DMD<Studio.CharaList..OnSelectChara> (Studio.CharaList,int) <0x0025b>
at Studio.CharaList/<InitCharaList>c__AnonStorey0.<>m__0 () <0x00028>
at UnityEngine.Events.InvokableCall.Invoke (object[]) <0x00039>
at UnityEngine.Events.InvokableCallList.Invoke (object[]) <0x000c4>
at UnityEngine.Events.UnityEventBase.Invoke (object[]) <0x00043>
at UnityEngine.Events.UnityEvent.Invoke () <0x00023>
at UnityEngine.UI.Button.Press () <0x00060>
at UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData) <0x00043>
at UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler,UnityEngine.EventSystems.BaseEventData) <0x00047>
at UnityEngine.EventSystems.ExecuteEvents.Execute<UnityEngine.EventSystems.IPointerClickHandler> (UnityEngine.GameObject,UnityEngine.EventSystems.BaseEventData,UnityEngine.EventSystems.ExecuteEvents/EventFunction`1<UnityEngine.EventSystems.IPointerClickHandler>) <0x00331>

If we can identify any other situations where the problem occurs, we will let you know additionally.

(DeepL: JPN→ENG)

ManlyMarco commented 6 months ago

@takahiro0327

ManlyMarco commented 6 months ago

Looks like it's caused by destroyed objects inside the dictionary https://github.com/IllusionMods/IllusionFixes/blob/884ea0716b39dc3628bf0ae5c5607dfab458db45/src/Core_Fix_StudioOptimizations/FindLoopAssistant.cs#L70-L72

takahiro0327 commented 6 months ago

Thanks for the report and mentions.

It should be fixed in the following, so give it a try. At my place, no matter how many changes I make to the character, I don't get any exceptions. I don't know why...

C:\illusion\KoikatsuSunshine\BepInEx\plugins\IllusionFixes\KKS_Fix_StudioOptimizations.dll KKS_Fix_StudioOptimizations.zip

C:\illusion\Koikatu\BepInEx\plugins\IllusionFixes\KK_Fix_StudioOptimizations.dll KK_Fix_StudioOptimizations.zip

Makao1240 commented 6 months ago

Worked fine! Thanks for the nice fix!