File Generator Pro documentation

PolyLabs | Version 1.2 | Nov 3, 2020 | support@polylabs.co

Introduction

File Generator Pro is a rethinking of the built-in script creation system in Unity. When developing games, you'll find that many of your files aren't MonoBehaviours, but the Create C# Script option in Unity only provides the ability to create a default class deriving from MonoBehaviour.

File Generator Pro enables you to create classes, interfaces, enums, and structs. It is capable validating classes and implementing complex inheritance on file creation, and even allows you to create multiple classes at once using the batch tool! Additionally, this tool has the ability to generate general-purpose files such as JSON, XML, Text, and even Markdown files.

 

Getting Started

File Generator Pro has two primary ways of being utilized; via the top menu and the project window context-menu.

Accessing Via Top Menu

To open the tool using the top menu, navigate to Tools => File Generator Pro => New File...

accessViaTopMenu

 

Accessing Via Project Context View

In the Project window, you can either select the Create dropdown, or select any folder in your hierarcy where you would like to create a file and right-click Create => File Generator Pro => NewFile...

accessViaContextMenu

Selecting on a file or directory in the Assets folder will result in the source destination to default to the currently selected object in the project hierarchy.

Note: You can still change the file destination at any time!

General File Menu

generalWindowImage

Clicking on any icon in the selection menu will navigate to the appropriate creation menu.

Creating a Class

createClassImage

File Destination

The source folder is selected by using the Browse.. button. Something to note is that the source file can only be created within the Assets folder.

Selecting Create & Open will generate the file and open it in the default code editor set in the Unity preferences.

Creating an Interface

createInterfaceImage

Creating an Enum

createEnumImage

Creating a Struct

createStructWindow

The Batch Tool

batchToolImage

 

Preferences

Preferences Image

Default Project Namespace

With this, the Namespace field in each category will automatically be populated with the chosen namespace. This takes effect project-wide. By default, this is left empty.

Curly Braces

Defines the code preference for how to format where curly braces should go in code. Newline is selected by default.

Newline

Sameline

Class Method Body

When auto-implementing class methods, this option defines what should be placed in the method body by default.

Return Default

NotImplementedException

Auto-Implement Class Inheritance

True by default. When selected, the generator will attempt to automatically populate the newly created class with the correct methods. It is able to recursively traverse inheritance trees to find any unimplemented abstract methods, and will also implement all interface methods.

When not selected, only the class definition will be provided, and a constructor if chosen.

Enable Overwrite

Not Reccomended, false by default (see FAQ). Setting the overwrite preference to true allows generated files of the same name as existing files to overwrite the contents of those files. Take extra care when contemplating if this should be enabled.

Always Implicitly Implement Interfaces

True by default. When implementing classes that inherit multiple interfaces, there is a possibility for two interfaces to have the same method signatures, but different return values. This clash can create errors, and can be remedied by explicitly implementing the interfaces (with its own drawbacks).

When not selected, whenever two or more interfaces are being implemented, they will always be explicitly implemented to avoid errors.

 

Frequently Asked Questions

When I type in a UnityEngine super class, it says that the name isn't found. Why?

Except for MonoBehaviour, which is treated as a special case for a default super class, any entity (class, interface, struct, enum, etc..) that is part of the UnityEngine (or UnityEditor) namespace needs to contain the fully qualified name.

For Example

 

I can't find a class or interface when trying to use inheritance, how can I fix this?

Usually, this comes down to making sure spelling is correct, and checking that you are using the fully qualified name of your entity; if the class or interface is contained in a namespace, make sure you are entering it in as "MyNamespace.MyClass".

If you have done both of these without remedy, reach out to our support contact with a description of your issue.

 

Why Can't MonoBehaviour classes be serialized?

Unity does not support serialization for MonoBehaviour classes, so any properties within the class you want to serialize will need to be individually serialized. Separating the data into a non-MonoBehaviour class is a common solution to this issue.

 

Why did my new file fail to write?

There are a variety of reasons that a file might not be able to be created, including:

 

Why is the overwrite option not recommended?

When creating a new file or a batch of classes, the last thing you would want to have happen is to accidentally overwrite an important file! While a good version control system would allow this to be easily undone (and everyone should use one when developing games!) , we want to make sure that you fully understand the potential dangers that can come from not being careful with the feature, especially in the case where you do not have a VCS in place.

 

Support

If you have any questions, concerns, issues, or feature requests don't hesitate to reach out to us at

support@polylabs.co

To best help with an issue, please provide the version number in the support tab of the editor utility, and a description of your issue.

 

 

PolyLabs Home