Example #1
0
        public string GenerateClass(string className)
        {
            var fileBuilder = new FileDeclaration.Builder()
                              .AddUsingDeclaration <RToolSortingLayer>();
            var classBuilder = new ClassDeclaration.Builder(className)
                               .IsStatic(true)
                               .SetAccessModifer(AccessModifier.PUBLIC);

            foreach (UnitySortingLayer sortingLayer in UnitySortingLayer.layers)
            {
                string propertyName  = PropertyUtil.CleanName(sortingLayer.name);
                string propertyValue = GetValueString(sortingLayer);

                var propertyBuilder =
                    PropertyDeclaration.GetBuilder <RToolSortingLayer>(propertyName)
                    .SetAccessModifier(AccessModifier.PUBLIC)
                    .IsStatic(true)
                    .SetValue(propertyValue);

                classBuilder.AddProperty(propertyBuilder.Build());
            }

            fileBuilder.SetClass(classBuilder.Build());
            return(CSharpGenerator.GenerateFile(fileBuilder.Build()));
        }
Example #2
0
        public string GenerateClass(string className)
        {
            Node baseNode = new NodeBuilder(UnityApplication.dataPath, metaFileMatcher).Build();

            var fileBuilder  = new FileDeclaration.Builder();
            var classBuilder = new ClassDeclaration.Builder(className)
                               .IsStatic(true)
                               .SetAccessModifer(AccessModifier.PUBLIC);

            AddNode(classBuilder, baseNode);

            fileBuilder.AddUsingDeclaration <RToolResource <UnityObject> >();
            fileBuilder.SetClass(classBuilder.Build());
            return(CSharpGenerator.GenerateFile(fileBuilder.Build()));
        }