public static void SpringBoneCopy(UnitychanSpringBoneCopyHelperData copyData)
        {
            var length = copyData.Before.Length < copyData.After.Length
                ? copyData.Before.Length
                : copyData.After.Length;

            for (var i = 0; i < length; i++)
            {
                if (copyData.Before[i] == null || copyData.After[i] == null)
                {
                    continue;
                }

                var pivot         = copyData.After[i].pivotNode;
                var sphCollider   = copyData.After[i].sphereColliders;
                var capCollider   = copyData.After[i].capsuleColliders;
                var panelCollider = copyData.After[i].panelColliders;

                copyData.After[i].stiffnessForce   = copyData.Before[i].stiffnessForce;
                copyData.After[i].dragForce        = copyData.Before[i].dragForce;
                copyData.After[i].springForce      = copyData.Before[i].springForce;
                copyData.After[i].windInfluence    = copyData.Before[i].windInfluence;
                copyData.After[i].pivotNode        = pivot;
                copyData.After[i].angularStiffness = copyData.Before[i].angularStiffness;
                copyData.After[i].yAngleLimits     = copyData.Before[i].yAngleLimits;
                copyData.After[i].zAngleLimits     = copyData.Before[i].zAngleLimits;
                copyData.After[i].radius           = copyData.Before[i].radius;
                copyData.After[i].sphereColliders  = sphCollider;
                copyData.After[i].capsuleColliders = capCollider;
                copyData.After[i].panelColliders   = panelCollider;
            }
        }
Ejemplo n.º 2
0
        private void OnGUI()
        {
            EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(true));
            {
                //コピー元
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    if (GUILayout.Button("選択中のオブジェクト以下のSpringBoneを登録する"))
                    {
                        var selectSpringBones = FindFollowerSpringBone();
                        if (selectSpringBones != null)
                        {
                            beforeSpringBone = selectSpringBones;
                        }
                    }

                    EditorGUILayout.Space();

                    _beforeScrollPos = EditorGUILayout.BeginScrollView(_beforeScrollPos, GUI.skin.box);
                    {
                        ArrayApplyModifiedProperties(nameof(beforeSpringBone), "コピー元");
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                //コピー先
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    if (GUILayout.Button("選択中のオブジェクト以下のSpringBoneを登録する"))
                    {
                        var selectSpringBones = FindFollowerSpringBone();
                        if (selectSpringBones != null)
                        {
                            afterSpringBone = selectSpringBones;
                        }
                    }

                    EditorGUILayout.Space();

                    _afterScrollPos = EditorGUILayout.BeginScrollView(_afterScrollPos, GUI.skin.box);
                    {
                        ArrayApplyModifiedProperties(nameof(afterSpringBone), "コピー先");
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();

            //エラー、警告判定
            if (beforeSpringBone.Length <= 0 || afterSpringBone.Length <= 0)
            {
                EditorGUILayout.HelpBox("リストの状態が不正です。", MessageType.Error);
                return;
            }

            if (beforeSpringBone.Any(bsb => bsb == null) || afterSpringBone.Any(asb => asb == null))
            {
                EditorGUILayout.HelpBox("Nullが含まれています。\r\n該当要素はスキップされます。", MessageType.Warning);
            }

            if (beforeSpringBone.Length != afterSpringBone.Length)
            {
                EditorGUILayout.HelpBox("配列のサイズが違います。\r\n足りない要素分はスキップされます。", MessageType.Warning);
            }

            //コピー!
            if (GUILayout.Button("コピー!"))
            {
                var copyData = new UnitychanSpringBoneCopyHelperData()
                {
                    Before = beforeSpringBone,
                    After  = afterSpringBone
                };
                UnitychanSpringBoneCopyHelper.SpringBoneCopy(copyData);
            }
        }