Exemple #1
0
        private static void BuildComponents
        (
            Dictionary <string, Transform> objectMap,
            IEnumerable <TextRecordParsing.Record> records
        )
        {
            var componentDefiners = SpringSetupComponentDefiners.GetComponentDefiners();

            foreach (var entry in records)
            {
                Transform transform = null;
                if (objectMap.TryGetValue(entry.GetString(0), out transform))
                {
                    var gameObject   = transform.gameObject;
                    var currentQueue = new Queue <string>(entry.Items.Skip(1));
                    foreach (var definer in componentDefiners)
                    {
                        definer.BuildFromDefinition(gameObject, currentQueue);
                    }
                }
            }
        }
        private static string BuildComponentDefinitionString(GameObject colliderRoot)
        {
            var builder = new System.Text.StringBuilder();

            const string ComponentHeaderToken = "[Components]";

            builder.Append("\n");
            builder.Append(ComponentHeaderToken);
            builder.Append("\n");

            var componentDefiners = SpringSetupComponentDefiners.GetComponentDefiners();
            var children          = colliderRoot.GetComponentsInChildren <Transform>(true);
            var hasAnyComponents  = false;

            foreach (var child in children)
            {
                var hasUsableComponents = false;
                var componentBuilder    = new System.Text.StringBuilder();
                foreach (var definer in componentDefiners)
                {
                    if (definer.TryToAppendDefinition(componentBuilder, child.gameObject))
                    {
                        hasUsableComponents = true;
                    }
                }

                if (hasUsableComponents)
                {
                    AppendRecordItem(builder, child.name);
                    AppendRecordItem(builder, componentBuilder.ToString());
                    builder.Append("\n");
                    hasAnyComponents = true;
                }
            }

            return(hasAnyComponents ? builder.ToString() : "");
        }