Exemple #1
0
        /// <summary>
        /// クラスに含まれる処理を適用します。
        /// </summary>
        /// <param name="avatar"></param>
        /// <param name="enableAutoEyeMovement">オートアイムーブメントを有効化するなら<c>true</c>、無効化するなら<c>false</c>。</param>
        /// <param name="addedShouldersPositionY">VRChat上でモデルがなで肩・いかり肩になる問題について、Shoulder/UpperArmボーンのPositionのYに加算する値。</param>
        /// <param name="addedArmaturePositionY"></param>
        /// <param name="moveEyeBoneToFrontForEyeMovement"></param>
        /// <param name="forQuest"></param>
        /// <returns>変換中に発生したメッセージ。</returns>
        internal static IEnumerable <(string, MessageType)> Apply(
            GameObject avatar,
            bool enableAutoEyeMovement,
            float addedShouldersPositionY,
            float addedArmaturePositionY,
            float moveEyeBoneToFrontForEyeMovement,
            bool forQuest
            )
        {
            var messages = new List <(string, MessageType)>();

            VRChatsBugsWorkaround.EnableAnimationOvrride(avatar: avatar);
            if (VRChatUtility.SDKVersion == 2)
            {
                if (enableAutoEyeMovement)
                {
                    if (!VRChatsBugsWorkaround.ApplyAutoEyeMovementDegreeMapping(avatar: avatar))
                    {
                        moveEyeBoneToFrontForEyeMovement = 0.0f;
                    }
                }
                else
                {
                    VRChatsBugsWorkaround.DisableAutoEyeMovement(avatar: avatar);
                    moveEyeBoneToFrontForEyeMovement = 0.0f;
                }
            }
            else
            {
                moveEyeBoneToFrontForEyeMovement = 0.0f;
            }
            VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ(
                avatar: avatar,
                addedValueToArmature: addedArmaturePositionY,
                addedValueToShoulders: addedShouldersPositionY,
                addedValueToEyes: moveEyeBoneToFrontForEyeMovement
                );
            if (VRChatUtility.SDKVersion == 2)
            {
                if (enableAutoEyeMovement || forQuest)
                {
                    // VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ() より後に実行しないと
                    // 同メソッド内部で使用しているUniVRMが、同名ボーンのエラーを出す場合がある
                    VRChatsBugsWorkaround.EnableAutoEyeMovement(avatar: avatar);
                }
            }
            messages.AddRange(VRChatsBugsWorkaround.EnableTextureMipmapStreaming(avatar: avatar));

            return(messages);
        }
        /// <summary>
        /// クラスに含まれる処理を適用します。
        /// </summary>
        /// <param name="avatar"></param>
        /// <param name="enableAutoEyeMovement">オートアイムーブメントを有効化するなら<c>true</c>、無効化するなら<c>false</c>。</param>
        /// <param name="addedShouldersPositionY">VRChat上でモデルがなで肩・いかり肩になる問題について、Shoulder/UpperArmボーンのPositionのYに加算する値。</param>
        /// <param name="addedArmaturePositionY"></param>
        /// <param name="moveEyeBoneToFrontForEyeMovement"></param>
        /// <param name="forQuest"></param>
        /// <returns>変換中に発生したメッセージ。</returns>
        internal static IEnumerable <Converter.Message> Apply(
            GameObject avatar,
            bool enableAutoEyeMovement,
            float addedShouldersPositionY,
            float addedArmaturePositionY,
            float moveEyeBoneToFrontForEyeMovement,
            bool forQuest
            )
        {
            var messages = new List <Converter.Message>();

            VRChatsBugsWorkaround.EnableAnimationOvrride(avatar: avatar);
#if VRC_SDK_VRCSDK2
            if (enableAutoEyeMovement)
            {
                VRChatsBugsWorkaround.SetEyeBonesForCecilHenShin(avatar: avatar);
            }
            if (enableAutoEyeMovement)
            {
                if (!VRChatsBugsWorkaround.ApplyAutoEyeMovementDegreeMapping(avatar: avatar))
                {
                    moveEyeBoneToFrontForEyeMovement = 0.0f;
                }
            }
            else
            {
                VRChatsBugsWorkaround.DisableAutoEyeMovement(avatar: avatar);
                moveEyeBoneToFrontForEyeMovement = 0.0f;
            }
#else
            moveEyeBoneToFrontForEyeMovement = 0.0f;
#endif
            VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ(
                avatar: avatar,
                addedValueToArmature: addedArmaturePositionY,
                addedValueToShoulders: addedShouldersPositionY,
                addedValueToEyes: moveEyeBoneToFrontForEyeMovement
                );
#if VRC_SDK_VRCSDK2
            if (enableAutoEyeMovement || forQuest)
            {
                // VRChatsBugsWorkaround.AddShouldersPositionYAndEyesPositionZ() より後に実行しないと
                // 同メソッド内部で使用しているUniVRMが、同名ボーンのエラーを出す場合がある
                VRChatsBugsWorkaround.EnableAutoEyeMovement(avatar: avatar);
            }
#endif
            messages.AddRange(VRChatsBugsWorkaround.EnableTextureMipmapStreaming(avatar: avatar));

            return(messages);
        }