Esempio n. 1
0
        private static void CreateLayerValues(GenerateSetting setting)
        {
            var layers = InternalEditorUtility.layers;

            var layerIdClass   = new CSharpEnum(setting.@namespace, "LayerId");
            var layerMaskClass = new CSharpEnum(setting.@namespace, "LayerMaskValue")
            {
                IsFlags = true
            };

            foreach (var layer in layers)
            {
                var layerId = LayerMask.NameToLayer(layer);
                layerIdClass.Fields.Add(new Variable("int", layer, layerId.ToString(), Modifier.StaticReadonly)
                {
                    Comment = layer,
                });

                var mask = $"1 << {layerId}";
                layerMaskClass.Fields.Add(new Variable("int", layer, mask, Modifier.StaticReadonly)
                {
                    Comment = layer,
                });
            }
            GenerateSourceCode(setting, "LayerValues.Generated", layerIdClass, layerMaskClass);
        }
Esempio n. 2
0
        private void WriteEnum(CSharpEnum @enum)
        {
            WriteSummaryComment(@enum.Comment);
            if (@enum.IsFlags)
            {
                WriteOneLine("[System.Flags]");
            }
            WriteOneLine(@enum.GetClassDeclareString());
            WriteOneLine("{");
            using (_indent.Scope)
            {
                foreach (var field in @enum.Fields)
                {
                    WriteSummaryComment(field.Comment);
                    WriteOneLine(field.ToEnumDeclareString());
                    WriteNewLine();
                }
            }

            WriteOneLine("}");
        }