public HierarchyNodeGenerator(GameObject go)
        {
            this.rootNode = GetNodeInfo(go.transform);
            this.FileName = string.Format("{0}Node", this.rootNode.Name);

            this.ScriptString = CreateScript(this.rootNode);
            this.ComponentScriptString = CreateComponentScript(this.rootNode);
        }
 private string CreateScript(NodeInfo node)
 {
     return string.Format(SCRIPT_TEMPLATE, AddIndent(CreateNode(node)));
 }
 private string CreateNodeProperty(NodeInfo node)
 {
     var props = node.Components.Select(type => string.Format(NODE_PROPERTY_TEMPLATE, type, type.Split('.').Last())).ToArray();
     return string.Join("\n\n", props);
 }
 private string CreateNodeChild(NodeInfo node)
 {
     var props = node.ChildNodes.Select(c => string.Format(NODE_CHILD_PROPERTY_TEMPLATE, node.ClassName, c.ClassName, c.Name, Regex.Replace(c.OriginalName, "\"", "\\\""))).ToArray();
     return string.Format(NODE_CHILD_TEMPLATE, node.ClassName, AddIndent(string.Join("\n\n", props)));
 }
        private string CreateNode(NodeInfo node)
        {
            var nodeProp = "";

            if (node.Components.Count > 0)
            {
                nodeProp = string.Format("\n\n{0}", AddIndent(CreateNodeProperty(node)));
            }

            if (node.ChildNodes.Count != 0)
            {
                var childClasses = node.ChildNodes.Select(c => CreateNode(c)).ToArray();
                return string.Format(NODE_TEMPLATE, node.ClassName, AddIndent(string.Join("\n\n", childClasses)), nodeProp, CreateNodeChild(node));
            }

            return string.Format(EMPTY_CHILDREN_NODE_TEMPLATE, node.ClassName, nodeProp);
        }
 private string CreateComponentScript(NodeInfo node)
 {
     return string.Format(COMPONENT_SCRIPT_TEMPLATE, this.FileName, node.ClassName);
 }