Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/publish-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish To GitHub Pages

on:
push:
branches:
- main

jobs:
Deploy:
runs-on: windows-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Install Unity
shell: pwsh
run: choco install unity --params="'/InstallationPath:C:\Program Files\Unity\Hub\Editor\2019.4.0f1'" --version=2019.4.0 --no-progress -y --ignore-package-exit-codes=3010

- name: Build DocFX
shell: pwsh
run: ./build.ps1 BuildDocs --unity-email $env:UNITY_EMAIL --unity-password $env:UNITY_PASSWORD --unity-serial $env:UNITY_SERIAL --is-ci
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}

- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v2
with:
target_branch: gh-pages
build_dir: Documentation/_site
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ jobs:
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
root: "UnityResourceGenerator/Assets/AutSoft.UnityResourceGenerator"

- name: Create GitHub Release
shell: pwsh
run: ./build.ps1 CreateGithubRelease --is-ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,4 @@ FodyWeavers.xsd
# End of https://www.toptal.com/developers/gitignore/api/visualstudio

!.vscode/**/*
.vscode/docfx-assistant
1 change: 1 addition & 0 deletions .nuke/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
temp/
131 changes: 131 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build Schema",
"$ref": "#/definitions/build",
"definitions": {
"build": {
"type": "object",
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"IsCi": {
"type": "boolean",
"description": "Are we running in CI"
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"BuildDocs",
"Compile",
"CreateGithubRelease",
"CreateMetadata",
"GenerateUnitySolution",
"Restore",
"ReturnLicense",
"ServeDocs"
]
}
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"BuildDocs",
"Compile",
"CreateGithubRelease",
"CreateMetadata",
"GenerateUnitySolution",
"Restore",
"ReturnLicense",
"ServeDocs"
]
}
},
"UnityEmail": {
"type": "string",
"description": "Email for Unity license"
},
"UnityPassword": {
"type": "string",
"description": "Password for Unity license"
},
"UnitySerial": {
"type": "string",
"description": "Serial for Unity license"
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
}
}
}
}
}
4 changes: 4 additions & 0 deletions .nuke/parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "./build.schema.json",
"Solution": "UnityResourceGenerator.sln"
}
2 changes: 2 additions & 0 deletions .vscode/spellright.dict
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
unrecoverably
parameterless
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
## 0.1.0
- Add initial project
# 0.2.0
- Add documentation website
- Reference documentation in `package.json`
- Make using namespaces optional
- Configure using directives
- Remove `IsResource` property from `IResourceData`. Scene path generation now depends on file extension
- Handle spaces in filenames
- Add known issues and update guide in the documentation

# 0.1.0
- Add initial project
9 changes: 9 additions & 0 deletions Documentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
5 changes: 5 additions & 0 deletions Documentation/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###############
# temp file #
###############
*.yml
.manifest
1 change: 1 addition & 0 deletions Documentation/api/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# C# API Documentation
51 changes: 51 additions & 0 deletions Documentation/articles/Customization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Customization

After pressing the `Generate Resource Paths` button, or visiting the `ResourceGenerator` page in the Project Settings an asset will be generated in the Assets folder, which will contain settings for the code generation.

## Built-in settings

![Generate Button](~/images/Customization/DefaultSettings.png)

### Basic settings

- **Folder from Assets**: Relative path to the folder where you want the generated class
- **Namespace**: The namespace of the generated class
- **Class name**: The name of the generated class. The file name will be the same
- **Log Infos**: Whether to log Info level logs. Turned off by default
- **Log Errors**: Whether to log Error level logs. Turned on by default

### Advanced settings

> [!NOTE]
> If you unrecoverably mess up your settings press the `Reset file mappings` button to restore the default file mappings

The data section describes the automatically generated file mappings. The data is an array. For each element of the array it will create a new inner class of the main generated one.

- **Class Name**: The name of the generated class
- **File Extensions**: Search pattern for the files
- **Data Type**: The C# type returned by `Resurces.Load`

The default mappings are created from the [Unity documentation](https://docs.unity3d.com/Manual/BuiltInImporters.html). If you know of any valid file mapping that the documentation does not state, please fork and create a Pull Request, or create an [Issue](https://github.com/AutSoft/UnityResourceGenerator/issues/new).

> [!WARNING]
> Scenes have special handling during the file generation, because of the way scenes paths are used by the SceneManager. Scenes are identified by the file ending `.unity`

## Extending the generated classes

The generated classes are `partial` by default. This means that if you want to add custom methods, simply create another `partial` class and add your code there.

```csharp
public static partial class ResourcePaths
{
public static partial class Scenes
{
public static string[] MainScenes { get; } = new []
{
Coins,
Level1,
Level2,
// ...
}
}
}
```
17 changes: 17 additions & 0 deletions Documentation/articles/Extensibility.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Extensibility

The library lets you to inject code into the generation pipeline. To access this feature, create a new Editor project, and reference `AutSoft.UnityResourceGenerator.Editor`. The included functionality is implemented using these mehtods.

## Module generation

A module is single string that is placed inside the main generated class. To create a custom module implement the [IModuleGenerator](xref:AutSoft.UnityResourceGenerator.Editor.Generation.IModuleGenerator) interface. The implementation must provide a parameterless constructor.

## Post processing

A post processor is a piece of code that is run after all modules are produced, and the final file text is created. To create a post processor implement the [IResourcePostProcessor](xref:AutSoft.UnityResourceGenerator.Editor.Generation.IResourcePostProcessor) interface. The implementation must provide a parameterless constructor.

The input of the processor is the current state of the generated file and it returns the new state of the generated file. Post processors also provide a Priority property which determines the ordering of them.

## Using directives

The generated using directives are also customizable under the settings window. If your custom generated code will require other using directives, there is no need to generate them, simply add them in the settings
21 changes: 21 additions & 0 deletions Documentation/articles/GettingStarted.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Getting Started

The Unity Resource Generator is a Unity Editor tool which can generate a helper class which will create a helper class that contains paths to loadable Unity resources. Additionally it will also generate helper methods to load scenes.

The generation of the class is customizable by default and the library also lets developers create custom code to run during generation.

## Installation

Use [OpenUPM](https://openupm.com/) to install the package.

```
openupm add com.autsoft.unityresourcegenerator
```

## Running the tool

The tool will create new button in the Editor at `Tools / Generate Resource Paths`

![Generate Button](~/images/intro/GenerateButton.png)

If your click the button the helper class will be generated in the root of the `Assets` folder
16 changes: 16 additions & 0 deletions Documentation/articles/KnownIssues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Known issues

## 0.1.0 - *

- SpecialCharacters can break generated names.
- Numbers at the end of the files are supported, but not at the start
- Any character in the filename which would not be a valid C# filed/property/method name will break the generated code
- Spaces get removed
- For Example:
- `Coin1` works
- `Coin 1` works
- `1Coin` does not
- `!Coin` does not
- `Coin!` does not

- Duplicate file names in the same class module will break the generated file. The solution for this requires further investigation
6 changes: 6 additions & 0 deletions Documentation/articles/UpgradeGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Upgrade Guide

Always update using the Unity Package Manager

## 0.1.0 - *
- If default file mappings or namespaces change, and you have custom ones, it is advised that you create a copy of your old settings, press the `Reset file mappings` button in the `Project Settings` window and then manually recreate your custom mappings.
10 changes: 10 additions & 0 deletions Documentation/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Getting Started
href: GettingStarted.md
- name: Customization
href: Customization.md
- name: Extensibility
href: Extensibility.md
- name: Known Issues
href: KnownIssues.md
- name: Upgrade Guide
href: UpgradeGuide.md
Loading