f2b9186eef
* Added the ability to drag and drop any atom reference to a `AtomReference` without the need to manually select the type through the 3 dot button on inspector - I also refactored the `AtomBaseReferenceDrawer` script so that it's easier to read/maintain. - The class `BaseAtomInstancer` is needed to be able to auto reference instancers. Because when we drag a `GameObject` we need to get it's `AtomInstancer` component to determine the reference type. Also, the class represents something similiar to `BaseAtom` for `ScriptableObjects` but for `MonoBehaviors`, so it makes sense to have it. * Addressed some of the key points @soraphis made and fixed the issues I mentioned on the #442 pull - Solved the probelms that arise when a `GameObject` has multiple different instancers in it (mentioned in the #442 pull) - Removed `UsageIndex` class as it is not needed * Fixed file name not matching the class name * Addressed @soraphis issue of `GuiData` not being a struct, so I changed it and modified the `AtomBaseReferenceDrawer` to handle it as a struct * Fixed `GuiData` isn't updated even though `position` and `label` parameters of the `OnGUI` are. * Reversed the for loops order because the order of the components inside the `GameObject` are more important than the order of the "usages" so it fixes that problem - Also cleaned the code a bit * Missed a line that could be simplified - Made `Set/GetUsageIndex` into static because we can * Fixed issue mentioned in #442 > "you only get the first component, when dragging in a game object, so there could be the case where selecting the type manually and dragging into it will swap the field" The issue is when there are multiple instancer components in a single `GameObject` then when you drag said `GameObject` then the atom reference will switch to the first instancer (via usage index) no matter the intent of the user. However, the intent of the user could be to pick the 2nd or 3rd reference, so he could manually select the usage type using the 3 dots button, but it won't work if he decides to drag and drop a `GameObject` that has multiple instancers that the reference could switch to automatically, which will always be the first instancer of the dragged `GameObject`, which bascially makes the experience frustrating to that particular scenario. Now, you can guess that the issue is hyper specific just because of how hard it is to me to explain it in text, so don't worry if you didn't get it on the first read. If you would like me to showcase it, I will gladly share a video example of what I mean. * Fixed index out of range exception (I forgot that I set the usage index at the end of this method and it could be -1 because of this line) * Redone the previous push because it was incorrect * Response to @AdamRamberg to try to make the code section clearer by refactoring it * * Minor cosmetic changes * Replace switch expression to be backwards compatible (for example to be able to run the unity-atoms-example project) * Always remove the last greater than symbol in GetPropertyTypeName to take into account generic types * Added comment to IAtomInstancer * Removed `GuiData` * testing being able to merge * Removed `GuiData` in the new merged push * Removed `GuiData` class once again * Integrated the #447 fix - Also the variable `initialPosition` was missing so I added it back - Swapped the ordering of the `position` and `property` inside of the methods to match the ordering of the `OnGUI` method (I think it just makes more sense visually to order it this way) * Revert removal of compiler flags when setting valueFieldHeight --------- Co-authored-by: Adam Ramberg <adam@mambojambostudios.com> |
||
---|---|---|
.github | ||
docs | ||
Packages | ||
website | ||
.dockerignore | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
CHANGELOG.md | ||
CHANGELOG.md.meta | ||
CONTRIBUTING.md | ||
CONTRIBUTING.md.meta | ||
docker-compose.yml | ||
Dockerfile | ||
LICENSE.md | ||
LICENSE.md.meta | ||
omnisharp.json | ||
omnisharp.json.meta | ||
package.json | ||
package.json.meta | ||
Packages.meta | ||
PUBLISHING.md | ||
README.md | ||
README.md.meta |
⚛️ Unity Atoms
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.5.0",
"com.unity-atoms.unity-atoms-base-atoms": "4.5.0",
"com.unity-atoms.unity-atoms-fsm": "4.5.0",
"com.unity-atoms.unity-atoms-mobile": "4.5.0",
"com.unity-atoms.unity-atoms-mono-hooks": "4.5.0",
"com.unity-atoms.unity-atoms-tags": "4.5.0",
"com.unity-atoms.unity-atoms-scene-mgmt": "4.5.0",
"com.unity-atoms.unity-atoms-ui": "4.5.0",
"com.unity-atoms.unity-atoms-input-system": "4.5.0",
...
}
}
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
- Unity Atoms — Tiny modular pieces utilizing the power of Scriptable Objects
- Announcing Unity Atoms v2
- Unity Atoms v4 is out!
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.