Giter VIP home page Giter VIP logo

unity-atoms's Introduction

⚛️ Unity Atoms

openupm 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.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

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.

unity-atoms's People

Contributors

adamramberg avatar ahsolo avatar bguyl avatar btsslawa avatar caseyhofland avatar dependabot[bot] avatar drdavient avatar enderlook avatar fakegood avatar favoyang avatar hazarartuner avatar icetrooper avatar iruizmar avatar jmacgill avatar jzapdot avatar kyrw avatar lumpn avatar matthewtole avatar miikalo avatar mutmedia avatar pnarimani avatar ribeiroferreiralucas avatar simonbucher avatar soraphis avatar thimodev avatar toasterhead-master avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-atoms's Issues

Create / autogenerate Unity Atoms specific script templates

Is your feature request related to a problem? Please describe.
This is an issue that tries to increase the developer experience using Unity Atoms. It would be really nice if there were templates / CreateAssetMenu items for some Atoms, eg:

  • Functions - eg: Create IntFunction or Create BoolIntFunction
  • Actions - eg: Create IntAction
  • Listeners - eg: Create FloatBoolListener
  • Events - eg: Create IntBoolEvent

My thinking is that these should be generated based on the Atom types that are defined. This should probably also be part of the Generator as well as further additions to the generation (see issue #60).

Describe the solution you'd like
The best DX would be to add templates (like the ones in the generator) and then generate .cs files from the templates calling a method via a CreateAssetMenu attribute. When clicking the CreateAssetMenu we probably also need some solution to enter the name of the newly generated Atom.

Describe alternatives you've considered
The straight forward solution would be to generate these templates in the Generator following this: https://support.unity3d.com/hc/en-us/articles/210223733-How-to-customize-Unity-script-templates

This doesn't sounds like a great solution since it is not possible (to my knowledge) to add templates on a project basis (only global).

In this case there will be an option to "Generate Unity Atoms scripting templates", but also "Remove generated Unity Atoms scripting templates".

Additional context
Consider finishing #60 before starting this issue.

Efficient AtomicTags

I just saw the atomittacs issue/feature and it has imho many of the problems unity has with its own tags:

https://github.com/AdamRamberg/unity-atoms/blob/v1.0.0/Assets/UnityAtoms/AtomicTags/AtomicTags.cs

checking if a tag is in the list: O(n) in a hashset O(1). now, hashsets are not serializable but: ISerializationCallbackReceiver to the rescue.

also, tagged objects could add/remove themselfs (OnEnable / OnDisable) from a static Dictionary<StringReference, List<GameObject>> with the addition of public static GameObject[] FindByAtmicTag(...)

unity has for its own tags a list of all tagged objects and iterates through all of them, IIRC.

also make AtomicTags a ListComponent or something similar... maybe: static Dictionary<GameObject, AtomicTags> this could help further down below on HasTag


for the extension methods

they all scream inefficient. GetTags calls GetComponentTwice -> could cache it
(same for HasTag)

HasTag could become:

var tags = AtomicTags.GetForGameObject(go); // uses the static Dictionary<GameObject, AtomicTags>
return tags != null ? tags.Contains(str) : false; 

note: also overload hashCode from StringConstant to be equal to its Value member. maybe do it for all in the base class ScriptableVariable base, can't think of any drawback for now.

Equivalently GetTag could become:

var tags = AtomicTags.GetForGameObject(go);
return tags != null ? tags.GetTags() : new List<StringConstant>(0); 

Generator to create new Atoms (classes)

It would be really nice to have a generator that creates new atoms classes for you, to reduce the amount of boilerplate code to be written. It should be possible to choose what to generate (Variable, EventListener, Constant, etc), what to name it and what types to use.

Not sure what techniques to use. Have worked with Yeoman / EJS before, but not sure if it's a good fit for Unity / C# (is it possible to run from the inspector if it's a node module for example?). Maybe do some custom templating?

Create SceneConstant Atom

Summary

Something that would be useful for developers would be an Atom revolving around a SceneAsset. Ideally it does not keep a reference to a SceneAsset itself since it is an editor-only type, but instead serializes its full path and name only so that at runtime a user could load a scene using that serialized name or path value.

This would have a custom inspector/property drawer so that a user can assign a SceneAsset directly to the Atom or ping the currently referenced instance in the Project view, but would only assign its name and path to serialized fields.

The benefit of this versus a StringConstant or StringVariable is that this would offer a better UX and stronger validation of the values. There is a lack of validation that a general-purpose type offers that this more specific type could address. For example, the Atom itself could leverage OnValidate to assert that the name/path values should not be blank, custom methods to indicate that the name/path resolves to a valid scene in the build settings, and the custom inspector could also warn the user if the referenced SceneAsset was not in the build settings or asset bundle.

license

What is the license for this project?

Add Variables directly to Event Listeners

It's a bit annoying to have to create events all the time to be able to use the event listeners, so sometimes it would be nice to be able to set either a Variable or an Event to the listener (making the event be used in case it exists, or created on load in case it's not).

Build error 2019.1.5f1 - MonoScript, AssetPostprocessor could not be found; Canary branch

Hi, I got a problem with the build in Unity 2019.1.5f1 (platform doesn't matter; I tried both on Android build and Windows build).
More information in the screenshot. Is it possible to get a fix?

BTW: This is my first project with UnityAtoms and until now, it works really nice. It takes some time to get used to, some things could be better, but I really appreciate your repo. A great extension to Unity workflow. Thank you
Do you consider to enhance this repo with new features? Or show it on Unity forum (I haven't found anything related to that repo)?

unityatoms_error

Do you want us to create a Unity Atoms Slack / Discord / Spectrum channel?

Like stated above, would you like us to create a Slack, Spectrum or Discord (or something else) channel to be able to communicate more effectively? Please add a thumbs up (👍) to the option that you prefer below 👇

If you want something other then Slack, Spectrum or Discord create a new comment with that option.

[feature] Make usage of the package-manager

hey, i highly refactored the project in my fork: https://github.com/soraphis/unity-atoms/tree/stable

i made this to have the source files in the root directory, so i could add a package.json.

i updated the readme and added how to install it with the package-manager in unity 2018.3+
(more information about that can be found here and here )

i don't know if this is a way you wanna go with your tool / repository, thats why i have not created a pull request for this changes

IntListener (And maybe others) responses not passing through variable

I testing the library and using a Changed event on a FloatVariable, listening to it with a FloatListener in another GameObject and in the FloatListener calling a response to a function in the destination object/script that accepts a float. What I get in the inspector though is a field appearing under the script name and that value is the value passed through to my script, not the incoming value from the event.

Any idea what I'm doing wrong? I seems as though I've set everything up just like the Medium post and in the Medium post the listener response to HealthChanged doesn't have a field under it.

UNityAtomsProblem

Cheers
Aaron

[Discussion] Repository Cleanup

Just going through the files and folders, here are my thoughts:

Source/Base/CreateOnAwake

  • i don't get the use case of this classes. Can you make an example?

Sources/GameFunctions

  • i don't get the use case of this classes. Can you make an example?

Source/Logger

  • AtomsLogger.cs should be in Utils. there is no need for an own folder for that simple wrapper class.

Source/Utils

  • Vector2Utils.cs is never used

Source/Extensions

  • all but GameObjectExtension are unused
  • and if its only that one class, I'd move it to Utils.

Source/AtomicUI

  • UIContainers.cs
    • GetComponent calls should be cached
    • more important: this looks, as if it should be an own project UnityAtomsExtension where common used Components could be predefined. The class itself looks like a imho pretty uncommon use case. I wouldn't include it in the library.

Source/SceneManagement

  • same as above, looks for me like a special usecase. (most of the time you want to do way more than just load a scene (load it async, to show a progressbar; play a sound; load it additively; ...)

all GameEventListener's don't allow passing a dynamic parameters to callback

I encountered a problem that I can't pass dynamic value in the callback.
Fortunately, I found a cause and a solution.
To fix the issue require to modify GameEventListener file.
change this
[SerializeField] private UER UnityEventResponse = null;
to this
public UER UnityEventResponse = null;

Need to do this in both classes.
I think those two classes need to be refactored to extract a common code.

Variable transformers, eg. Clamp Value

For Variables, set a ShouldUpdate "hook" that you query before you update the value. Eg:
public bool SetValue(T value) { if (!AreEqual(this.value, value) && (ShouldUpdate == null || (ShouldUpdate != null && ShouldUpdate(T newValue, T currentValue, T oldValue)))) { // Set value } }
This makes it possible to add your custom logic to your variables, for example "clamp value" - to clamp the value between a min and a max. In this feature it is also included to create the "clamp value" hook.

[FEATURE] Set event name suggestion on Variable Changed event creation

Is would be really nice to have an automatically set up name for the event when creating a new event for a variable (could be fancy and try to understand what naming convention is being used or just force some naming convention such as appending " changed" or "_changed", or some middle ground such as a setting regex for it?)

This makes the process of creating new events for variables less repetitive (especially in the case mentioned in #66 )

Selecting Multiple Objects with a same type of event overrides all objects events with the same one

Describe the bug
If you create multiplie game objects with a common event listener type, selecting all of them makes the event they are listening to be the same as the last selected object (overriding each objects events)

To Reproduce

  1. Create 2 or more game objects with a same type of event listener (I used Int Listener), each with it's own event (IntEventA and IntEventB in my example)
    image
    image
  2. Select both game objects (note that the event field is actually populated with a value, IntEventB, when it should probably be '-', the symbol for different values)
    image
  3. Deselect the objects and note that all of them now are using the same event value (in my case, Game Object A is using IntEventB)
    image

Expected behavior
Selecting multiple objects should not cause any modifications at all in the game objects

Environment

  • OS: Windows 10
  • Unity Version 2019.1.13
  • Version of Unity Atoms v2.0.0

Generate Atoms of different types

Is your feature request related to a problem? Please describe.
Make it possible to generate Atoms of different type for:

  • Actions
  • Listeners
  • Functions
  • Events

Eg. generate a BoolIntEvent. This should be done in the Generator already available in Unity Atoms.

Describe the solution you'd like
This is not part of the regular Atoms generation currently implemented in Unity Atoms. I propose to create a new "page" in the Generator to generate "Multi Atoms" (I'm open for better naming here). The user will first pick what Atom to generate (selection box): Action, Listener, Function or Event. Then options to add types will appear.

Describe alternatives you've considered
Another consideration is to create a new Generator for this kind of generation.

I would be really appreciate someone making a PR on this. Make sure to read the guidelines before starting + assign yourself (or ask me) to the issue. Also don't hesitate to ask any further questions below before developing.

AtomicTags - Like Unity tags, but the Unity Atoms way

Add a MonoBehaviour called AtomicTags that takes a list of StringConstants. Also add some extension methods to GameObject so that we can check if a GameObject has an AtomicTag.

GameObjectExtensions API:

  • List GetTags()
  • bool HasTag(StringConstant)
  • bool HasTag(String)

Edited Manifestfile leads to issues

Hey there,

so I copy&paste the dependency as told in the readme into my manifest file like this

{
"dependencies": {
"com.unity.ads": "2.0.8",
"com.unity.analytics": "3.2.2",
"com.unity.collab-proxy": "1.2.15",
"com.unity.package-manager-ui": "2.0.3",
"com.unity.purchasing": "2.0.3",
"com.unity.textmeshpro": "1.3.0",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.assetbundle": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.cloth": "1.0.0",
"com.unity.modules.director": "1.0.0",
"com.unity.modules.imageconversion": "1.0.0",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0",
"com.unity.modules.physics": "1.0.0",
"com.unity.modules.physics2d": "1.0.0",
"com.unity.modules.screencapture": "1.0.0",
"com.unity.modules.terrain": "1.0.0",
"com.unity.modules.terrainphysics": "1.0.0",
"com.unity.modules.tilemap": "1.0.0",
"com.unity.modules.ui": "1.0.0",
"com.unity.modules.uielements": "1.0.0",
"com.unity.modules.umbra": "1.0.0",
"com.unity.modules.unityanalytics": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
"com.unity.modules.unitywebrequestaudio": "1.0.0",
"com.unity.modules.unitywebrequesttexture": "1.0.0",
"com.unity.modules.unitywebrequestwww": "1.0.0",
"com.unity.modules.vehicles": "1.0.0",
"com.mambojambostudios.unity-atoms": "https://github.com/AdamRamberg/unity-atoms.git",
"com.unity.modules.video": "1.0.0",
"com.unity.modules.vr": "1.0.0",
"com.unity.modules.wind": "1.0.0",
"com.unity.modules.xr": "1.0.0"
}
}

Then Unity throws an error:

An error occurred while resolving packages:
Project has invalid dependencies:
com.mambojambostudios.unity-atoms: No 'git' executable was found. Please install Git on your system and restart Unity

A re-import of the project may be required to fix the issue or a manual modification of E:/Behind The Stone/Game Development/Games/Experimenting/AtomsTesting/Packages/manifest.json file.

Don't know exactly what the problem is. Git is installed on my machine.
Any ideas?

Unity Atoms unable to find UnityEngine.UI

I'm using 2019.3.0a4 version

When I add atoms on package manager this i what I see on my console, any Idea of what could be happening?

[CompilerError] The type or namespace name 'UI' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Compiler Error at Library\PackageCache\com.mambojambostudios.unity-atoms@163a216\Source\MonoHooks\OnButtonClickHook.cs:2 column 19
1: using UnityEngine;
-->2: using UnityEngine.UI;
4: namespace UnityAtoms

[CompilerError] The type or namespace name 'EventSystems' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
Compiler Error at Library\PackageCache\com.mambojambostudios.unity-atoms@163a216\Source\MonoHooks\OnPointerDownHook.cs:2 column 19
1: using UnityEngine;
-->2: using UnityEngine.EventSystems;
4: namespace UnityAtoms

[CompilerError] The type or namespace name 'IPointerDownHandler' could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at Library\PackageCache\com.mambojambostudios.unity-atoms@163a216\Source\MonoHooks\OnPointerDownHook.cs:7 column 55
5: {
6: [AddComponentMenu("Unity Atoms/Hooks/On Pointer Down")]
-->7: public sealed class OnPointerDownHook : VoidHook, IPointerDownHandler
8: {
9: public void OnPointerDown(PointerEventData eventData)

[CompilerError] The type or namespace name 'PointerEventData' could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at Library\PackageCache\com.mambojambostudios.unity-atoms@163a216\Source\MonoHooks\OnPointerDownHook.cs:9 column 35
7: public sealed class OnPointerDownHook : VoidHook, IPointerDownHandler
8: {
-->9: public void OnPointerDown(PointerEventData eventData)
10: {
11: OnHook(new Void());

[CompilerError] The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)
Compiler Error at Library\PackageCache\com.mambojambostudios.unity-atoms@163a216\Source\MonoHooks\OnButtonClickHook.cs:7 column 30
5: {
6: [AddComponentMenu("Unity Atoms/Hooks/On Button Click")]
-->7: [RequireComponent(typeof(Button))]
8: public sealed class OnButtonClickHook : VoidHook
9: {

No boxing conversion from Color/Vector2/Vector3

Hey there,
I downloaded the 0.1 unitypackage in an empty project and got three errors after import:

Assets/UnityAtoms/Variables/ColorVariable.cs(6,34): error CS0315: The type UnityEngine.Color' cannot be used as type parameter T' in the generic type or method UnityAtoms.EquatableScriptableObjectVariable<T,E1,E2>'. There is no boxing conversion from UnityEngine.Color' to `System.IEquatable<UnityEngine.Color>'

Assets/UnityAtoms/Variables/Vector2Variable.cs(6,36): error CS0315: The type UnityEngine.Vector2' cannot be used as type parameter T' in the generic type or method UnityAtoms.EquatableScriptableObjectVariable<T,E1,E2>'. There is no boxing conversion from UnityEngine.Vector2' to `System.IEquatable<UnityEngine.Vector2>'

Assets/UnityAtoms/Variables/Vector3Variable.cs(6,36): error CS0315: The type UnityEngine.Vector3' cannot be used as type parameter T' in the generic type or method UnityAtoms.EquatableScriptableObjectVariable<T,E1,E2>'. There is no boxing conversion from UnityEngine.Vector3' to `System.IEquatable<UnityEngine.Vector3>'

Running on Windows 7, Unity version: 2017.4.15f1

Trigger GameEvents from the inspector

Create an editor script to make it possible to trigger GameEvents from the Unity Inspector. Probably best to create a generic class that gets extended for each GameEvent type.

"Name of new item" text box shows up for all Variables in a list

Description
If I have multiple unassignes Variables in a list (of serializable classes), when I click to create a new variable, the "Name of new item" text box shows up fot all unassigned variables in the list

Note: When you finally press create, this bug does not create a variable for all the objects, just the one you initially selected for creation, so the impact is very minor

To Reproduce
Steps to reproduce the behavior:

  1. Create a serializable class with a *Variable field
[Serializable]
public class ClassWithVariable 
{
  // [...]
  FloatVariable var;
  // [...]
}
  1. Create a List of that class in an MonoBehaviour
public class MonoBehaviourWithListOfClass : MonoBehaviour
{
  // [...]
  public List<ClassWithVariable> objectsWithVariables;
  // [...]
}
  1. Add that Behaviour to a game object, some objects to the list, and click on create for one of the variables.
  2. Notice that the text box for creating a new variable is showing up for all of the objects in the list

Expected behavior
The text box should show up only for the variable being created

Screenshots
image

Note that all the variables has "asdfa" with the checkbox and the x opened beside it

Environment

  • OS: Windows 10
  • Unity Version 2019.1.13
  • Version of Unity Atoms v2.0.0

[QUESTION] Demo Scene Missing Healthbar.HealthChanged

State your question below
In the demo scene. HealthListener is missing HealthBar.HealthChanged
However, when I "fix" it, I am now required to give a static value. And the health bar no longer works.

How is it setup to feed the HealthBar.HealthChanged a dynamic variable?

Add any additional information / background
Screen shot of the missing state https://snipboard.io/LWk0KG.jpg
Also the health bar needs to be assigned an source image, as its also missing

Add Where condition to Listeners, eg. call handlers every Nth time

I got a new small idea to add, I can make a pull request when two earlier issues will be resolved.
What do you think about adding two properties to GameEventListener and one mechanic:

  1. int every (default: 1)
  2. bool triggerFirst (default: false)
  3. some private int counter

We could trigger some UnityEvents/GameActions every few raised Event, not every once (like it's now). "triggerFirst" means if we set "every=5", will something be done on the first occurrence or not). Every raised event a counter will be increased to check how many times it triggered. It would add more flexibility to Listeners and it's a small change.

Initial value for variables

Wouldn't it be quite convenient if it had default variables that reset each time on OnEnable or somewhere else ? Or am I missing some design philosophy here ? :)

Unable to register event response for EventListeners

While attempting to register a function of a custom script as an event response for a VoidEvent I am not able to select a function. The function itself takes no variables, is public, and returns void.

Here is what I see when I try to register the custom script.
image

Two things to note.

  • Custom script derives from MonoBehaviour
  • I am using Unity for macOS

Clean up `[AddComponent]` and `[CreateAssetMenu]` usage

Summary

Making it easier for users to find and add the appropriate component or create the appropriate ScriptableObject derived unity-atom asset can make this library much easier for new users. There is some consistency with the context menu creation for SO assets, but I think some reorganization could help there as well. There is a bit more cleanup to do in order to get these AddComponent menus more organized.

image

As of the latest on canary, these seem to be mostly organized around the type they revolve around versus the type of thing they are. This can lead to making these menus less navigable for a user if there is growth of atoms revolving around a particular type.

For example, everything dealing with an GameObject value is organized for the context menu into a single scope including actions, events, variables, lists, etc... Right now as far as I can see there is only a single GameObject action of type GetUnusedGameObject, but presumably this list could grow to be very large as the number of actions/events revolving around GameObject(s) is subject to a lot of growth.

image

For both SO asset creation and AddComponent menus, I believe a more helpful structure would be to organize these into the type of thing they are versus what they revolve around or use. Instead of a structure looking like this:

  • Unity Atoms
    • Int
    • Vector3
    • GameObject
      • Variable
      • Event
      • List
      • GameObjectAction1
      • GameObjectAction2
      • GameObjectAction3
      • ...

you would have something that looked like this:

  • Unity Atoms
    • Variable
      • Int
      • Vector3
      • GameObject
    • List
    • Event
    • Conditional
    • Action
      • GameObject
        • GameObjectAction1
        • GameObjectAction2
        • GameObjectAction3

This is also more in-line with the UX for other popular game development tools like Bolt or PlayMaker and can lead to a more consistent development experience and quicker onboarding for new users.

image

image

image

Making these changes would not result in any breaking API changes for end-users as these affect the Unity Editor UX only and would be a general UX improvement with little downsides.

Not serialized in the inspector

Serialized fields do not show up in the inspector for some reason. At the moment, the only way to inspect and assign values is to activate debug mode.

Create events as delegates or actions

Is there any special reason behind the events having to implement an interface? Doesnt this even makes it weirder if you want to listen for 2 events of the same type in a single class?

No Int Int listener?

Was just trying to subscribe to an int int event in the editor but that listener doesnt seem to exist, is there a reason why I shouldnt have an int int listener? or is it just an oversight

External Dependencies in development branches

So, not sure about the best way to approach this, but I just added Unity-Atoms as a submodule in a different project I have and moved to the Canary branch. This made me unable to build the game because of a dependency on UniRx in one of the example folders. For now I basically deleted it, but if I ever make changes to the branch and want to submit a PR, it might prove itself a bit more annoying.

I think that when we use the project as a submodul (or just getting it from git directly) it should try to avoid external dependencies as much as it can (or could use other open source dependencies as submodules?)

This is more of a suggestion and trying to figure the best way to keep the examples in the package (since in that case it's easier to have external dependencies)
We could have the examples be in a different branch and do some continuous deployment to make sure the "package branch" has all the examples in it?

Name Listener Components based on Specified Event Name

Rename Game Listener components in the Inspector based on the specified event for which it is listening. Currently, if you have several Game Listener components on a scene object / prefab, you may have several listeners with the same generic name (e.g. Game Object Listener) and it makes it harder to find which listener you need in the Inspector.

Refactoring ScriptableObject / Monobehaviour class names

Not sure if this is related to Unity Atoms or if a solution to this problem should be part of Unity Atoms. Anyway, here we go..

It is really annoying that when you rename a MonoBehaviour / ScriptableObject (when using Unity Atoms for example a Game Function or a Game Action) class the reference gets lost and you might need to rewire everything in the editor that used that class. From my understanding Unity is using fileID + a generated guid to reference something hooked up in the editor (or in an asset file). I have also heard that the guid is based on the class name + namespace. So if it is possible to get the generated guid (or if there is an API where you pass class name + namespace), then it would be possible to create a rename script that renames the class + change all the guids in all meta / scene / asset files. The script might be added to the Unity editor or it might be a IDE extension (for example VS Code). Many assumptions here, but if it is possible it would be a great feature.

SetValue action but with Variable's InitialValue

Is it possible to achieve something like:
I got FloatVariable called "MovementSpeed", where Initial value is "4.4", Value is changing during a game, but Initial is constant, I restart a level and want to reset MovementSpeed to its Initial value 4,4.
In other words:
I want to reset Variable (Float/Int etc.) to its initial value when a scene is loaded/level started. I can use a pattern like in demos&examples with GameObject "OnLevelStart", hook, and SetVariable in Listener for every Variable, but...
In SetVariable we have to set what the value is, like "100", "5" (a number) or could use another Variable, but we don't have any mechanism to Reset a Variable to its initial value. I can't imagine, that I make MovementSpeed with Initial value 4.4, and SetVariable to reset to 4,4, because when in some moment designer will think that InitialValue for Variable would be 5, I have to also remember that I need to change SetVariable to 5 in OnLevelStart. It would be messy.

I got 2 ideas to solve this problem:

  1. Make a generic SetVariableInitial action, we got a reference to the Variable to reset, but we cannot specify what value will be set... just because we want its initial, not hand-written value. So it will be the same like SetVariable but without value to set field.
  2. Make some GameAction where we can store a List of Variables to reset to initialValue and a method with doing that job. We can use a Hook OnStart, Void Listener and use this GameAction on callback.

Are there any other better options to solve that problem? Maybe something is already implemented but I miss that?

What changes might cause this missing dynamic method?

Hi Adam,

Every now and then my event listeners are breaking and I'm unable to setup using dynamic values. Previous dynamic listeners continue to work but the inspector shows the following:

image

The missing Actor.TargetAllAbilities is still present on the game object. Like I say it continues to work too but that might just be because it's not doing a clean build.

Any ideas? I've raised it as a question rather than a bug due to the fact I'm pretty new to Atoms and relatively new to Unity as a whole - so it might just be me being stupid!

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.