Example #1
0
        public void CreateInterfaceScript()
        {
            RecursiveFindReferences();
            var filePath = SaveFilePanel("Save Script", Directory, $"{Filename}-Interface", "cs");

            VariantGenerator.CreateScriptInterfaceOnly(filePath, Namespace, Types);
        }
Example #2
0
        public void CreateClassesScript()
        {
            RecursiveFindReferences();
            var filePath = SaveFilePanel("Save Script", Directory, $"{Filename}-Classes", "cs");

            VariantGenerator.CreateScriptClassOnly(filePath, Namespace, Types, IsReferenceType);
        }
        private void GenerateVariantInterface(Type valueType, string suffix, CreateVariants createVariants)
        {
            var directory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(Generator)) + "/" + VariantInterfaceDirectory;

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }

            var filepath = $"{directory}/{valueType.Name}{suffix}.cs";

            if (!File.Exists(filepath) || File.ReadLines(filepath).FirstOrDefault() == HEAD_LINE)
            {
                using var writer = new StreamWriter(filepath);
                writer.WriteLine(HEAD_LINE);
                writer.WriteLine(VariantGenerator.NamespaceBegin(VariantInterfaceNamespace));
                createVariants(writer, valueType, IsReferenceType, suffix);
                writer.WriteLine(VariantGenerator.NamespaceEnd());
            }
        }