예제 #1
0
        private static void AddNode(ClassDeclaration.Builder builder, Node node)
        {
            string nodeDirectory = NodeUtil.GetRelativeDirectory(node, UC.DIRECTORY_SEPERATOR);

            foreach (string assetName in node.AssetNames)
            {
                string propertyName = PropertyUtil.CleanName(assetName);
                string assetPath    = nodeDirectory + UC.DIRECTORY_SEPERATOR + assetName;
                string assetType    = "UnityEngine.Object";
                string propertyType = String.Format(PROPERTY_TYPE_FORMAT, assetType);

                string propertyValue =
                    String.Format(VALUE_FORMAT, assetType, assetPath, assetName);

                var property = new PropertyDeclaration.Builder(propertyType, propertyName)
                               .IsStatic(true)
                               .SetAccessModifier(AccessModifier.PUBLIC)
                               .SetValue(propertyValue)
                               .Build();

                builder.AddProperty(property);
            }

            foreach (Node subnode in node.Subnodes.Values)
            {
                string className       = NodeUtil.GetNodeDirectory(subnode);
                var    subClassBuilder = new ClassDeclaration.Builder(className)
                                         .IsStatic(true)
                                         .SetAccessModifer(AccessModifier.PUBLIC);

                AddNode(subClassBuilder, subnode);
                builder.AddSubclass(subClassBuilder.Build());
            }
        }