Skip to content

Commit

Permalink
VRChatAnimatorLayerのnullチェック
Browse files Browse the repository at this point in the history
  • Loading branch information
HhotateA committed Oct 21, 2021
1 parent 7c6122b commit 1bc52dc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Assets/HhotateA/AvatarModifyTool/Editor/AvatarModifyTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,11 @@ void SetAvatarAnimatorController(AnimatorLayerType type, AnimatorController cont
avatar.customizeAnimationLayers = true;
var index = Array.FindIndex(avatar.baseAnimationLayers,
l => l.type == type.GetVRChatAnimatorLayerType());
if (index == -1)
{
Debug.LogError("Animation Layers" + type.GetVRChatAnimatorLayerType() + " Not Found");
return;
}
avatar.baseAnimationLayers[index].isDefault = false;
avatar.baseAnimationLayers[index].animatorController = controller;
#else
Expand All @@ -461,6 +466,11 @@ bool GetAvatarAnimatorControllerExists(AnimatorLayerType type)
#if VRC_SDK_VRCSDK3
var index = Array.FindIndex(avatar.baseAnimationLayers,
l => l.type == type.GetVRChatAnimatorLayerType());
if (index == -1)
{
Debug.LogError("Animation Layers" + type.GetVRChatAnimatorLayerType() + " Not Found");
return false;
}
return avatar.baseAnimationLayers[index].animatorController != null;
#else
return avatar.runtimeAnimatorController != null;
Expand Down Expand Up @@ -540,6 +550,11 @@ Dictionary<AnimatorLayerType, int> ComputeLayersOffset(AvatarModifyData assets)
int GetLayerOffset(AvatarModifyData assets,AnimatorLayerType type)
{
var index = Array.FindIndex(avatar.baseAnimationLayers,l => l.type == type.GetVRChatAnimatorLayerType());
if (index == -1)
{
Debug.LogError("Animation Layers" + type.GetVRChatAnimatorLayerType() + " Not Found");
return 0;
}
if (avatar.customizeAnimationLayers == false) return 0;
if (avatar.baseAnimationLayers[index].isDefault == true) return 0;
if (!avatar.baseAnimationLayers[index].animatorController) return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2389,7 +2389,12 @@ Material GetDefaultMaterial(Renderer rend, int index)
defaultMaterials.Add(rend,rend.sharedMaterials.ToArray());
}

return defaultMaterials[rend][index];
if ( 0 <= index && index < defaultMaterials[rend].Length)
{
return defaultMaterials[rend][index];
}

return null;
}

// デフォルトのBlendShape状態(シーン)を記録&取得する
Expand Down

0 comments on commit 1bc52dc

Please sign in to comment.