예제 #1
0
        private static void AppendPivots(CSVBuilder builder, IEnumerable <SpringBone> springBones)
        {
            var pivotSerializers = springBones
                                   .Where(bone => bone.pivotNode != null &&
                                          bone.pivotNode != bone.transform.parent &&
                                          bone.pivotNode.parent != null)
                                   .Select(bone => bone.pivotNode)
                                   .Distinct()
                                   .Select(pivot => PivotToSerializer(pivot));

            if (!pivotSerializers.Any())
            {
                return;
            }

            string[] pivotHeader = { "// PivotName", "ParentName", "local rotation x", "y", "z" };

            builder.AppendLine();
            builder.AppendLine("[Pivots]");
            builder.AppendLine(pivotHeader);
            foreach (var pivot in pivotSerializers)
            {
                builder.Append(pivot);
                builder.AppendLine();
            }
        }
        // private

        private static void AppendColliders(CSVBuilder builder, GameObject colliderRoot)
        {
            var sphereColliders = colliderRoot.GetComponentsInChildren <SpringSphereCollider>(true)
                                  .Select(item => SphereColliderToSerializer(item));
            var capsuleColliders = colliderRoot.GetComponentsInChildren <SpringCapsuleCollider>(true)
                                   .Select(item => CapsuleColliderToSerializer(item));
            var panelColliders = colliderRoot.GetComponentsInChildren <SpringPanelCollider>(true)
                                 .Select(item => PanelColliderToSerializer(item));

            if (!sphereColliders.Any() && !capsuleColliders.Any() && !panelColliders.Any())
            {
                return;
            }

            string[][] headerRows =
            {
                new string[] { "// ColliderName", "ParentName", "pos x", "y", "z", "rot x", "y", "z", "scale x", "y", "z", "ColliderType", "Parameters"     },
                new string[] { "//",              "",           "",      "",  "",  "",      "",  "",  "",        "",  "",  "Sp (Sphere)",  "radius", "linkedRenderer"},
                new string[] { "//",              "",           "",      "",  "",  "",      "",  "",  "",        "",  "",  "Cp (Capsule)", "radius", "height", "linkedRenderer"},
                new string[] { "//",              "",           "",      "",  "",  "",      "",  "",  "",        "",  "",  "Pa (Panel)",   "width", "height", "linkedRenderer"}
            };

            builder.AppendLine();
            builder.AppendLine("[Colliders]");
            foreach (var headerRow in headerRows)
            {
                builder.AppendLine(headerRow);
            }

            foreach (var serializer in sphereColliders)
            {
                builder.Append(serializer);
                builder.AppendLine();
            }

            foreach (var serializer in capsuleColliders)
            {
                builder.Append(serializer);
                builder.AppendLine();
            }

            foreach (var serializer in panelColliders)
            {
                builder.Append(serializer);
                builder.AppendLine();
            }
        }
예제 #3
0
        private static void AppendSpringBones(CSVBuilder builder, IEnumerable <SpringBone> springBones)
        {
            if (!springBones.Any())
            {
                return;
            }

            string[] springBoneHeaderRow =
            {
                "// bone",
                "radius",
                "stiffnessForce",
                "dragForce",
                "springForce x",
                "springForce y",
                "springForce z",
                "wind influence",
                "pivot node",
                "use y angle limit",
                "y angle min",
                "y angle max",
                "use z angle limit",
                "z angle min",
                "z angle max",
                "angle stiffness",
                "length limit count",
                "length limit target",
                "length limit ratio x N",
                "collider x N"
            };

            builder.AppendLine();
            builder.AppendLine("[SpringBones]");
            builder.AppendLine(springBoneHeaderRow);
            foreach (var bone in springBones)
            {
                var boneSerializer = SpringBoneToBaseSerializer(bone);
                builder.Append(boneSerializer);

                var colliderNames = new List <string>();
                colliderNames.AddRange(bone.sphereColliders.Where(item => item != null).Select(item => item.name));
                colliderNames.AddRange(bone.capsuleColliders.Where(item => item != null).Select(item => item.name));
                colliderNames.AddRange(bone.panelColliders.Where(item => item != null).Select(item => item.name));
                builder.AppendLine(colliderNames.Distinct());
            }
        }
        private static void AppendDynamicsNulls(CSVBuilder builder, GameObject rootObject)
        {
            var dynamicsNulls = rootObject.GetComponentsInChildren <DynamicsNull>(true)
                                .Select(item => TransformToSerializer(item.transform));

            if (!dynamicsNulls.Any())
            {
                return;
            }

            builder.AppendLine();
            builder.AppendLine("[DynamicsNulls]");
            foreach (var item in dynamicsNulls)
            {
                builder.Append(item);
                builder.AppendLine();
            }
        }