diff --git a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs index 81e77e8b..bb23905c 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/AvatarProcessor.cs @@ -1,18 +1,18 @@ /* * MIT License - * + * * Copyright (c) 2022 bd_ - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -341,14 +341,27 @@ namespace nadena.dev.modular_avatar.core.editor "VRC.SDKBase.Validation.Performance.Stats.AvatarPerformanceStats" ); var ty_VRCSdkControlPanel = Util.FindType("VRCSdkControlPanel"); - tempControlPanel = ScriptableObject.CreateInstance(ty_VRCSdkControlPanel) as Object; + + if (ty_VRCSdkControlPanelAvatarBuilder3A == null || ty_AvatarPerformanceStats == null || + ty_VRCSdkControlPanel == null) + { + return; + } var avatar = avatarGameObject.GetComponent(); var animator = avatarGameObject.GetComponent(); var builder = ty_VRCSdkControlPanelAvatarBuilder3A.GetConstructor(Type.EmptyTypes) - .Invoke(Array.Empty()); + ?.Invoke(Array.Empty()); var perfStats = ty_AvatarPerformanceStats.GetConstructor(new[] {typeof(bool)}) - .Invoke(new object[] {false}); + ?.Invoke(new object[] {false}); + + if (builder == null || perfStats == null) + { + return; + } + + tempControlPanel = ScriptableObject.CreateInstance(ty_VRCSdkControlPanel) as Object; + ty_VRCSdkControlPanelAvatarBuilder3A .GetMethod("RegisterBuilder", BindingFlags.Public | BindingFlags.Instance) .Invoke(builder, new object[] {tempControlPanel});