Go to file
Oliver Biwer 06fc87a123 compatibility with dynamic assemblies and different namespace/class conditions (#230)
* compatibility with dynamic assemblies

* fixing #232

fixed a case where the class namespace might be null

* fixing #232 + corrections, fixing #233

* Fix nested types not being generated correctly

VALUE_TYPE_NAME_NO_PAIR had an incorrect value if the type was nested.

* Reimagine the Generators Type Selector Layout

UNTESTED! I will test if the generator later this week (18/01).
UNCOMMENTED! Same as above.

The new selector will neatly separate namespaces from types, is ordered alphabetically and goes down a new level for every subnamespace. It will now also display nested types as such (so nested type Bar is displayed as Foo+Bar). This means that types of the same name but in different namespaces are now supported.

It will also ignore any abstract or generic types as Atoms can only generate solid types (...I think?)

If you want to check it out, I recommend looking at how NamespaceLevel works. It splits types up into types that have reached their namespace level and types that can still go deeper, in which case they are rooted as part of the NamespaceLevel. From there, it can handle adding dropdown items and finding a selected Type.

* Enable all GenerationOptions by default

Or on a Reset of the SO

* Ensure instantiated generator has unique assetpath

This can otherwise lead to weird behaviour if a new asset is created at the path of an existing asset

* Use variables for SerializedProperties

* Make objectfields to generated scripts readonly

These should not be edited which may lead to errors.

* Add comments

* Use hash to find which type belongs to which DropdownItem

* Use level to distinquish between namespace levels

Using TrimStart was also trimming off characters after dots (.) if appropriate.

* Safety measure

Ensure serializedObject.Update is called in the beginning of OnInspectorGUI.

* Fix size of Dropdown

It will now neatly cover all the generator options. This doesn't really matter at all, I just think it looks neat, plus it ensures there is always enough view to not have trouble selecting a type.

* Use CompilationPipeline to get assemblies

Pros: It only collects Unity Assemblies that are not Editor Only. This ensures that every type will 100% be compatible in builds.
Cons: It doesn't find any assemblies outside of Unity, for example the System assembly.

Personally I like this way better since it ensures support even for cross platform development. Imagine someone generating a type you can only find in Windows, then trying to build for Mac. We can still populate the base package with the base values from systems and people will still be able to create Atoms for unsupported values, just not using the generator.

Alternatively we could create an "unsafe" toggle.

* Use CompilationPipeline to get assemblies

Pros: It only collects Unity Assemblies that are not Editor Only. This ensures that every type will 100% be compatible in builds.
Cons: It doesn't find any assemblies outside of Unity, for example the System assembly.

Personally I like this way better since it ensures support even for cross platform development. Imagine someone generating a type you can only find in Windows, then trying to build for Mac. We can still populate the base package with the base values from systems and people will still be able to create Atoms for unsupported values, just not using the generator.

Alternatively we could create an "unsafe" toggle.

* Add Safe Search toggle to AtomGenerator

Previously, the AtomGenerator was only able to generate types that were Unity compatible and either Serializable or ScriptableObjects.

The first change is that it now also searches for Objects to account for prefabs.
The second change is a toggle next to the generator to differentiate between searching for Unity compatible types and searching for all types (denoted as "unsafe types"). This does what it promises: it gets all the (dynamic) assemblies it can find, retrieves all exported types, and makes no distinction between serializable or nonserializable. This returns the functionality to generate for example strings and ints with the generator.

* Add Quality of Life improvements to the Editor

Co-authored-by: Casey Hofland <hofland.casey@gmail.com>
2021-03-07 21:49:39 +01:00
.github/ISSUE_TEMPLATE Add initial issue templates 2019-10-16 23:19:08 +02:00
docs Changes due to move to new organization 2021-01-22 08:22:16 +01:00
Packages compatibility with dynamic assemblies and different namespace/class conditions (#230) 2021-03-07 21:49:39 +01:00
scripts Unity Atoms Input System Integration (#212) 2020-12-21 00:24:12 +01:00
website Revert "Bump highlight.js from 9.15.10 to 9.18.5 in /website (#244)" (#245) 2021-01-23 19:56:02 +01:00
.dockerignore Add website for documentation 2019-10-04 01:37:30 +02:00
.editorconfig Added eslint + prettier and updated .editorconfig 2019-10-07 20:47:30 +02:00
.gitattributes Added .gitattributes file 2019-04-07 11:56:55 +02:00
.gitignore Update docs + remove ds store 2020-03-02 18:42:19 +01:00
CHANGELOG.md 🍺 v4.4.2 2020-12-30 22:36:53 +01:00
CHANGELOG.md.meta Add missing meta + adjust package.json 2019-10-03 17:51:16 +02:00
CONTRIBUTING.md Changes due to move to new organization 2021-01-22 08:22:16 +01:00
CONTRIBUTING.md.meta Add missing meta + adjust package.json 2019-10-03 17:51:16 +02:00
docker-compose.yml Add website for documentation 2019-10-04 01:37:30 +02:00
Dockerfile #189 Restructure tutorials and add two new tutorials (#190) 2020-08-23 12:13:10 +02:00
LICENSE.md New repo structure 2019-10-01 17:27:22 +02:00
LICENSE.md.meta Add missing meta + adjust package.json 2019-10-03 17:51:16 +02:00
omnisharp.json Added eslint + prettier and updated .editorconfig 2019-10-07 20:47:30 +02:00
omnisharp.json.meta Squashed commit of the following: 2019-03-17 23:43:20 +01:00
package-lock.json 🧞‍♀️ v4.3.0 2020-08-04 01:58:16 +02:00
package.json Changes due to move to new organization 2021-01-22 08:22:16 +01:00
package.json.meta Squashed commit of the following: 2019-03-17 23:43:20 +01:00
Packages.meta Add missing meta + adjust package.json 2019-10-03 17:51:16 +02:00
PUBLISHING.md v2.1.0 🚀 2019-11-28 19:35:59 +01:00
README.md Changes due to move to new organization 2021-01-22 08:22:16 +01:00
README.md.meta Squashed commit of the following: 2019-03-17 23:43:20 +01:00

⚛️ Unity Atoms

openupm openupm openupm openupm openupm openupm openupm openupm

Tiny modular pieces utilizing the power of Scriptable Objects

Influences

Unity Atoms is derived from and a continuation of Ryan Hipple's talk from Unite 2017. The original source code can be found here.

This talk by Richard Fine is a forerunner to Ryan Hipple's talk during Unite 2016.

Motivation

The general approach to building scripts in Unity often generates a code base that is monolithic. This results in that your code is cumbersome to test, non-modular and hard to debug and understand.

Unity Atoms is an open source library that aims to make your game code:

  • 📦 Modular - avoid scripts and systems directly dependent on each other
  • ✏️ Editable - Scriptable Objects makes it possible to make changes to your game at runtime
  • 🐛 Debuggable - modular code is easier to debug than tightly coupled code

Installation

NPM

Prerequisite: Since Unity Atoms is using the Unity Package Manager (UPM) you need to use Unity version 2018.3 >=

Add the following to your manifest.json (which is located under your project location in the folder Packages):

{
    "scopedRegistries": [
        {
            "name": "NPM Registry",
            "url": "https://registry.npmjs.org",
            "scopes": [
                "com.unity-atoms.unity-atoms-core",
                "com.unity-atoms.unity-atoms-base-atoms",
                "com.unity-atoms.unity-atoms-fsm",
                "com.unity-atoms.unity-atoms-mobile",
                "com.unity-atoms.unity-atoms-mono-hooks",
                "com.unity-atoms.unity-atoms-tags",
                "com.unity-atoms.unity-atoms-scene-mgmt",
                "com.unity-atoms.unity-atoms-ui",
		        "com.unity-atoms.unity-atoms-input-system"
            ]
        }
    ],
    "dependencies": {
        ...
        "com.unity-atoms.unity-atoms-core": "4.4.2",
        "com.unity-atoms.unity-atoms-base-atoms": "4.4.2",
        "com.unity-atoms.unity-atoms-fsm": "4.4.2",
        "com.unity-atoms.unity-atoms-mobile": "4.4.2",
        "com.unity-atoms.unity-atoms-mono-hooks": "4.4.2",
        "com.unity-atoms.unity-atoms-tags": "4.4.2",
        "com.unity-atoms.unity-atoms-scene-mgmt": "4.4.2",
        "com.unity-atoms.unity-atoms-ui": "4.4.2",
	    "com.unity-atoms.unity-atoms-input-system": "4.4.2",
        ...
    }
}

Note that the core and base atoms packages are mandatory while the others are optional. If you don't want a subpackage, simply remove it from your dependencies. Note that subpackages may have additional dependencies.

OpenUPM

The package is available on the openupm registry. It's recommended to install it via openupm-cli.

# required
openupm add com.unity-atoms.unity-atoms-core
openupm add com.unity-atoms.unity-atoms-base-atoms

# optional
openupm add com.unity-atoms.unity-atoms-fsm
openupm add com.unity-atoms.unity-atoms-mobile
openupm add com.unity-atoms.unity-atoms-mono-hooks
openupm add com.unity-atoms.unity-atoms-tags
openupm add com.unity-atoms.unity-atoms-scene-mgmt
openupm add com.unity-atoms.unity-atoms-ui
openupm add com.unity-atoms.unity-atoms-input-system

Documentation

The Unity Atoms docs are now published at https://unity-atoms.github.io/unity-atoms.

Blog posts

How does it work?

Read this article on Medium for a great introduction to Unity Atoms.

Looking for support?

For questions and support please join our Discord channel.

Maintainers

We are looking for more people to join the team! Contact us if you want to jump aboard.