Beispiel #1
0
        public string GenerateClass(string className)
        {
            var classBuilder = new ClassDeclaration.Builder(className)
                               .SetAccessModifer(AccessModifier.PUBLIC);

            for (int layerIndex = 0; layerIndex < MAX_NUM_LAYERS; layerIndex++)
            {
                string layerName = UnityLayerMask.LayerToName(layerIndex);

                if (0 == layerName.Length)
                {
                    continue;
                }

                string layerPropertyName = PropertyUtil.CleanName(layerName);
                var    property          = new PropertyDeclaration.Builder(C.INT_TYPE, layerPropertyName)
                                           .SetAccessModifier(AccessModifier.PUBLIC)
                                           .SetValue(layerIndex.ToString())
                                           .IsStatic(true)
                                           .Build();

                classBuilder.AddProperty(property);
            }

            return(CSharpGenerator.GenerateClass(classBuilder.Build()));
        }
Beispiel #2
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());
            }
        }
Beispiel #3
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()));
        }
Beispiel #4
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()));
        }