示例#1
0
        private static void Postfix(MotionIKUI __instance,
                                    MotionIKUI.IKUIInfo ___infoBody,
                                    MotionIKUI.IKUIInfo ___infoLeftShoulder, MotionIKUI.IKUIInfo ___infoLeftElbow,
                                    MotionIKUI.IKUIInfo ___infoRightShoulder, MotionIKUI.IKUIInfo ___infoRightElbow,
                                    MotionIKUI.IKUIInfo ___infoLeftWaist, MotionIKUI.IKUIInfo ___infoLeftKnee,
                                    MotionIKUI.IKUIInfo ___infoRightWaist, MotionIKUI.IKUIInfo ___infoRightKnee,
                                    HPart.Group.MotionKind ___kindMotion)
        {
            if (__instance.CharaInfoData == null)
            {
                return;
            }

            var ik = __instance.CharaInfoData.motions[(int)___kindMotion].ik;

            SetParentName(___infoBody, ik.areas[(int)KinematicCtrl.IKTargetEN.Body]);
            SetParentName(___infoLeftShoulder, ik.areas[(int)KinematicCtrl.IKTargetEN.LeftShoulder]);
            SetParentName(___infoLeftElbow, ik.areas[(int)KinematicCtrl.IKTargetEN.LeftArmChain]);
            SetParentName(___infoRightShoulder, ik.areas[(int)KinematicCtrl.IKTargetEN.RightShoulder]);
            SetParentName(___infoRightElbow, ik.areas[(int)KinematicCtrl.IKTargetEN.RightArmChain]);
            SetParentName(___infoLeftWaist, ik.areas[(int)KinematicCtrl.IKTargetEN.LeftThigh]);
            SetParentName(___infoLeftKnee, ik.areas[(int)KinematicCtrl.IKTargetEN.LeftLegChain]);
            SetParentName(___infoRightWaist, ik.areas[(int)KinematicCtrl.IKTargetEN.RightThigh]);
            SetParentName(___infoRightKnee, ik.areas[(int)KinematicCtrl.IKTargetEN.RightLegChain]);
        }
示例#2
0
        internal static void Postfix(MotionIKUI __instance,
                                     MotionIKUI.IKUIInfo ___infoRightHand, MotionIKUI.IKUIInfo ___infoBody,
                                     MotionIKUI.IKUIInfo ___infoLeftShoulder, MotionIKUI.IKUIInfo ___infoLeftElbow,
                                     MotionIKUI.IKUIInfo ___infoRightShoulder, MotionIKUI.IKUIInfo ___infoRightElbow,
                                     MotionIKUI.IKUIInfo ___infoLeftWaist, MotionIKUI.IKUIInfo ___infoLeftKnee,
                                     MotionIKUI.IKUIInfo ___infoRightWaist, MotionIKUI.IKUIInfo ___infoRightKnee)
        {
            var motionSettingCanvas = __instance.motionSettingCanvas;

            CopyIKParentingButton(___infoRightHand, ___infoBody, IKTargetIndices.Body,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoLeftShoulder, IKTargetIndices.LeftShoulder,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoLeftElbow, IKTargetIndices.LeftElbow,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoRightShoulder, IKTargetIndices.RightShoulder,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoRightElbow, IKTargetIndices.RightElbow,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoLeftWaist, IKTargetIndices.LeftWaist,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoLeftKnee, IKTargetIndices.LeftKnee,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoRightWaist, IKTargetIndices.RightWaist,
                                  motionSettingCanvas, __instance);
            CopyIKParentingButton(___infoRightHand, ___infoRightKnee, IKTargetIndices.RightKnee,
                                  motionSettingCanvas, __instance);
        }
示例#3
0
        internal static void InitHook(MotionIKUI __instance)
        {
            _folderTreeView.DefaultPath   = Path.Combine(Utils.NormalizePath(UserData.Path), "edit/ik");
            _folderTreeView.CurrentFolder = _folderTreeView.DefaultPath;

            _motionIKUI  = __instance;
            _targetScene = Scene.Instance.AddSceneName;
        }
示例#4
0
        static bool Prefix(MotionIKUI __instance, ChaControl _chara, Motion.IK _ik, FullBodyBipedIK _fullBodyIK, KinematicCtrl _kinematicCtrl, int _charaID)
        {
            if (_ik == null || _fullBodyIK == null || _kinematicCtrl == null)
            {
                return(false);
            }
            var hEditInstance = Singleton <HEditGlobal> .Instance;

            var nowPartCharaInfo = hEditInstance.nowPartCharaInfo;

            hEditInstance.nowPartCharaInfo = null;
            if (_ik.isUse)
            {
                _kinematicCtrl.Active(PoseInfo.ModeEN.IK, false);
            }

            var effectors = new IKEffector[] { _fullBodyIK.solver.bodyEffector,
                                               _fullBodyIK.solver.leftShoulderEffector, _fullBodyIK.solver.leftHandEffector,
                                               _fullBodyIK.solver.rightShoulderEffector, _fullBodyIK.solver.rightHandEffector,
                                               _fullBodyIK.solver.leftThighEffector, _fullBodyIK.solver.leftFootEffector,
                                               _fullBodyIK.solver.rightThighEffector, _fullBodyIK.solver.rightFootEffector };

            var chains = new FBIKChain[] { _fullBodyIK.solver.leftArmChain, _fullBodyIK.solver.rightArmChain,
                                           _fullBodyIK.solver.leftLegChain, _fullBodyIK.solver.rightLegChain };

            for (int i = 0; i < EffectorIndices.Length; i++)
            {
                var targetIndex = EffectorIndices[i];
                var effector    = effectors[i];
                var area        = _ik.areas[targetIndex];
                SetIKUse(__instance, targetIndex, effector, area.isUse, _kinematicCtrl, false);
                SetIKWeight(__instance, targetIndex, effector, area.isUse, area.weight, false);
                hEditInstance.SetIKParent(_chara, _kinematicCtrl, area.parentCharaID, area.parentArea, targetIndex);
                hEditInstance.SetIKPos(_kinematicCtrl.lstIKBone[targetIndex].changeAmount, area.amount);
            }

            for (int i = 0; i < ChainIndices.Length; i++)
            {
                var targetIndex = ChainIndices[i];
                var chain       = chains[i];
                var area        = _ik.areas[targetIndex];
                SetIKUse(__instance, targetIndex, chain, area.isUse, _kinematicCtrl, false);
                SetIKWeight(__instance, targetIndex, chain, area.isUse, area.weight, false);
                hEditInstance.SetIKParent(_chara, _kinematicCtrl, area.parentCharaID, area.parentArea, targetIndex);
                hEditInstance.SetIKPos(_kinematicCtrl.lstIKBone[targetIndex].changeAmount, area.amount);
            }

            if (!_ik.isUse)
            {
                _kinematicCtrl.Active(PoseInfo.ModeEN.None, false);
            }
            else if (__instance.CharaInfoData != null && __instance.CharaInfoData.useCharaID != _charaID)
            {
                hEditInstance.KinematicCtrlAllVisible(_kinematicCtrl, false);
            }
            hEditInstance.nowPartCharaInfo = nowPartCharaInfo;
            return(false);
        }
示例#5
0
 private static void SetIKWeight(MotionIKUI instance, int area, FBIKChain chain, bool isOn, float value, bool isSave)
 {
     SetIKWeightChainMethod.Invoke(instance, new object[] { area, chain, isOn, value, isSave });
 }
示例#6
0
 private static void SetIKUse(MotionIKUI instance, int area, FBIKChain chain, bool isOn, KinematicCtrl kinematicCtrl, bool isSave)
 {
     SetIKUseChainMethod.Invoke(instance, new object[] { area, chain, isOn, kinematicCtrl, isSave });
 }
示例#7
0
 private static void SetIKWeight(MotionIKUI instance, int area, IKEffector effector, bool isOn, float value, bool isSave)
 {
     SetIKWeightEffectorMethod.Invoke(instance, new object[] { area, effector, isOn, value, isSave });
 }
示例#8
0
 private static void SetIKUse(MotionIKUI instance, int area, IKEffector effector, bool isOn, KinematicCtrl kinematicCtrl, bool isSave)
 {
     SetIKUseEffectorMethod.Invoke(instance, new object[] { area, effector, isOn, kinematicCtrl, isSave });
 }
示例#9
0
        private static void CopyIKParentingButton(MotionIKUI.IKUIInfo source, MotionIKUI.IKUIInfo target,
                                                  IKTargetIndices category, MotionSettingCanvas motionSettingCanvas, MotionIKUI uiObject)
        {
            var ikButton = UnityEngine.Object.Instantiate(source.btnIKSelectArea.gameObject).GetComponent <Button>();

            ikButton.transform.SetParent(target.tglUse.transform.parent, false);
            // MotionIKUI.kindMotion is a private field, so the copycat function will have to use reflection :/
            ikButton.OnClickAsObservable().Subscribe(_ => motionSettingCanvas.motionIKParentUI.OpenCategory((int)category,
                                                                                                            (HPart.Group.MotionKind)AccessTools.Field(typeof(MotionIKUI), "kindMotion").GetValue(uiObject)));
            target.btnIKSelectArea = ikButton;

            var buttonText = UnityEngine.Object.Instantiate(source.textParent.gameObject).GetComponent <TextMeshProUGUI>();

            buttonText.transform.SetParent(target.btnIKSelectArea.transform, false);
            buttonText.text   = "-";
            target.textParent = buttonText;
        }