diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c9bbfa2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,17 @@ +# editorconfig.org + +# top-most EditorConfig file +root = true + +# Default settings: +# A newline ending every file +# Use 4 spaces as indentation +[*] +insert_final_newline = true +indent_style = space + +# Unity scripts +[Assets/**/*.cs] +charset = utf-8 +end_of_line = lf +indent_size = 4 diff --git a/.github/workflows/publish-upm-package.yml b/.github/workflows/publish-upm-package.yml new file mode 100644 index 0000000..c5ba031 --- /dev/null +++ b/.github/workflows/publish-upm-package.yml @@ -0,0 +1,17 @@ +name: Publish UPM Package + +on: + release: + types: [published] + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: monry/actions-upm-publish@v1 + with: + npm_registry_url: ${{ secrets.NPM_REGISTRY_URL }} + npm_auth_token: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/.gitignore b/.gitignore index 32bfc8e..9ed4641 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,7 @@ sysinfo.txt # Crashlytics generated file crashlytics-build.properties + +# PlayMode Test generated file +Assets/InitTestScene*.unity +Assets/InitTestScene*.unity.meta diff --git a/Assets/CHANGELOG.md b/Assets/CHANGELOG.md index 40ca861..8d6e00f 100644 --- a/Assets/CHANGELOG.md +++ b/Assets/CHANGELOG.md @@ -1,9 +1,297 @@ # Changelog -## [1.0.0] - YYYY-MM-DD +## [0.1.0-preview.45] - 2021-01-21 -* Initial version +Reference UniRx on GitHub instead of Self-hosted registry + +### Changes + +- Reference UniRx on GitHub instead of Self-hosted registry + +## [0.1.0-preview.44] - 2020-11-18 + +Add CurrentRuntimePlatformProvider + +### Features + +- #221 Add CurrentRuntimePlatformProvider / Thanks @milkcocoa !! + +## [0.1.0-preview.43] - 2020-10-06 + +Fix upm dependencies + +### Fixes + +- #219 Fix Zenject dependencies + +## [0.1.0-preview.24] - 2019-10-04 + +### Implementations + +* Add `ObservableReceiver` to receive as `IObservable` + +### Fixes + +* Fixed an issue that sometimes caused timeline event preparation to fail +* Corrected the field to be used + +## [0.1.0-preview.23] - 2019-10-03 + +### Breaking Changes + +* Revert timing of preparing to `Start()` instead of `Awake()` + * Avoid running in non-active components + +### Fixes + +* Fix messaging about SimpleAnimation + +### Tests + +* Add tests for SimpleAnimation + +## [0.1.0-preview.22] - 2019-10-02 + +### Breaking Changes + +* Send `UniRx.Unit` into connecting flows instead of `Message` to omit data messaging + +### Implementations + +* Implement ValueExtractor +* Implement ValueCombiner + +### Improvements + +* Display current flow progress in UniFlow Graph +* Support connect ValueProviders in UniFlow Graph + +## [0.1.0-preview.21] - 2019-09-20 + +### Implementations + +* Implement ValueComparer +* Implement ValueProvider + +### Fixes + +* Fix observable + * Split message correctly + * Send `ObservableReceiverBase` message correctly +* Fix GraphView + +## [0.1.0-preview.20] - 2019-09-17 + +### Changes + +* Change timing of preparing to `Awake()` instead of `Start()` + +### Fixes + +* Fix some bugs in GraphView +* Change method interface to send latest message correctly + +## [0.1.0-preview.19] - 2019-09-16 + +### Implementations + +* Add `Toss` and `Receive` connector to split graph + +### Destructive Changes + +* Pass previous message to `IConnector.OnConnectAsObservable()` + +### Fixes + +* `SimpleAnimationEvent`: Waiting animation correctly + +## [0.1.0-preview.18] - 2019-09-10 + +Fix editor bug + +### Fixes + +* Set TargetComponents correctly when connect from search window + +## [0.1.0-preview.17] - 2019-09-09 + +Fix undo + +### Fixes + +* Register GameObject creation event to undo stack + +## [0.1.0-preview.16] - 2019-09-09 + +Fix error in FlowGraph + +### Fixes + +* Fix NullReferenceException in FlowGraph +* Support to render `List` + +## [0.1.0-preview.15] - 2019-09-06 + +Fix build issue + +### Fixes + +* Avoid compile error on build + +## [0.1.0-preview.14] - 2019-09-02 + +None + +## [0.1.0-preview.13] - 2019-09-02 + +Tweak + +### Changes + +* Rename connectables + +### Fixes + +* Omit shared components +* Fix `IObservable.Subscribe()` + +## [0.1.0-preview.12] - 2019-09-02 + +Tweak + +### Fixes + +* Remove debug code + * Remove shortcut key +* Update README.md + +## [0.1.0-preview.11] - 2019-09-02 + +Implement UniFlow Graph + +### Features + +* UniFlow Graph + * Display connectables in Graph View + * Edit connectables +* Add `IObservableReceiver` + +### Fixes + +* SimpleAnimationEvent has been destroyed but still trying to access + +## [0.1.0-preview.10] - 2019-08-22 + +Tweak + +### Changes + +* Change some enum default values to unselected + +## [0.1.0-preview.9] - 2019-08-22 + +Add connectors + +### Features + +* Add connectors + * MoveParentTransform + * RaycastTargetController + * SimpleAnimationEvent + +### Improvements + +* Added Connector to load/unload scenes using `enum` values + +### Fixes + +* Fixed an issue where GameObject to which SimpleAnimation was attached was incorrect + +## [0.1.0-preview.8] - 2019-08-20 + +Improve inspector + +### Improvements + +* Remove `ActAsReceiver` parameter from Connector components + +### Fixes + +* Fixed regression where some SerializeFields disappeared + +## [0.1.0-preview.7] - 2019-08-19 + +Implement `TimeScaleController`, `KeyEvent` + +### Features + +* Add `Connector.TimeScaleController` +* Add `Connector.KeyEvent` +* Add `Receiver.Log` +* Add `ObservableReceiverBase` + +### Improvements + +* Make accessor to public + +## [0.1.0-preview.6] - 2019-08-11 + +Add Components automatically + +### Features + +* Add components required by some connectors automatically + +### Improvements + +* Refactor codes + +## [0.0.4-preview.5] - 2019-08-06 + +Refactor code + +### Features + +* Add Interval event + +### Improvements + +* Refactor codes +* Reverses reference direction between Publishers + +## [0.0.3-preview.4] - 2019-08-06 + +Fix minor bugs + +### Fixes + +* Avoid `CS0649` warning +* Fix version conflicts in UniRx + +## [0.0.2-preview.3] - 2019-08-06 + +Support many events + +### Features + +* Support Lifecycle events +* Support Physics/Physics2D events +* Support Camera, Transform, RectTransform events +* Support Audio events + +### Improvements + +* Connect events correctly +* Refresh EventMessages on re-invoke event + +### Supports + +* Supported Unity version bumped up to 2019.2 + +## [0.0.1] - 2019-07-21 + +Initial version ### Features -* +* Implements simple events diff --git a/Assets/Editor.meta b/Assets/Editor.meta new file mode 100644 index 0000000..fb4c557 --- /dev/null +++ b/Assets/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07aa457ae04af4b98bce42409533883b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/AssetReferences.asset b/Assets/Editor/AssetReferences.asset new file mode 100644 index 0000000..342b877 --- /dev/null +++ b/Assets/Editor/AssetReferences.asset @@ -0,0 +1,20 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 862eccc6c6b74070a43ca9ba61c41d8d, type: 3} + m_Name: AssetReferences + m_EditorClassIdentifier: + flowVisualElement: {fileID: 7433441132597879392, guid: e5cd5853b6b74e9eab84a4e05492245e, + type: 3} + flowGraphView: {fileID: 7433441132597879392, guid: 2d1bfda56f80479a9954af9e73517286, + type: 3} + flowNode: {fileID: 7433441132597879392, guid: 9966dde7671f4ac2b46777545308ca19, + type: 3} diff --git a/Assets/Editor/AssetReferences.asset.meta b/Assets/Editor/AssetReferences.asset.meta new file mode 100644 index 0000000..6280858 --- /dev/null +++ b/Assets/Editor/AssetReferences.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 605e150d339d14b64b0f12478f2b60c6 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts.meta b/Assets/Editor/Scripts.meta new file mode 100644 index 0000000..1720458 --- /dev/null +++ b/Assets/Editor/Scripts.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a288908b1da674ce6bab525764a9a873 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts/AssetReferences.cs b/Assets/Editor/Scripts/AssetReferences.cs new file mode 100644 index 0000000..842ed78 --- /dev/null +++ b/Assets/Editor/Scripts/AssetReferences.cs @@ -0,0 +1,36 @@ +using System.Linq; +using UnityEditor; +using UnityEngine; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + [CreateAssetMenu(menuName = "UniFlow/Editor AssetReferences", fileName = "AssetReferences.asset")] + public class AssetReferences : ScriptableObject + { + [SerializeField] private StyleSheet flowVisualElement = default; + [SerializeField] private StyleSheet flowGraphView = default; + [SerializeField] private StyleSheet flowNode = default; + + public StyleSheet FlowVisualElement => flowVisualElement; + public StyleSheet FlowGraphView => flowGraphView; + public StyleSheet FlowNode => flowNode; + + private static AssetReferences instance = default; + public static AssetReferences Instance => instance ? instance : instance = Load(); + + public static void Reload() + { + instance = Load(); + } + + private static AssetReferences Load() + { + return AssetDatabase + .FindAssets("t:UniFlow.Editor.AssetReferences") + .Select(AssetDatabase.GUIDToAssetPath) + .Select(AssetDatabase.LoadAssetAtPath) + .FirstOrDefault(); + } + } +} \ No newline at end of file diff --git a/Assets/Editor/Scripts/AssetReferences.cs.meta b/Assets/Editor/Scripts/AssetReferences.cs.meta new file mode 100644 index 0000000..df303a5 --- /dev/null +++ b/Assets/Editor/Scripts/AssetReferences.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 862eccc6c6b74070a43ca9ba61c41d8d +timeCreated: 1566486612 \ No newline at end of file diff --git a/Assets/Editor/Scripts/ConnectorInfo.cs b/Assets/Editor/Scripts/ConnectorInfo.cs new file mode 100644 index 0000000..e8496ac --- /dev/null +++ b/Assets/Editor/Scripts/ConnectorInfo.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow.Editor +{ + [Serializable] + public class ConnectorInfo + { + private ConnectorInfo( + GameObject gameObject, + IConnector connector, + Type type, + string name, + IEnumerable parameters, + IEnumerable composableMessageAnnotations, + IEnumerable collectableMessageAnnotations + ) + { + GameObject = gameObject; + Connector = connector; + Type = type; + Name = name; + parameterList = parameters.ToList(); + ComposableMessageAnnotations = composableMessageAnnotations; + CollectableMessageAnnotations = collectableMessageAnnotations; + } + + public GameObject GameObject { get; set; } + public IConnector Connector { get; set; } + public Type Type { get; } + public string Name { get; } + [SerializeField] private List parameterList = default; + public IEnumerable ParameterList => parameterList; + public IEnumerable ComposableMessageAnnotations { get; private set; } + public IEnumerable CollectableMessageAnnotations { get; private set; } + + public void ApplyParameter(Parameter parameter) + { + if (Connector == default) + { + return; + } + + GetFieldRecursive(Type, parameter.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)? + .SetValue(Connector, parameter.Value); + } + + public void ReCalculateAnnotations() + { + if (Connector == default) + { + return; + } + + ComposableMessageAnnotations = typeof(IMessageComposable).IsAssignableFrom(Type) + ? ((IMessageComposable) Connector).GetMessageComposableAnnotations() + : new IComposableMessageAnnotation[0]; + CollectableMessageAnnotations = typeof(IMessageCollectable).IsAssignableFrom(Type) + ? ((IMessageCollectable) Connector).GetMessageCollectableAnnotations() + : new ICollectableMessageAnnotation[0]; + } + + private static FieldInfo GetFieldRecursive(Type type, string name, BindingFlags bindingFlags) + { + do + { + var fieldInfo = type.GetField(name, bindingFlags); + if (fieldInfo != default) + { + return fieldInfo; + } + + if (type.BaseType == default) + { + break; + } + + type = type.BaseType; + } while (true); + return default; + } + + public void ApplyParameters() + { + if (Connector == default) + { + return; + } + + ParameterList.ToList().ForEach(ApplyParameter); + } + + [PublicAPI] + public static ConnectorInfo Create(IConnector instance) + { + return Create(instance.GetType(), instance); + } + + [PublicAPI] + public static ConnectorInfo Create(Type type, IConnector instance) + { + return Create( + ((Component) instance)?.gameObject, + instance, + type, + type.Name, + type.GetFieldsRecursive(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) + .Where(x => (x.GetCustomAttribute() != null || x.IsPublic) && x.GetCustomAttribute() == null) + .Select(x => Parameter.Create(x.FieldType, x.Name, instance != default ? x.GetValue(instance) : default)), + typeof(IMessageComposable).IsAssignableFrom(type) && instance != null + ? ((IMessageComposable) instance).GetMessageComposableAnnotations() + : new IComposableMessageAnnotation[0], + typeof(IMessageCollectable).IsAssignableFrom(type) && instance != null + ? ((IMessageCollectable) instance).GetMessageCollectableAnnotations() + : new ICollectableMessageAnnotation[0] + ); + } + + [PublicAPI] + public static ConnectorInfo Create( + GameObject gameObject, + IConnector instance, + Type type, + string name, + IEnumerable parameters, + IEnumerable composableMessageAnnotations, + IEnumerable collectableMessageAnnotations + ) + { + return new ConnectorInfo(gameObject, instance, type, name, parameters, composableMessageAnnotations, collectableMessageAnnotations); + } + + [Serializable] + public class Parameter + { + private Parameter(Type type, string name, object value) + { + Type = type; + Name = name; + Value = value; + } + + [SerializeField] private object value = default; + + public Type Type { get; } + public string Name { get; } + public object Value + { + get => value; + set => this.value = value; + } + + public static Parameter Create(Type type, string name, object value) + { + return new Parameter(type, name, value); + } + } + } +} diff --git a/Assets/Editor/Scripts/ConnectorInfo.cs.meta b/Assets/Editor/Scripts/ConnectorInfo.cs.meta new file mode 100644 index 0000000..d2159a1 --- /dev/null +++ b/Assets/Editor/Scripts/ConnectorInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 832d12247ef4b47eab684af7034e3c6c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts/EdgeConnectorListener.cs b/Assets/Editor/Scripts/EdgeConnectorListener.cs new file mode 100644 index 0000000..373e80a --- /dev/null +++ b/Assets/Editor/Scripts/EdgeConnectorListener.cs @@ -0,0 +1,34 @@ +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace UniFlow.Editor +{ + public class EdgeConnectorListener : IEdgeConnectorListener + { + public EdgeConnectorListener(FlowGraphView flowGraphView, SearchWindowProvider searchWindowProvider) + { + FlowGraphView = flowGraphView; + SearchWindowProvider = searchWindowProvider; + } + + private FlowGraphView FlowGraphView { get; } + private SearchWindowProvider SearchWindowProvider { get; } + + void IEdgeConnectorListener.OnDropOutsidePort(Edge edge, Vector2 position) + { + SearchWindowProvider.FlowPort = (FlowPort) (edge.output?.edgeConnector.edgeDragHelper.draggedPort ?? edge.input?.edgeConnector.edgeDragHelper.draggedPort); + SearchWindow + .Open( + new SearchWindowContext(GUIUtility.GUIToScreenPoint(Event.current.mousePosition)), + SearchWindowProvider + ); + } + + void IEdgeConnectorListener.OnDrop(GraphView graphView, Edge edge) + { + FlowGraphView.AddEdge((FlowPort) edge.output, (FlowPort) edge.input); + (edge.output.node as FlowNode)?.ApplyTargetConnectors(); + FlowGraphView.SetupActAsTrigger(); + } + } +} diff --git a/Assets/Editor/Scripts/EdgeConnectorListener.cs.meta b/Assets/Editor/Scripts/EdgeConnectorListener.cs.meta new file mode 100644 index 0000000..e45bb9d --- /dev/null +++ b/Assets/Editor/Scripts/EdgeConnectorListener.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 783a4a0e2caa408aaa72e9d89f41d3a0 +timeCreated: 1566893817 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowEdge.cs b/Assets/Editor/Scripts/FlowEdge.cs new file mode 100644 index 0000000..e02310a --- /dev/null +++ b/Assets/Editor/Scripts/FlowEdge.cs @@ -0,0 +1,36 @@ +using UnityEditor.Experimental.GraphView; + +namespace UniFlow.Editor +{ + public class FlowEdge : Edge, IRemovableElement + { + void IRemovableElement.RemoveFromGraphView() + { + output.Disconnect(this); + input.Disconnect(this); + + if (!(output?.node is FlowNode outputNode)) + { + return; + } + + switch (output) + { + case FlowPort _: + outputNode.ApplyTargetConnectors(); + break; + } + + switch (input) + { + case FlowMessageCollectPort messageCollectPort: + messageCollectPort.CollectableMessageAnnotation.ValueCollector.SourceConnector = default; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.TargetConnector = default; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.TypeString = default; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.CollectorKey = default; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.ComposerKey = default; + break; + } + } + } +} diff --git a/Assets/Editor/Scripts/FlowEdge.cs.meta b/Assets/Editor/Scripts/FlowEdge.cs.meta new file mode 100644 index 0000000..7c45f51 --- /dev/null +++ b/Assets/Editor/Scripts/FlowEdge.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2115b911c6054dcaa5f8c8351b295822 +timeCreated: 1566529312 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowEditorWindow.cs b/Assets/Editor/Scripts/FlowEditorWindow.cs new file mode 100644 index 0000000..5cc3294 --- /dev/null +++ b/Assets/Editor/Scripts/FlowEditorWindow.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using JetBrains.Annotations; +using UnityEditor; +using UnityEngine; + +namespace UniFlow.Editor +{ + internal class UniFlowSettings : ScriptableSingleton + { + [SerializeField] private Vector3 latestPosition = Vector3.zero; + [SerializeField] private Vector3 latestScale = Vector3.one; + + internal Vector3 LatestPosition + { + get => latestPosition; + set => latestPosition = value; + } + internal Vector3 LatestScale + { + get => latestScale; + set => latestScale = value; + } + internal bool IsPrefabMode => SelectedGameObject != default && !SelectedGameObject.scene.IsValid(); + internal GameObject SelectedGameObject { get; set; } = null; + } + + public class FlowEditorWindow : EditorWindow + { + internal static FlowEditorWindow Window { get; private set; } = default; + + internal FlowGraphView FlowGraphView { get; private set; } + + [SerializeField] private List connectableInfoList = new List(); + [SerializeField] [UsedImplicitly] private int counter = default; + + public IList ConnectableInfoList => connectableInfoList; + + [MenuItem("Window/UniFlow/Open UniFlow Graph")] + public static void Open() + { + GetWindow(); + Window.titleContent = new GUIContent("UniFlow Graph"); + } + + public void ForceRegisterUndo() + { + counter++; + } + + private void Reload() + { + AssetReferences.Reload(); + + rootVisualElement.Clear(); + connectableInfoList = new List(); + var flowVisualElement = new FlowVisualElement + { + name = typeof(FlowVisualElement).Name, + }; + flowVisualElement.Initialize(); + rootVisualElement.Add(flowVisualElement); + FlowGraphView = flowVisualElement.FlowGraphView; + + Repaint(); + } + + private void OnPlayModeStateChanged(PlayModeStateChange playModeStateChange) + { + switch (playModeStateChange) + { + case PlayModeStateChange.EnteredEditMode: + Reload(); + break; + case PlayModeStateChange.ExitingEditMode: + break; + case PlayModeStateChange.EnteredPlayMode: + Reload(); + break; + case PlayModeStateChange.ExitingPlayMode: + break; + default: + throw new ArgumentOutOfRangeException(nameof(playModeStateChange), playModeStateChange, null); + } + } + + private void OnEnable() + { + Window = this; + Undo.undoRedoPerformed += Reload; + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; + Reload(); + } + + [SuppressMessage("ReSharper", "DelegateSubtraction")] + private void OnDisable() + { + Undo.undoRedoPerformed -= Reload; + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; + } + + private void OnDestroy() + { + Window = null; + } + } +} diff --git a/Assets/Editor/Scripts/FlowEditorWindow.cs.meta b/Assets/Editor/Scripts/FlowEditorWindow.cs.meta new file mode 100644 index 0000000..67c9a9b --- /dev/null +++ b/Assets/Editor/Scripts/FlowEditorWindow.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8991e32e603d4ef99dba136dde08bc1d +timeCreated: 1566479887 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowGraphView.cs b/Assets/Editor/Scripts/FlowGraphView.cs new file mode 100644 index 0000000..1bbfe6f --- /dev/null +++ b/Assets/Editor/Scripts/FlowGraphView.cs @@ -0,0 +1,428 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEngine; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + public class FlowGraphView : GraphView + { + private IList Connectors { get; set; } = new List(); + private IDictionary> DestinationConnectors { get; } = new Dictionary>(); + private IDictionary> SourceConnectors { get; } = new Dictionary>(); + private IDictionary RenderedNodes { get; } = new Dictionary(); + private IDictionary NormalizedPositionDictionary { get; } = new Dictionary(); + private SearchWindowProvider SearchWindowProvider { get; set; } + private EdgeConnectorListener EdgeConnectorListener { get; set; } + private MessageConnectorListener MessageConnectorListener { get; set; } + + private const float NodeWidth = 300.0f; + private static Vector2 NodesOffset { get; } = new Vector2(50.0f, 50.0f); + private static Vector2 NodeMargin { get; } = new Vector2(50.0f, 50.0f); + + public void Initialize() + { + UpdateViewTransform(UniFlowSettings.instance.LatestPosition, UniFlowSettings.instance.LatestScale); + styleSheets.Add(AssetReferences.Instance.FlowGraphView); + SetupZoom(0.05f, ContentZoomer.DefaultMaxScale); + this.AddManipulator(new ContentDragger()); + this.AddManipulator(new SelectionDragger()); + this.AddManipulator(new RectangleSelector()); + this.AddManipulator(new ClickSelector()); + + var flowGridBackground = new FlowGridBackground + { + name = typeof(FlowGridBackground).Name, + }; + Insert(0, flowGridBackground); + + SearchWindowProvider = ScriptableObject.CreateInstance(); + SearchWindowProvider.Initialize(this); + EdgeConnectorListener = new EdgeConnectorListener(this, SearchWindowProvider); + MessageConnectorListener = new MessageConnectorListener(this); + + viewTransformChanged += graphView => + { + UniFlowSettings.instance.LatestPosition = graphView.viewTransform.position; + UniFlowSettings.instance.LatestScale = graphView.viewTransform.scale; + }; + + nodeCreationRequest += context => + { + SearchWindowProvider.FlowPort = null; + SearchWindow + .Open( + new SearchWindowContext(context.screenMousePosition), + SearchWindowProvider + ); + }; + + deleteSelection += (operationName, user) => + { + DeleteSelection(); + SetupActAsTrigger(); + }; + + elementsRemovedFromStackNode += (stackNode, removedGraphElements) => + { + removedGraphElements.ToList().ForEach(Debug.Log); + SetupActAsTrigger(); + }; + elementsRemovedFromGroup += (group, removedGraphElements) => + { + removedGraphElements.ToList().ForEach(Debug.Log); + SetupActAsTrigger(); + }; + + graphViewChanged += change => + { + change + .elementsToRemove? + .OfType() + .ToList() + .ForEach( + x => x.RemoveFromGraphView() + ); + SetupActAsTrigger(); + return change; + }; + + CreateNodesFromInstance(); + + CreateEdges(); + + CreateMessageConnectorEdges(); + + RegisterCallback( + (GeometryChangedEvent e) => + { + Relocation(); + } + ); + RegisterCallback( + (KeyDownEvent e) => + { + // ReSharper disable once SwitchStatementMissingSomeCases + switch (e.keyCode) + { + case KeyCode.C: + SearchWindowProvider.FlowPort = null; + SearchWindow + .Open( + new SearchWindowContext(GUIUtility.GUIToScreenPoint(layout.position) + new Vector2(125.0f, 55.0f)), + SearchWindowProvider + ); + break; + } + } + ); + } + + public void Relocation(bool forceReset = false) + { + var nextYList = new List(); + + var groupId = Undo.GetCurrentGroup(); + + if (!NormalizedPositionDictionary.Any()) + { + return; + } + + var maxX = NormalizedPositionDictionary.Max(x => x.Value.x); + for (var i = 0; i <= maxX; i++) + { + nextYList.Add(0.0f); + } + + foreach (var pair in NormalizedPositionDictionary) + { + var node = pair.Key; + var normalizedPosition = pair.Value; + + if (!forceReset && node.GetRecordedPosition().magnitude > 0.0f) + { + node.SetPosition(new Rect(node.GetRecordedPosition(), node.layout.size)); + } + else + { + node.SetPosition( + new Rect( + new Vector2(normalizedPosition.x * (NodeWidth + NodeMargin.x) + NodesOffset.x, nextYList[normalizedPosition.x] + NodesOffset.y), + node.layout.size + ) + ); + node.ApplyPosition(); + } + + nextYList[normalizedPosition.x] += node.layout.height + NodeMargin.y; + } + + Undo.CollapseUndoOperations(groupId); + } + + public void CollectConnectorsForSearchTree() + { + SearchWindowProvider.CalculateSearchTree(); + } + + internal Vector2 NormalizeMousePosition(Vector2 mousePosition) + { + return contentViewContainer + .WorldToLocal( + FlowEditorWindow + .Window + .rootVisualElement + .ChangeCoordinatesTo( + FlowEditorWindow.Window.rootVisualElement.parent, + mousePosition - FlowEditorWindow.Window.position.position + ) + ); + } + + internal void SetupActAsTrigger() + { + this.Query() + .Children() + .Where(x => x.ConnectorInfo.Connector is ConnectorBase) + .ForEach(x => ((ConnectorBase) x.ConnectorInfo.Connector).ActAsTrigger = (x.InputPort.connections == null || !x.InputPort.connections.Any())); + } + + private IEnumerable CollectConnectors() + { + if (UniFlowSettings.instance.IsPrefabMode) + { + return UniFlowSettings.instance.SelectedGameObject + .GetComponentsInChildren(true); + } + + if (UniFlowSettings.instance.SelectedGameObject != null) + { + return UniFlowSettings.instance + .SelectedGameObject + .scene + .GetRootGameObjects() + .SelectMany(x => x.GetComponentsInChildren(true)); + } + + return new IConnector[0]; + } + + private void CreateNodesFromInstance() + { + Connectors = CollectConnectors().ToList(); + + foreach (var connector in Connectors) + { + if (!DestinationConnectors.ContainsKey(connector)) + { + DestinationConnectors[connector] = new List(); + } + + if (connector is ConnectorBase connectorBase) + { + foreach (var targetConnector in connectorBase.TargetComponents) + { + if (targetConnector == default) + { + continue; + } + + if (!SourceConnectors.ContainsKey(targetConnector)) + { + SourceConnectors[targetConnector] = new List(); + } + + DestinationConnectors[connectorBase].Add(targetConnector); + SourceConnectors[targetConnector].Add(connectorBase); + } + } + } + + var rootConnectables = Connectors.Where(x => !SourceConnectors.ContainsKey(x)).ToArray(); + if (!rootConnectables.Any() && Connectors.Any()) + { + rootConnectables = new[] {Connectors.First()}; + } + + if (UniFlowSettings.instance.SelectedGameObject != default && !UniFlowSettings.instance.IsPrefabMode) + { + rootConnectables = rootConnectables.Where(x => x is ConnectorBase connector && connector != default && ContainsSelectedGameObjectInConnectableTree(connector)).ToArray(); + } + + foreach (var (rootConnectable, index) in rootConnectables.Select((v, i) => (v, i))) + { + CreateNodeRecursive(rootConnectable, new Vector2Int(0, index)); + } + } + + private static bool ContainsSelectedGameObjectInConnectableTree(ConnectorBase haystack) + { + if (haystack.gameObject == UniFlowSettings.instance.SelectedGameObject) + { + return true; + } + + return haystack + .TargetComponents + .Where(x => x != default) + .Any( + x => + x.gameObject == UniFlowSettings.instance.SelectedGameObject + || x is ConnectorBase child && child != default && ContainsSelectedGameObjectInConnectableTree(child) + ); + } + + private void CreateNodeRecursive(IConnector connectable, Vector2Int normalizedPosition) + { + var node = AddNode(connectable.GetType(), connectable, Vector2.zero); + NormalizedPositionDictionary[node] = normalizedPosition; + RenderedNodes[connectable] = node; + + // ReSharper disable once InvertIf + if (DestinationConnectors.ContainsKey(connectable)) + { + foreach (var (targetConnectable, index) in DestinationConnectors[connectable].Select((v, i) => (v, i))) + { + if (!RenderedNodes.ContainsKey(targetConnectable)) + { + CreateNodeRecursive(targetConnectable, new Vector2Int(normalizedPosition.x + 1, normalizedPosition.y + index)); + } + else if (NormalizedPositionDictionary[RenderedNodes[targetConnectable]].x < normalizedPosition.x + 1) + { + NormalizedPositionDictionary[RenderedNodes[targetConnectable]] = new Vector2Int(normalizedPosition.x + 1, normalizedPosition.y + index); + } + } + } + } + + private void CreateEdges() + { + foreach (var (sourceConnector, targetConnectors) in DestinationConnectors.Select(x => (x.Key, x.Value))) + { + foreach (var targetConnector in targetConnectors) + { + if (!RenderedNodes.ContainsKey(sourceConnector) || !RenderedNodes.ContainsKey(targetConnector)) + { + continue; + } + + AddEdge((FlowPort) RenderedNodes[sourceConnector].OutputPort, (FlowPort) RenderedNodes[targetConnector].InputPort); + } + } + } + + private void CreateMessageConnectorEdges() + { + foreach (var connector in Connectors) + { + var valueCollectors = connector.GetType() + .GetPropertiesRecursive(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy) + .Where(x => typeof(IValueCollector).IsAssignableFrom(x.PropertyType)) + .Select(x => x.GetMethod.Invoke(connector, null) as IValueCollector) + .ToArray(); + foreach (var valueCollector in valueCollectors) + { + if (!(valueCollector?.SourceConnector is IMessageComposable) || !RenderedNodes.ContainsKey(connector) || !RenderedNodes.ContainsKey(valueCollector.SourceConnector) || !(connector is IMessageCollectable)) + { + continue; + } + + var messageComposeNode = RenderedNodes[valueCollector.SourceConnector]; + var messageCollectNode = RenderedNodes[connector]; + var messageComposePort = messageComposeNode + .MessageComposePorts + .FirstOrDefault( + x => + x.ComposableMessageAnnotation.Key == valueCollector.ComposerKey +// && x.ComposableMessageAnnotation.Type.AssemblyQualifiedName == valueCollector.TypeString + ); + var messageCollectPort = messageCollectNode + .MessageCollectPorts + .FirstOrDefault( + x => + x.CollectableMessageAnnotation.Key == valueCollector.CollectorKey +// && x.CollectableMessageAnnotation.Type.AssemblyQualifiedName == valueCollector.TypeString + ); + if (messageComposePort != null && messageCollectPort != null) + { + AddEdge(messageComposePort, messageCollectPort); + } + } + } + } + + public FlowNode AddNode(Type connectableType, IConnector connectableInstance, Vector2 position) + { + var connectableInfo = ConnectorInfo.Create(connectableType, connectableInstance); + FlowEditorWindow.Window.ConnectableInfoList.Add(connectableInfo); + var node = new FlowNode(connectableInfo, EdgeConnectorListener, MessageConnectorListener); + node.Initialize(); + node.SetPosition(new Rect(position.x, position.y, 0, 0)); + AddElement(node); + return node; + } + + public FlowEdge AddEdge(Port outputPort, Port inputPort) + { + var edge = new FlowEdge + { + output = outputPort, + input = inputPort, + }; + edge.output.Connect(edge); + edge.input.Connect(edge); + AddElement(edge); + return edge; + } + + public override List GetCompatiblePorts(Port startPort, NodeAdapter nodeAdapter) + { + switch (startPort) + { + case FlowMessageComposePort startFlowMessageComposePort: + return ports + .ToList() + .Where( + x => + x is FlowMessageCollectPort flowMessageCollectPort + && ( + flowMessageCollectPort.CollectableMessageAnnotation.Type.IsAssignableFrom(startFlowMessageComposePort.ComposableMessageAnnotation.Type) + || typeof(ScriptableObject).IsAssignableFrom(startFlowMessageComposePort.ComposableMessageAnnotation.Type) && typeof(ScriptableObject).IsAssignableFrom(flowMessageCollectPort.CollectableMessageAnnotation.Type) + || flowMessageCollectPort.CollectableMessageAnnotation.Type == typeof(int) && startFlowMessageComposePort.ComposableMessageAnnotation.Type.IsEnum + || startFlowMessageComposePort.ComposableMessageAnnotation.Type == typeof(int) && flowMessageCollectPort.CollectableMessageAnnotation.Type.IsEnum + ) + && x.direction != startPort.direction + && x.node != startPort.node + ) + .ToList(); + case FlowMessageCollectPort startFlowMessageCollectPort: + return ports + .ToList() + .Where( + x => + x is FlowMessageComposePort flowMessageComposePort + && ( + startFlowMessageCollectPort.CollectableMessageAnnotation.Type.IsAssignableFrom(flowMessageComposePort.ComposableMessageAnnotation.Type) + || typeof(ScriptableObject).IsAssignableFrom(flowMessageComposePort.ComposableMessageAnnotation.Type) && typeof(ScriptableObject).IsAssignableFrom(startFlowMessageCollectPort.CollectableMessageAnnotation.Type) + || startFlowMessageCollectPort.CollectableMessageAnnotation.Type == typeof(int) && flowMessageComposePort.ComposableMessageAnnotation.Type.IsEnum + || flowMessageComposePort.ComposableMessageAnnotation.Type == typeof(int) && startFlowMessageCollectPort.CollectableMessageAnnotation.Type.IsEnum + ) + && startFlowMessageCollectPort.CollectableMessageAnnotation.Type.IsAssignableFrom(flowMessageComposePort.ComposableMessageAnnotation.Type) + && x.direction != startPort.direction + && x.node != startPort.node + ) + .ToList(); + default: + return ports + .ToList() + .Where(x => x is FlowPort && x.direction != startPort.direction && x.node != startPort.node) + .ToList(); + } + } + } +} diff --git a/Assets/Editor/Scripts/FlowGraphView.cs.meta b/Assets/Editor/Scripts/FlowGraphView.cs.meta new file mode 100644 index 0000000..5de35ec --- /dev/null +++ b/Assets/Editor/Scripts/FlowGraphView.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0663831361b146bdb10f634132351323 +timeCreated: 1566483741 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowGridBackground.cs b/Assets/Editor/Scripts/FlowGridBackground.cs new file mode 100644 index 0000000..06ea8fb --- /dev/null +++ b/Assets/Editor/Scripts/FlowGridBackground.cs @@ -0,0 +1,8 @@ +using UnityEditor.Experimental.GraphView; + +namespace UniFlow.Editor +{ + public class FlowGridBackground : GridBackground + { + } +} \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowGridBackground.cs.meta b/Assets/Editor/Scripts/FlowGridBackground.cs.meta new file mode 100644 index 0000000..c1e0578 --- /dev/null +++ b/Assets/Editor/Scripts/FlowGridBackground.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9e69953512fc435ca34deb4a994c6c90 +timeCreated: 1566528461 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowMessageCollectPort.cs b/Assets/Editor/Scripts/FlowMessageCollectPort.cs new file mode 100644 index 0000000..2351493 --- /dev/null +++ b/Assets/Editor/Scripts/FlowMessageCollectPort.cs @@ -0,0 +1,32 @@ +using System; +using UnityEditor.Experimental.GraphView; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + public class FlowMessageCollectPort : Port + { + private FlowMessageCollectPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type) + { + } + + public ICollectableMessageAnnotation CollectableMessageAnnotation { get; private set; } + + public static Port Create(Orientation portOrientation, Direction portDirection, Capacity portCapacity, ICollectableMessageAnnotation collectableMessageAnnotation, IEdgeConnectorListener edgeConnectorListener = default) + { + var port = new FlowMessageCollectPort(portOrientation, portDirection, portCapacity, typeof(FlowMessageCollectPort)) + { + CollectableMessageAnnotation = collectableMessageAnnotation, + }; + + // ReSharper disable once InvertIf + if (edgeConnectorListener != default) + { + port.m_EdgeConnector = new EdgeConnector(edgeConnectorListener); + port.AddManipulator(port.m_EdgeConnector); + } + + return port; + } + } +} diff --git a/Assets/Editor/Scripts/FlowMessageCollectPort.cs.meta b/Assets/Editor/Scripts/FlowMessageCollectPort.cs.meta new file mode 100644 index 0000000..98925b5 --- /dev/null +++ b/Assets/Editor/Scripts/FlowMessageCollectPort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b15b165d9c8e140e19f047fec52b041b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts/FlowMessageComposePort.cs b/Assets/Editor/Scripts/FlowMessageComposePort.cs new file mode 100644 index 0000000..dd91a67 --- /dev/null +++ b/Assets/Editor/Scripts/FlowMessageComposePort.cs @@ -0,0 +1,32 @@ +using System; +using UnityEditor.Experimental.GraphView; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + public class FlowMessageComposePort : Port + { + private FlowMessageComposePort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type) + { + } + + public IComposableMessageAnnotation ComposableMessageAnnotation { get; private set; } + + public static Port Create(Orientation portOrientation, Direction portDirection, Capacity portCapacity, IComposableMessageAnnotation composableMessageAnnotation, IEdgeConnectorListener edgeConnectorListener = default) + { + var port = new FlowMessageComposePort(portOrientation, portDirection, portCapacity, typeof(FlowMessageComposePort)) + { + ComposableMessageAnnotation = composableMessageAnnotation, + }; + + // ReSharper disable once InvertIf + if (edgeConnectorListener != default) + { + port.m_EdgeConnector = new EdgeConnector(edgeConnectorListener); + port.AddManipulator(port.m_EdgeConnector); + } + + return port; + } + } +} diff --git a/Assets/Editor/Scripts/FlowMessageComposePort.cs.meta b/Assets/Editor/Scripts/FlowMessageComposePort.cs.meta new file mode 100644 index 0000000..3632d1c --- /dev/null +++ b/Assets/Editor/Scripts/FlowMessageComposePort.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f9c4725aac1b94447ae3b85fbc56bcbb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts/FlowNode.cs b/Assets/Editor/Scripts/FlowNode.cs new file mode 100644 index 0000000..6e799e7 --- /dev/null +++ b/Assets/Editor/Scripts/FlowNode.cs @@ -0,0 +1,415 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text.RegularExpressions; +using UniRx; +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEditor.UIElements; +using UnityEngine; +using UnityEngine.UIElements; +using Object = UnityEngine.Object; + +namespace UniFlow.Editor +{ + public class FlowNode : Node, IRemovableElement + { + public FlowNode(ConnectorInfo connectorInfo, IEdgeConnectorListener edgeConnectorListener, IEdgeConnectorListener messageConnectorListener) + { + ConnectorInfo = connectorInfo; + EdgeConnectorListener = edgeConnectorListener; + MessageConnectorListener = messageConnectorListener; + } + + public void Initialize() + { + name = ConnectorInfo.Name; + title = ConnectorInfo.Name; + styleSheets.Add(AssetReferences.Instance.FlowNode); + capabilities = + Capabilities.Selectable | +// Capabilities.Collapsible | +// Capabilities.Resizable | + Capabilities.Movable | + Capabilities.Deletable | + Capabilities.Droppable | + Capabilities.Ascendable | + Capabilities.Renamable; + + if (ConnectorInfo.GameObject == default) + { + ConnectorInfo.GameObject = DeterminateGameObject(); + } + + if (ConnectorInfo.Connector == default) + { + ConnectorInfo.Connector = Undo.AddComponent(ConnectorInfo.GameObject, ConnectorInfo.Type) as IConnector; + ConnectorInfo.ReCalculateAnnotations(); + } + + AddParameters(); + AddPorts(); + RegisterCallback((GeometryChangedEvent e) => ApplyPosition()); + ConnectorInfo + .Connector? + .OnConnectSubject + .Subscribe( + x => + { + var messagedBorder = new VisualElement {name = "messaged-border"}; + Add(messagedBorder); + Observable.Timer(TimeSpan.FromSeconds(1.0)).Subscribe(_ => Remove(messagedBorder)); + } + ); + } + + public Port InputPort { get; private set; } + public Port OutputPort { get; private set; } + + public IList MessageComposePorts { get; } = new List(); + public IList MessageCollectPorts { get; } = new List(); + + internal ConnectorInfo ConnectorInfo { get; } + + private IEdgeConnectorListener EdgeConnectorListener { get; } + private IEdgeConnectorListener MessageConnectorListener { get; } + + private const string DefaultTargetGameObjectName = "UniFlowController"; + private static IEnumerable ParameterNamesHideInNode { get; } = new List + { + "actAsTrigger", + "targetComponents", + "targetIds", + }; + + private static IDictionary> CreateFieldFunctions { get; } = new Dictionary> + { + {typeof(string), CreateBindableElement}, + {typeof(int), CreateBindableElement}, + {typeof(float), CreateBindableElement}, + {typeof(double), CreateBindableElement}, + {typeof(bool), CreateBindableElement}, + {typeof(Object), CreateBindableElement}, + }; + + private static IList PropertyFieldRenderableTypes { get; } = new List + { + typeof(byte), + typeof(Vector2), + typeof(Vector3), + typeof(Vector4), + typeof(Quaternion), + typeof(Vector2Int), + typeof(Vector3Int), + typeof(Color), + typeof(Color32), + }; + + void IRemovableElement.RemoveFromGraphView() + { + if (ConnectorInfo.Connector == default || !(ConnectorInfo.Connector is Component component)) + { + return; + } + + Undo.DestroyObjectImmediate(component); + FlowEditorWindow.Window.FlowGraphView.SetupActAsTrigger(); + } + + public Vector2 GetRecordedPosition() + { + return ((ConnectorBase) ConnectorInfo.Connector).FlowGraphNodePosition; + } + + public void ApplyPosition() + { + if (!(ConnectorInfo.Connector is ConnectorBase connector) || connector == default || Mathf.Approximately(layout.position.magnitude, 0.0f)) + { + return; + } + + Undo.RecordObject(connector, "Move Node"); + // ReSharper disable once InvertIf + if (connector.FlowGraphNodePosition != layout.position) + { + connector.FlowGraphNodePosition = layout.position; + EditorUtility.SetDirty(connector); + } + } + + public void ApplyTargetConnectors() + { + if (ConnectorInfo.Connector == default || !(ConnectorInfo.Connector is ConnectorBase connector) || connector == default) + { + return; + } + + Undo.RecordObject(connector, "Apply Target Connectors"); + connector.TargetComponents = OutputPort? + .connections + .Select(x => x.input.node as FlowNode) + .Where(x => x != default) + .Select(x => x.ConnectorInfo.Connector) + .OfType(); + EditorUtility.SetDirty(connector); + } + + private void AddParameters() + { + var contentsElement = this.Q("contents"); + + var parametersElement = new VisualElement {name = "parameters"}; + { + var dividerElement = new VisualElement {name = "divider"}; + dividerElement.AddToClassList("horizontal"); + parametersElement.Add(dividerElement); + + var itemsElement = new VisualElement {name = "items"}; + parametersElement.Add(itemsElement); + + { + var element = new VisualElement(); + var field = new ObjectField("GameObject") {objectType = typeof(GameObject), allowSceneObjects = true}; + field.SetValueWithoutNotify(ConnectorInfo.GameObject); + field.RegisterValueChangedCallback( + x => + { + var groupId = Undo.GetCurrentGroup(); + + if (x.previousValue != default && ConnectorInfo.Connector is Component component && component != default) + { + Undo.DestroyObjectImmediate(component); + EditorUtility.SetDirty(x.previousValue); + } + + if (x.newValue != default && x.newValue is GameObject newGameObject) + { + ConnectorInfo.GameObject = newGameObject; + ConnectorInfo.Connector = Undo.AddComponent(ConnectorInfo.GameObject, ConnectorInfo.Type) as IConnector; + ConnectorInfo.ReCalculateAnnotations(); + ConnectorInfo.ApplyParameters(); + ApplyTargetConnectors(); + InputPort?.connections.Select(y => y.output.node).OfType().ToList().ForEach(y => y.ApplyTargetConnectors()); + EditorUtility.SetDirty(x.newValue); + } + + if (x.previousValue != default && x.previousValue is GameObject previousGameObject && previousGameObject.name == "Dummy") + { + Object.Destroy(previousGameObject); + } + + Undo.CollapseUndoOperations(groupId); + } + ); + + element.Add(field); + itemsElement.Add(element); + + if (ConnectorInfo.ParameterList.Any(x => !ParameterNamesHideInNode.Contains(x.Name))) + { + var innerDividerElement = new VisualElement {name = "divider"}; + innerDividerElement.AddToClassList("horizontal"); + itemsElement.Add(innerDividerElement); + } + } + + foreach (var parameter in ConnectorInfo.ParameterList) + { + if (ParameterNamesHideInNode.Contains(parameter.Name)) + { + continue; + } + + var element = new VisualElement(); + var field = CreateField(ConnectorInfo, parameter); + element.Add(field); + itemsElement.Add(element); + } + } + + contentsElement.Add(parametersElement); + } + + private static VisualElement CreateField(ConnectorInfo connectorInfo, ConnectorInfo.Parameter parameter) + { + // Generic types field only be rendered by PropertyField + if ( + parameter.Type.IsGenericType + && ( + typeof(List<>).IsAssignableFrom(parameter.Type.GetGenericTypeDefinition()) + || typeof(ExposedReference<>).IsAssignableFrom(parameter.Type.GetGenericTypeDefinition()) + ) + || PropertyFieldRenderableTypes.Contains(parameter.Type) + ) + { + if (connectorInfo.GameObject == default || connectorInfo.Connector == default) + { + return null; + } + + var serializedObject = new SerializedObject(connectorInfo.Connector as Component); + var serializedProperty = serializedObject.FindProperty(parameter.Name); + var displayName = ToDisplayName(parameter.Name); + var field = new PropertyField(serializedProperty, displayName); + try + { + field.Bind(serializedObject); + } + catch (ArgumentException) + { + // First-aid for problems that may cause the display to be corrupted when the enum value is changed + serializedProperty.enumValueIndex = 0; + serializedProperty.ClearArray(); + serializedObject.ApplyModifiedProperties(); + field = new PropertyField(serializedProperty, displayName); + field.Bind(serializedObject); + } + + return field; + } + + // EnumField does not work unless the initial value is given to the second argument + if (parameter.Type.IsEnum) + { + var field = new EnumField(ToDisplayName(parameter.Name), parameter.Value == default ? (Enum) Activator.CreateInstance(parameter.Type) : (Enum) parameter.Value); + field.RegisterValueChangedCallback( + x => + { + parameter.Value = x.newValue; + Undo.RecordObject(connectorInfo.Connector as Component, $"Change {connectorInfo.Name}.{parameter.Name}"); + connectorInfo.ApplyParameter(parameter); + EditorUtility.SetDirty(connectorInfo.Connector as Component); + } + ); + return field; + } + + var fieldType = parameter.Type; + + if (typeof(Object).IsAssignableFrom(parameter.Type)) + { + fieldType = typeof(Object); + } + + if (!CreateFieldFunctions.ContainsKey(fieldType)) + { + return null; + } + + return CreateFieldFunctions[fieldType](connectorInfo, parameter); + } + + private static BindableElement CreateBindableElement(ConnectorInfo connectorInfo, ConnectorInfo.Parameter parameter) where TResult : BaseField, new() + { + var field = new TResult + { + label = ToDisplayName(parameter.Name), + }; + + // ReSharper disable once InvertIf + if (typeof(TValue) == typeof(Object) && field is ObjectField objectField) + { + objectField.objectType = parameter.Type; + objectField.allowSceneObjects = true; + } + + if (parameter.Value != default) + { + field.value = (TValue) parameter.Value; + } + + if (field is INotifyValueChanged notifyValueChanged) + { + notifyValueChanged.RegisterValueChangedCallback( + x => + { + // 直接 Component 監視させちゃう? + Undo.RecordObject(FlowEditorWindow.Window, "Change Value"); + parameter.Value = x.newValue; + connectorInfo.ApplyParameter(parameter); + FlowEditorWindow.Window.ForceRegisterUndo(); + EditorUtility.SetDirty(connectorInfo.Connector as Component); + } + ); + } + + return field; + } + + private static GameObject DeterminateGameObject() + { + if (UniFlowSettings.instance.SelectedGameObject) + { + return UniFlowSettings.instance.SelectedGameObject; + } + + if (GameObject.Find(DefaultTargetGameObjectName) != default) + { + return GameObject.Find(DefaultTargetGameObjectName); + } + + var go = new GameObject(DefaultTargetGameObjectName); + Undo.RegisterCreatedObjectUndo(go, "New UniFlowController"); + return go; + } + + [SuppressMessage("ReSharper", "InvertIf")] + private void AddPorts() + { + OutputPort = FlowPort.Create(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, EdgeConnectorListener); + OutputPort.portName = "Out"; + outputContainer.Add(OutputPort); + + // Prevent grab port for input + InputPort = FlowPort.Create(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi); + InputPort.portName = "In"; + inputContainer.Add(InputPort); + + if (ConnectorInfo.ComposableMessageAnnotations.Any()) + { + var divider = new VisualElement {name = "divider"}; + divider.AddToClassList("horizontal"); + outputContainer.Add(divider); + + foreach (var composableMessageAnnotation in ConnectorInfo.ComposableMessageAnnotations) + { + var port = FlowMessageComposePort.Create(Orientation.Horizontal, Direction.Output, Port.Capacity.Multi, composableMessageAnnotation, MessageConnectorListener); + port.portName = composableMessageAnnotation.Key; + outputContainer.Add(port); + MessageComposePorts.Add(port as FlowMessageComposePort); + } + } + + if (ConnectorInfo.CollectableMessageAnnotations.Any()) + { + var divider = new VisualElement {name = "divider"}; + divider.AddToClassList("horizontal"); + inputContainer.Add(divider); + + foreach (var collectableMessageAnnotation in ConnectorInfo.CollectableMessageAnnotations) + { + var port = FlowMessageCollectPort.Create(Orientation.Horizontal, Direction.Input, Port.Capacity.Multi, collectableMessageAnnotation, MessageConnectorListener); + port.portName = collectableMessageAnnotation.Key; + inputContainer.Add(port); + MessageCollectPorts.Add(port as FlowMessageCollectPort); + } + } + } + + private static string ToDisplayName(string original) + { + if (Regex.IsMatch(original, "ControlMethod$")) + { + return "Control Method"; + } + + if (Regex.IsMatch(original, "EventType$")) + { + return "Event Type"; + } + + return original.Substring(0, 1).ToUpper() + Regex.Replace(original.Substring(1), "([A-Z]+[a-z])", " $1"); + } + } +} diff --git a/Assets/Editor/Scripts/FlowNode.cs.meta b/Assets/Editor/Scripts/FlowNode.cs.meta new file mode 100644 index 0000000..be46cdc --- /dev/null +++ b/Assets/Editor/Scripts/FlowNode.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8fc98eb37f1b4b69a10c9990a1509baf +timeCreated: 1566527981 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowPort.cs b/Assets/Editor/Scripts/FlowPort.cs new file mode 100644 index 0000000..112086e --- /dev/null +++ b/Assets/Editor/Scripts/FlowPort.cs @@ -0,0 +1,30 @@ +using System; +using UnityEditor.Experimental.GraphView; +using UnityEngine; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + public class FlowPort : Port + { + private FlowPort(Orientation portOrientation, Direction portDirection, Capacity portCapacity, Type type) : base(portOrientation, portDirection, portCapacity, type) + { + } + + public static Port Create(Orientation portOrientation, Direction portDirection, Capacity portCapacity, IEdgeConnectorListener edgeConnectorListener = default) + { + // Should I use Port.Create()? + var port = new FlowPort(portOrientation, portDirection, portCapacity, typeof(FlowPort)); + + // ReSharper disable once InvertIf + if (edgeConnectorListener != default) + { + port.m_EdgeConnector = new EdgeConnector(edgeConnectorListener); + port.AddManipulator(port.m_EdgeConnector); + } + port.portColor = Color.yellow; + + return port; + } + } +} diff --git a/Assets/Editor/Scripts/FlowPort.cs.meta b/Assets/Editor/Scripts/FlowPort.cs.meta new file mode 100644 index 0000000..4c48b4a --- /dev/null +++ b/Assets/Editor/Scripts/FlowPort.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ba2ac6700fd4440895a81bb745143298 +timeCreated: 1566529708 \ No newline at end of file diff --git a/Assets/Editor/Scripts/FlowVisualElement.cs b/Assets/Editor/Scripts/FlowVisualElement.cs new file mode 100644 index 0000000..ffd36c6 --- /dev/null +++ b/Assets/Editor/Scripts/FlowVisualElement.cs @@ -0,0 +1,117 @@ +using UniRx; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.UIElements; + +namespace UniFlow.Editor +{ + public class FlowVisualElement : VisualElement + { + internal FlowGraphView FlowGraphView { get; private set; } + private VisualElement Content { get; set; } + + public void Initialize() + { + styleSheets.Add(AssetReferences.Instance.FlowVisualElement); + + var toolbar = new IMGUIContainer( + () => + { + GUILayout.BeginHorizontal(EditorStyles.toolbar); + if (GUILayout.Button("Load", EditorStyles.toolbarButton)) + { + FlowGraphView.CollectConnectorsForSearchTree(); + UniFlowSettings.instance.SelectedGameObject = Selection.activeGameObject; + if (Contains(Content)) + { + Remove(Content); + } + Load(); + } + + GUILayout.Space(6); + + if (GUILayout.Button($"Save {(UniFlowSettings.instance.IsPrefabMode ? "Prefab" : "Scenes")}", EditorStyles.toolbarButton)) + { + if (UniFlowSettings.instance.IsPrefabMode) + { + PrefabUtility.SavePrefabAsset(UniFlowSettings.instance.SelectedGameObject); + } + else if (UniFlowSettings.instance.SelectedGameObject != default) + { + EditorSceneManager.SaveScene(UniFlowSettings.instance.SelectedGameObject.scene); + } + } + + GUILayout.Space(6); + + if (GUILayout.Button("Reset Viewport", EditorStyles.toolbarButton)) + { + UniFlowSettings.instance.LatestPosition = Vector3.zero; + UniFlowSettings.instance.LatestScale = Vector3.one; + Remove(Content); + Load(); + } + if (GUILayout.Button("Auto Layout", EditorStyles.toolbarButton)) + { + if (Contains(Content)) + { + Remove(Content); + } + Load(); + Observable.TimerFrame(1).Subscribe(_ => FlowGraphView.Relocation(true)); + } + + if (UniFlowSettings.instance.SelectedGameObject != default) + { + GUILayout.Space(6); + + // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression + if (UniFlowSettings.instance.IsPrefabMode) + { + GUILayout.Label($"[Prefab] {CreateGameObjectTreeString(UniFlowSettings.instance.SelectedGameObject.transform)}"); + } + else + { + GUILayout.Label($"[{UniFlowSettings.instance.SelectedGameObject.scene.name}] {CreateGameObjectTreeString(UniFlowSettings.instance.SelectedGameObject.transform)}"); + } + } + + GUILayout.FlexibleSpace(); + GUILayout.EndHorizontal(); + } + ); + Add(toolbar); + + Load(); + } + + private static string CreateGameObjectTreeString(Transform transform) + { + if (!transform.gameObject.scene.IsValid()) + { + return AssetDatabase.GetAssetPath(transform.gameObject); + } + + var parent = transform.parent; + return parent == default ? transform.name : $"{CreateGameObjectTreeString(parent)} > {transform.name}"; + } + + private void Load() + { + FlowGraphView = new FlowGraphView + { + name = typeof(FlowGraphView).Name, + }; + + FlowGraphView.Initialize(); + Content = new VisualElement + { + name = "Content", + }; + Content.Add(FlowGraphView); + Add(Content); + } + } +} diff --git a/Assets/Editor/Scripts/FlowVisualElement.cs.meta b/Assets/Editor/Scripts/FlowVisualElement.cs.meta new file mode 100644 index 0000000..ad0e515 --- /dev/null +++ b/Assets/Editor/Scripts/FlowVisualElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0de9e2e85c5c43d68cc5e98238742e77 +timeCreated: 1566483785 \ No newline at end of file diff --git a/Assets/Editor/Scripts/IRemovableElement.cs b/Assets/Editor/Scripts/IRemovableElement.cs new file mode 100644 index 0000000..b8a8cf2 --- /dev/null +++ b/Assets/Editor/Scripts/IRemovableElement.cs @@ -0,0 +1,7 @@ +namespace UniFlow.Editor +{ + public interface IRemovableElement + { + void RemoveFromGraphView(); + } +} \ No newline at end of file diff --git a/Assets/Editor/Scripts/IRemovableElement.cs.meta b/Assets/Editor/Scripts/IRemovableElement.cs.meta new file mode 100644 index 0000000..96ff7d7 --- /dev/null +++ b/Assets/Editor/Scripts/IRemovableElement.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cf11e073a53243eeb19968e55d8fac0c +timeCreated: 1567154451 \ No newline at end of file diff --git a/Assets/Editor/Scripts/LayerIndex.cs b/Assets/Editor/Scripts/LayerIndex.cs new file mode 100644 index 0000000..c1d1b08 --- /dev/null +++ b/Assets/Editor/Scripts/LayerIndex.cs @@ -0,0 +1,8 @@ +namespace UniFlow.Editor +{ + public enum LayerIndex + { + Edge = 1, + Node, + } +} \ No newline at end of file diff --git a/Assets/Editor/Scripts/LayerIndex.cs.meta b/Assets/Editor/Scripts/LayerIndex.cs.meta new file mode 100644 index 0000000..4894060 --- /dev/null +++ b/Assets/Editor/Scripts/LayerIndex.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7b2f5cee29ac4d5ba6c38784800955a4 +timeCreated: 1566528981 \ No newline at end of file diff --git a/Assets/Editor/Scripts/MessageConnectorListener.cs b/Assets/Editor/Scripts/MessageConnectorListener.cs new file mode 100644 index 0000000..baf01b1 --- /dev/null +++ b/Assets/Editor/Scripts/MessageConnectorListener.cs @@ -0,0 +1,52 @@ +using UnityEditor; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace UniFlow.Editor +{ + public class MessageConnectorListener : IEdgeConnectorListener + { + public MessageConnectorListener(FlowGraphView flowGraphView) + { + FlowGraphView = flowGraphView; + } + + private FlowGraphView FlowGraphView { get; } + + void IEdgeConnectorListener.OnDropOutsidePort(Edge edge, Vector2 position) + { + // Do nothing. + } + + void IEdgeConnectorListener.OnDrop(GraphView graphView, Edge edge) + { + FlowEdge registeredEdge = default; + switch (edge.output) + { + case FlowMessageComposePort _ when edge.input is FlowMessageCollectPort: + registeredEdge = FlowGraphView.AddEdge(edge.output, edge.input); + break; + case FlowMessageCollectPort _ when edge.input is FlowMessageComposePort: + registeredEdge = FlowGraphView.AddEdge(edge.input, edge.output); + break; + } + + if (registeredEdge == default) + { + return; + } + + if (!(registeredEdge.output is FlowMessageComposePort messageComposePort) || !(registeredEdge.input is FlowMessageCollectPort messageCollectPort)) + { + return; + } + + messageCollectPort.CollectableMessageAnnotation.ValueCollector.SourceConnector = ((FlowNode) messageComposePort.node).ConnectorInfo.Connector; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.TargetConnector = ((FlowNode) messageCollectPort.node).ConnectorInfo.Connector; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.TypeString = messageComposePort.ComposableMessageAnnotation.Type.AssemblyQualifiedName; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.ComposerKey = messageComposePort.ComposableMessageAnnotation.Key; + messageCollectPort.CollectableMessageAnnotation.ValueCollector.CollectorKey = messageCollectPort.CollectableMessageAnnotation.Key; + EditorUtility.SetDirty(((FlowNode) messageCollectPort.node).ConnectorInfo.Connector as ConnectorBase); + } + } +} diff --git a/Assets/Editor/Scripts/MessageConnectorListener.cs.meta b/Assets/Editor/Scripts/MessageConnectorListener.cs.meta new file mode 100644 index 0000000..6416065 --- /dev/null +++ b/Assets/Editor/Scripts/MessageConnectorListener.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 828ad09f2e7374b03b0718d375b0408d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Editor/Scripts/SearchWindowProvider.cs b/Assets/Editor/Scripts/SearchWindowProvider.cs new file mode 100644 index 0000000..1d3e195 --- /dev/null +++ b/Assets/Editor/Scripts/SearchWindowProvider.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using UnityEditor.Experimental.GraphView; +using UnityEngine; + +namespace UniFlow.Editor +{ + public class SearchWindowProvider : ScriptableObject, ISearchWindowProvider + { + private FlowGraphView FlowGraphView { get; set; } + + private List SearchTreeEntries { get; set; } + + private Texture2D DummyIcon { get; set; } + + public FlowPort FlowPort { get; set; } + + private IDictionary SearchTreeGroupEntries { get; } = new Dictionary(); + + private static IEnumerable DirectoryOrder { get; } = new[] + { + "Controller", + "Event", + "Logic", + "Calculator", + "Expression", + "Receiver", + "Complex", + "Misc", + "ValueProvider", + "ValueSelector", + "ValueComparer", + "ValueInjector", + "SignalPublisher", + "SignalReceiver", + }; + + public void Initialize(FlowGraphView flowGraphView) + { + FlowGraphView = flowGraphView; + + DummyIcon = new Texture2D(1, 1); + DummyIcon.SetPixel(0, 0, new Color(0, 0, 0, 0)); + DummyIcon.Apply(); + + CalculateSearchTree(); + } + + public void CalculateSearchTree() + { + SearchTreeGroupEntries.Clear(); + SearchTreeEntries = new List + { + new SearchTreeGroupEntry(new GUIContent("Add Node")) + }; + AppDomain + .CurrentDomain + .GetAssemblies() + .SelectMany(x => x.GetTypes()) + .Where(x => x.IsClass && x.IsSubclassOf(typeof(ConnectorBase)) && !x.IsAbstract && x.GetCustomAttributes(false).Any(y => y is AddComponentMenu)) + .Where(x => x.GetCustomAttributes(typeof(AddComponentMenu), false).Any()) + .Select(x => (menu: x.GetCustomAttributes(typeof(AddComponentMenu), false).OfType().First(), type: x)) + .Select(x => (x.menu, x.type, entries: x.menu.componentMenu.Split('/').Skip(1).ToArray())) + .Select(x => (x.menu, x.type, x.entries, directory: x.entries.Take(x.entries.Length - 1).Aggregate((a, b) => $"{a}/{b}"))) + .Select(x => (x.menu, x.type, x.entries, x.directory, directoryOrder: DirectoryOrder.Contains(x.entries.FirstOrDefault()) ? DirectoryOrder.Select((directory, index) => (directory, index)).First(y => y.directory == x.entries.FirstOrDefault()).index : int.MaxValue)) + .OrderBy(x => x.directoryOrder) + .GroupBy(x => x.directory) + .SelectMany(x => x.OrderBy(y => y.entries.LastOrDefault())) + .ToList() + .ForEach( + item => + { + var (_, type, componentMenuEntries, _, _) = item; + var fullPath = new StringBuilder(); + foreach (var (componentMenuEntry, index) in componentMenuEntries.Select((x, i) => (x, i))) + { + fullPath.Append($"/{componentMenuEntry}"); + if (index == componentMenuEntries.Length - 1) + { + break; + } + + if (SearchTreeGroupEntries.ContainsKey(fullPath.ToString())) + { + continue; + } + + SearchTreeGroupEntries[fullPath.ToString()] = new SearchTreeGroupEntry(new GUIContent(componentMenuEntry)) {level = index + 1}; + SearchTreeEntries.Add(SearchTreeGroupEntries[fullPath.ToString()]); + } + + SearchTreeEntries.Add(new SearchTreeEntry(new GUIContent(componentMenuEntries.Last(), DummyIcon)) {level = componentMenuEntries.Length, userData = type}); + } + ); + } + + List ISearchWindowProvider.CreateSearchTree(SearchWindowContext context) + { + return SearchTreeEntries; + } + + bool ISearchWindowProvider.OnSelectEntry(SearchTreeEntry searchTreeEntry, SearchWindowContext context) + { + if (!typeof(IConnector).IsAssignableFrom((Type) searchTreeEntry.userData)) + { + return false; + } + + var node = FlowGraphView.AddNode((Type) searchTreeEntry.userData, null, FlowGraphView.NormalizeMousePosition(context.screenMousePosition)); + + if (FlowPort != default) + { + var edge = FlowGraphView.AddEdge(FlowPort, (FlowPort) node.InputPort); + FlowGraphView.AddElement(edge); + FlowGraphView.SetupActAsTrigger(); + if (FlowPort.node is FlowNode targetFlowNode && targetFlowNode.ConnectorInfo.Connector is ConnectorBase targetConnector) + { + if (targetConnector.TargetComponents == null) + { + targetConnector.TargetComponents = new List(); + } + targetConnector.TargetComponents = targetConnector.TargetComponents.Concat(new List {node.ConnectorInfo.Connector as ConnectorBase}); + } + } + FlowGraphView.SetupActAsTrigger(); + + return true; + } + } +} diff --git a/Assets/Editor/Scripts/SearchWindowProvider.cs.meta b/Assets/Editor/Scripts/SearchWindowProvider.cs.meta new file mode 100644 index 0000000..4f9ba4e --- /dev/null +++ b/Assets/Editor/Scripts/SearchWindowProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 949152518d31435a98b76546407f84c9 +timeCreated: 1566893459 \ No newline at end of file diff --git a/Assets/Editor/StyleSheets.meta b/Assets/Editor/StyleSheets.meta new file mode 100644 index 0000000..4dd2562 --- /dev/null +++ b/Assets/Editor/StyleSheets.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 56a08ed7966b430496412e3548a8ffee +timeCreated: 1566486429 \ No newline at end of file diff --git a/Assets/Editor/StyleSheets/FlowGraphView.uss b/Assets/Editor/StyleSheets/FlowGraphView.uss new file mode 100644 index 0000000..160c4a4 --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowGraphView.uss @@ -0,0 +1,9 @@ +#FlowGridBackground { + flex-direction: row; + flex: 1; + --grid-background-color: #2a2a2a; + --line-color: #262626; + --thick-line-color: #212121; + --spacing: 10; + --thick-lines: 10; +} diff --git a/Assets/Editor/StyleSheets/FlowGraphView.uss.meta b/Assets/Editor/StyleSheets/FlowGraphView.uss.meta new file mode 100644 index 0000000..0577e65 --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowGraphView.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2d1bfda56f80479a9954af9e73517286 +timeCreated: 1566524058 \ No newline at end of file diff --git a/Assets/Editor/StyleSheets/FlowNode.uss b/Assets/Editor/StyleSheets/FlowNode.uss new file mode 100644 index 0000000..4a37239 --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowNode.uss @@ -0,0 +1,49 @@ +FlowNode { + width: 300px; +} + +FlowNode #MainContainer { + margin: 5px 10px; +} + +FlowNode #parameters { + background-color: rgba(63, 63, 63, 0.8); +} + +FlowNode #parameters #items { + padding: 5px; +} + +FlowNode #parameters #items > #divider { + margin: 5px 0; +} + +FlowNode #parameters #items > VisualElement .unity-label { + min-width: 100px; + max-width: 100px; +} + +FlowNode #parameters #items > VisualElement #unity-x-input .unity-label, +FlowNode #parameters #items > VisualElement #unity-y-input .unity-label, +FlowNode #parameters #items > VisualElement #unity-z-input .unity-label { + min-width: 20px; + max-width: 20px; +} + +FlowNode #messaged-border { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + margin-top: 1px; + margin-bottom: 1px; + margin-left: 1px; + margin-right: 1px; + border-radius: 8px; + border-color: rgba(255, 255, 0, 0.5); + border-top-width: 3px; + border-bottom-width: 3px; + border-left-width: 3px; + border-right-width: 3px; +} diff --git a/Assets/Editor/StyleSheets/FlowNode.uss.meta b/Assets/Editor/StyleSheets/FlowNode.uss.meta new file mode 100644 index 0000000..5d57447 --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowNode.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9966dde7671f4ac2b46777545308ca19 +timeCreated: 1566528152 \ No newline at end of file diff --git a/Assets/Editor/StyleSheets/FlowVisualElement.uss b/Assets/Editor/StyleSheets/FlowVisualElement.uss new file mode 100644 index 0000000..2ffed4c --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowVisualElement.uss @@ -0,0 +1,11 @@ +#FlowVisualElement { + flex: 1; +} + +#FlowVisualElement > #Content { + flex: 1; +} + +#FlowVisualElement > #Content > #FlowGraphView { + flex: 1; +} diff --git a/Assets/Editor/StyleSheets/FlowVisualElement.uss.meta b/Assets/Editor/StyleSheets/FlowVisualElement.uss.meta new file mode 100644 index 0000000..5e4a0bf --- /dev/null +++ b/Assets/Editor/StyleSheets/FlowVisualElement.uss.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e5cd5853b6b74e9eab84a4e05492245e +timeCreated: 1566486429 \ No newline at end of file diff --git a/Assets/Editor/UniFlow.Editor.asmdef b/Assets/Editor/UniFlow.Editor.asmdef new file mode 100644 index 0000000..6a7678e --- /dev/null +++ b/Assets/Editor/UniFlow.Editor.asmdef @@ -0,0 +1,17 @@ +{ + "name": "UniFlow.Editor", + "references": [ + "GUID:04f82f1ff3df44e29a1b2cce70510c34", + "GUID:560b04d1a97f54a4e82edc0cbbb69285" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [] +} \ No newline at end of file diff --git a/Assets/Editor/UniFlow.Editor.asmdef.meta b/Assets/Editor/UniFlow.Editor.asmdef.meta new file mode 100644 index 0000000..f717c3e --- /dev/null +++ b/Assets/Editor/UniFlow.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 26d6569d8bbc24143ac64be547efc761 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Installers.meta b/Assets/Installers.meta new file mode 100644 index 0000000..b7f5cc0 --- /dev/null +++ b/Assets/Installers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 53348df9a58b6487c94cb5f44690ac9b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Installers/UniFlowInstaller.asset b/Assets/Installers/UniFlowInstaller.asset new file mode 100644 index 0000000..1c36e2d --- /dev/null +++ b/Assets/Installers/UniFlowInstaller.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3785a4ba4e2b4fcc81b428da2930f35d, type: 3} + m_Name: UniFlowInstaller + m_EditorClassIdentifier: diff --git a/Assets/Installers/UniFlowInstaller.asset.meta b/Assets/Installers/UniFlowInstaller.asset.meta new file mode 100644 index 0000000..384750a --- /dev/null +++ b/Assets/Installers/UniFlowInstaller.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 02e561d68dde84d7882365343fb07ef8 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/README.md b/Assets/README.md index c42425d..83e36d5 100644 --- a/Assets/README.md +++ b/Assets/README.md @@ -1,13 +1,13 @@ -# Event Connector +# UniFlow -EventConnector is a library that can connect various Unity events including user interaction without writing any C# script. +UniFlow is a library that can connect various Unity components without writing any C# script. -Processes such as "Tutorial that accepts user interaction" and "Waiting for the end of playback of Animation, Audio, Timeline, etc." can be implemented easily. +You can implement easily processes such as "Tutorial that accepts user interaction" and "Waiting for the end of playback of Animation, Audio, Timeline, etc.". ## Installation ```bash -upm add package dev.monry.upm.eventconnector +upm add package dev.monry.uniflow ``` Please refer to [this repository](https://github.com/upm-packages/upm-cli) about the `upm` command. @@ -16,37 +16,38 @@ Please refer to [this repository](https://github.com/upm-packages/upm-cli) about ### Basics -#### 1. Attach EventPublishers +#### 1. Attach Connectors -Attach one or more Components what implements `IEventConnectable` listed below into GameObject. +Attach one or more Components what implements `ConnectorBase` listed below into GameObject. -#### 2. Implement EventReceiver +#### 2. Connect Connectors -Implement Component what inherits `EventReceiver`. +Set *Next `ConnectorBase`* into **Target Instances** field for each Connectors. -Implement the process you want to execute when the event is received in the `OnReceive()` method that needs to override by `EventReceiver`. +It is also possible to solve with `Zenject.ResolveIdAll()` by setting ID in **Target Ids** field -This method will be passed `EventMessages` what contains all propagated event informations. +#### 3. Implement Receiver -#### 3. Connect EventConnectors and EventReceiver +Implement Component what inherits `ReceiverBase`. -Set **Next IEventConnectable** into *Target Connector Instances* field for each EventPublisher. +Implement the process you want to execute when the event is received in the `OnReceive()` method that needs to override by `ReceiverBase`. -It is also possible to solve with `Zenject.ResolveIdAll()` by setting ID in *Target Connector Ids* field +This method will be passed `EventMessages` what contains all propagated event informations. ### Inspector -inspector +inspector -#### Target Connector Instances +#### Target Instances -Specify instances what inherits `EventPublisher` or `EventReceiver` into this field. +Specify instances what inherits `ConnectableBase` into this field.
+\* `ConnectorBase` and `ReceiverBase` are inherits `ConnectableBase` Fire messages at the correct time for each component. -#### Target Connector Instances +#### Target Ids -Specify IDs what provides instances of `EventPublisher` or `EventReceiver` resolved by `Zenject.ResolveIdAll()` into this field. +Specify IDs what provides instances of `IConnectable` resolved by `Zenject.ResolveIdAll()` into this field. Fire messages at the correct time for each component. @@ -54,15 +55,17 @@ Fire messages at the correct time for each component. Set true to allow to act as the entry point of events. -#### Act As Receiver +#### Other parameters for each Connector -Set true to allow to act as the receiver of events. +Individual parameters can be specified for each component. -#### Other parameters for each Publisher +### UniFlow Graph -Individual parameters can be specified for each component. +![image](https://user-images.githubusercontent.com/838945/64085909-463dd780-cd70-11e9-9192-77972dbcebce.png) -## Components what inherits `EventPublisher` +UniFlow provides GraphView to view/edit connectables in scenes/prefabs + +## Components what inherits `ConnectorBase` ### Messaging from traditional callback @@ -170,6 +173,8 @@ Component supports below events to observe. * MouseOver * MouseDrag +Note: Do not notify on mobile platforms. + ### Messaging from Physics #### `PhysicsCollisionEvent` @@ -222,6 +227,26 @@ Component supports below events to observe. ### Messaging from time related components +#### `ActivationController` + +This component will control activation of `GameObject` and `MonoBehaviour`. + +Invoke `GameObject.SetActive(bool)` if `TargetGameObjects` field specified. + +Change `MonoBehaviour.enabled` field if `TargetMonoBaheviours` field specified. + +#### `DestroyInstance` + +This component will destroy instances. + +#### `SimpleAnimationController` + +This component will control [SimpleAnimation](https://github.com/Unity-Technologies/SimpleAnimation) components. + +#### `SimpleAnimationEvent` + +This component will observe event that triggered from [SimpleAnimation](https://github.com/Unity-Technologies/SimpleAnimation) components. + #### `AnimatorTrigger` This component will fire `Animator.SetTrigger()`. @@ -275,6 +300,36 @@ This component observes Timeline Signals emission. Specify `TimelineSignal.Dispatch()` in the destination method of the `UnityEngine.Timeline.SignalReceiver` component +#### `RaycasterController` + +This component controls some Raycaster such as `PhysicsRaycaster`, `Physics2DRaycaster` and `GraphicRaycaster`. + +#### `RaycastTargetController` + +This component controls raycastTarget such as `Collider.enabled`, `Graphic.raycastTarget`. + +#### `MoveParentTransform` + +This component changes parent transform. + +### Scene management + +#### `LoadScene` + +This component will load scene specified as string. + +#### `LoadScene` + +This component will load scene specified as enum. + +#### `UnloadScene` + +This component will unload scene specified as string. + +#### `UnloadScene` + +This component will unload scene specified as enum. + ### Other utilities #### `Timer` diff --git a/Assets/Sandbox.meta b/Assets/Sandbox.meta new file mode 100644 index 0000000..9e8b11e --- /dev/null +++ b/Assets/Sandbox.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bb048626fe54643beb870bad3bc4c6e5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sandbox/Prefabs.meta b/Assets/Sandbox/Prefabs.meta new file mode 100644 index 0000000..b9b4f3f --- /dev/null +++ b/Assets/Sandbox/Prefabs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: edcdfa5ade37941d88ca88aff0edf373 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sandbox/Prefabs/Prefab.prefab b/Assets/Sandbox/Prefabs/Prefab.prefab new file mode 100644 index 0000000..9927295 --- /dev/null +++ b/Assets/Sandbox/Prefabs/Prefab.prefab @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6573449693540830191 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4046970079478424149} + - component: {fileID: 7273723851028226959} + - component: {fileID: 846785533979003219} + m_Layer: 0 + m_Name: Prefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &4046970079478424149 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6573449693540830191} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 50, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &7273723851028226959 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6573449693540830191} + m_CullTransparentMesh: 0 +--- !u!114 &846785533979003219 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6573449693540830191} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 0, b: 0, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 diff --git a/Assets/Sandbox/Prefabs/Prefab.prefab.meta b/Assets/Sandbox/Prefabs/Prefab.prefab.meta new file mode 100644 index 0000000..325c0e7 --- /dev/null +++ b/Assets/Sandbox/Prefabs/Prefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8cae44cd6fba64772a14cd152a39a8e4 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sandbox/Scenes.meta b/Assets/Sandbox/Scenes.meta new file mode 100644 index 0000000..cf141f5 --- /dev/null +++ b/Assets/Sandbox/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: adba8b259ad124ec7aeb2a1069e04e86 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Sandbox/Scenes/Test.unity b/Assets/Sandbox/Scenes/Test.unity new file mode 100644 index 0000000..39e8cd3 --- /dev/null +++ b/Assets/Sandbox/Scenes/Test.unity @@ -0,0 +1,684 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &70988941 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 70988942} + - component: {fileID: 70988943} + - component: {fileID: 70988944} + m_Layer: 0 + m_Name: UniFlowController + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &70988942 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70988941} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &70988943 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70988941} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9d96a435a8d74b1a8c60ffea57ac84fa, type: 3} + m_Name: + m_EditorClassIdentifier: + flowGraphNodePosition: {x: 178, y: 94} + targetComponents: + - {fileID: 70988944} + targetIds: [] + actAsTrigger: 1 + source: {fileID: 6573449693540830191, guid: 8cae44cd6fba64772a14cd152a39a8e4, type: 3} + parent: {fileID: 167568203} +--- !u!114 &70988944 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 70988941} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a52a20b5ede4c8ca6a5debe9b19c80b, type: 3} + m_Name: + m_EditorClassIdentifier: + flowGraphNodePosition: {x: 604, y: 51} + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + targetTransform: {fileID: 0} + parentTransform: {fileID: 276008044} + worldPositionStays: 0 + targetGameObjectProvider: {fileID: 70988943} + parentGameObjectProvider: {fileID: 0} +--- !u!1 &167568202 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 167568203} + - component: {fileID: 167568205} + - component: {fileID: 167568204} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &167568203 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 167568202} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 508612077} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &167568204 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 167568202} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &167568205 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 167568202} + m_CullTransparentMesh: 0 +--- !u!1 &276008043 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 276008044} + - component: {fileID: 276008046} + - component: {fileID: 276008045} + m_Layer: 5 + m_Name: Image + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &276008044 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 276008043} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 508612077} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 300, y: 0} + m_SizeDelta: {x: 100, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &276008045 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 276008043} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &276008046 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 276008043} + m_CullTransparentMesh: 0 +--- !u!1 &508612073 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 508612077} + - component: {fileID: 508612076} + - component: {fileID: 508612075} + - component: {fileID: 508612074} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &508612074 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 508612073} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &508612075 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 508612073} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &508612076 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 508612073} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &508612077 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 508612073} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 167568203} + - {fileID: 276008044} + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1140276047 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1140276050} + - component: {fileID: 1140276049} + - component: {fileID: 1140276048} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1140276048 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1140276047} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1140276049 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1140276047} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 76c392e42b5098c458856cdf6ecaaaa1, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1140276050 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1140276047} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1626489816 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1626489819} + - component: {fileID: 1626489818} + - component: {fileID: 1626489817} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1626489817 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1626489816} + m_Enabled: 1 +--- !u!20 &1626489818 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1626489816} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &1626489819 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1626489816} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1977478638 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1977478640} + - component: {fileID: 1977478639} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1977478639 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1977478638} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1977478640 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1977478638} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} diff --git a/Assets/Sandbox/Scenes/Test.unity.meta b/Assets/Sandbox/Scenes/Test.unity.meta new file mode 100644 index 0000000..fe7504b --- /dev/null +++ b/Assets/Sandbox/Scenes/Test.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: cecd180ff84db4baf9dc8f050a8be511 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Connector/AnimationEvent.cs b/Assets/Scripts/Connector/AnimationEvent.cs deleted file mode 100644 index 54f2787..0000000 --- a/Assets/Scripts/Connector/AnimationEvent.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using JetBrains.Annotations; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - // AnimationEvent cannot fire to Component attaching to another GameObject - [RequireComponent(typeof(Animator))] - [AddComponentMenu("Event Connector/AnimationEvent", 301)] - public class AnimationEvent : EventPublisher - { - private ISubject Subject { get; } = new Subject(); - - public override IObservable OnPublishAsObservable() => - Subject - .Take(1) - .Select(x => EventMessage.Create(EventType.AnimationEvent, this, x)); - - /// - /// Invoked from AnimationEvent - /// - /// - [UsedImplicitly] - public void Dispatch(UnityEngine.AnimationEvent animationEvent) - { - Subject.OnNext(animationEvent); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/AnimatorTrigger.cs b/Assets/Scripts/Connector/AnimatorTrigger.cs deleted file mode 100644 index f83399c..0000000 --- a/Assets/Scripts/Connector/AnimatorTrigger.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/AnimatorTrigger", 300)] - public class AnimatorTrigger : EventPublisher - { - [SerializeField] - [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] - private Animator animator = default; - [SerializeField] private string triggerName = default; - - private Animator Animator => animator ? animator : animator = GetComponent(); - private string TriggerName => triggerName; - private int TriggerId => Animator.StringToHash(TriggerName); - - private IDisposable Disposable { get; } = new CompositeDisposable(); - - public override IObservable OnPublishAsObservable() => - Observable - .Create( - observer => - { - Animator.SetTrigger(TriggerId); - observer.OnNext(EventMessage.Create(EventType.AnimatorTrigger, Animator, AnimatorTriggerEventData.Create(TriggerName))); - return Disposable; - } - ); - - private void OnDestroy() - { - Disposable.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/AudioController.cs b/Assets/Scripts/Connector/AudioController.cs deleted file mode 100644 index f3b928d..0000000 --- a/Assets/Scripts/Connector/AudioController.cs +++ /dev/null @@ -1,66 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/AudioController", 302)] - public class AudioController : EventPublisher - { - [SerializeField] private AudioControlMethod audioControlMethod = default; - [SerializeField] - [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] - private AudioSource audioSource = default; - - private AudioControlMethod AudioControlMethod => audioControlMethod; - private AudioSource AudioSource => audioSource ? audioSource : audioSource = GetComponent(); - - private IDisposable Disposable { get; } = new CompositeDisposable(); - - public override IObservable OnPublishAsObservable() => - Observable - .Create( - observer => - { - InvokeAudioSourceMethod(); - observer.OnNext(EventMessage.Create(EventType.AudioController, AudioSource, AudioControllerEventData.Create(AudioControlMethod))); - return Disposable; - } - ); - - private void InvokeAudioSourceMethod() - { - switch (AudioControlMethod) - { - case AudioControlMethod.Play: - AudioSource.Play(); - break; - case AudioControlMethod.Stop: - AudioSource.Stop(); - break; - case AudioControlMethod.Pause: - AudioSource.Pause(); - break; - case AudioControlMethod.UnPause: - AudioSource.UnPause(); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - - private void OnDestroy() - { - Disposable.Dispose(); - } - } - - public enum AudioControlMethod - { - Play, - Stop, - Pause, - UnPause, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/AudioEvent.cs b/Assets/Scripts/Connector/AudioEvent.cs deleted file mode 100644 index d8f225b..0000000 --- a/Assets/Scripts/Connector/AudioEvent.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [RequireComponent(typeof(AudioSource))] - [AddComponentMenu("Event Connector/AudioEvent", 303)] - public class AudioEvent : EventPublisher - { - [SerializeField] private AudioEventType audioEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] - private AudioSource audioSource = default; - - private AudioEventType AudioEventType => audioEventType; - private AudioSource AudioSource => audioSource ? audioSource : audioSource = GetComponent(); - - private IReadOnlyReactiveProperty> TimePair { get; set; } - - public override IObservable OnPublishAsObservable() => - OnAudioEventAsObservable() - .Select(x => EventMessage.Create(EventType.AudioEvent, AudioSource, AudioEventData.Create(x))); - - private IObservable OnAudioEventAsObservable() - { - TimePair = AudioSource - .ObserveEveryValueChanged(x => x.time) - .Pairwise() - .ToReactiveProperty(); - switch (AudioEventType) - { - case AudioEventType.Play: - case AudioEventType.Stop: - case AudioEventType.Pause: - case AudioEventType.UnPause: - return AudioSource - .ObserveEveryValueChanged(x => x.isPlaying) - .Select(x => DetectAudioEventType(x, AudioSource.clip)) - .Where(x => AudioEventType == x); - case AudioEventType.Loop: - return TimePair - .Where(xs => AudioSource.isPlaying && xs.Current < xs.Previous && xs.Previous > 0.0f) - .Select(_ => AudioEventType.Loop); - default: - throw new ArgumentOutOfRangeException(); - } - } - - private AudioEventType DetectAudioEventType(bool isPlaying, AudioClip audioClip) - { - if (audioClip == default) - { - throw new ArgumentOutOfRangeException(); - } - - if (isPlaying && Mathf.Approximately(0.0f, TimePair.Value.Previous) && TimePair.Value.Current > 0.0f) - { - return AudioEventType.Play; - } - - if (!isPlaying && (Mathf.Approximately(audioClip.length, TimePair.Value.Current) || Mathf.Approximately(0.0f, TimePair.Value.Current) && TimePair.Value.Previous > 0.0f)) - { - return AudioEventType.Stop; - } - - if (!isPlaying && TimePair.Value.Current > 0.0f && TimePair.Value.Current > TimePair.Value.Previous) - { - return AudioEventType.Pause; - } - - if (isPlaying && TimePair.Value.Current > 0.0f && TimePair.Value.Current > TimePair.Value.Previous) - { - return AudioEventType.UnPause; - } - - return (AudioEventType) -1; - } - } - - public enum AudioEventType - { - Play, - Stop, - Pause, - UnPause, // Follow method name in AudioClip - Loop, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator.meta b/Assets/Scripts/Connector/Calculator.meta new file mode 100644 index 0000000..5ddf92c --- /dev/null +++ b/Assets/Scripts/Connector/Calculator.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3ba20cdd49d441f7914f0266d022cfea +timeCreated: 1572524989 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator/BoolCalculator.cs b/Assets/Scripts/Connector/Calculator/BoolCalculator.cs new file mode 100644 index 0000000..f0f0b36 --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/BoolCalculator.cs @@ -0,0 +1,18 @@ +using UnityEngine; + +namespace UniFlow.Connector.Calculator +{ + [AddComponentMenu("UniFlow/Calculator/BoolCalculator", (int) ConnectorType.BoolCalculator)] + public class BoolCalculator : CalculatorBase, IAdditionCalculator, IMultiplicationCalculator + { + bool IAdditionCalculator.Add(bool left, bool right) + { + return left | right; + } + + bool IMultiplicationCalculator.Multiply(bool left, bool right) + { + return left & right; + } + } +} diff --git a/Assets/Scripts/Connector/Calculator/BoolCalculator.cs.meta b/Assets/Scripts/Connector/Calculator/BoolCalculator.cs.meta new file mode 100644 index 0000000..08894c1 --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/BoolCalculator.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 108052b08e564232a8e4171d19d07ab0 +timeCreated: 1571562644 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator/CalculatorBase.cs b/Assets/Scripts/Connector/Calculator/CalculatorBase.cs new file mode 100644 index 0000000..6b9b64f --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/CalculatorBase.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Calculator +{ + public abstract class CalculatorBase : CalculatorBase + where TValueCollector : ValueCollectorBase, new() + { + + } + + public abstract class CalculatorBase : ConnectorBase, IMessageCollectable, IMessageComposable + where TLeftValueCollector : ValueCollectorBase, new() + where TRightValueCollector : ValueCollectorBase, new() + { + [SerializeField] private TLeftValue left = default; + [SerializeField] private TRightValue right = default; + [SerializeField] private OperatorType operatorType = default; + private TLeftValue Left + { + get => left; + set => left = value; + } + private TRightValue Right + { + get => right; + set => right = value; + } + private OperatorType OperatorType => operatorType; + + [SerializeField] private TLeftValueCollector leftCollector = new TLeftValueCollector(); + [SerializeField] private TRightValueCollector rightCollector = new TRightValueCollector(); + private TLeftValueCollector LeftCollector => leftCollector; + private TRightValueCollector RightCollector => rightCollector; + + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this, "Result", Calculate()); + } + + private TLeftValue Calculate() + { + switch (OperatorType) + { + case OperatorType.Add when this is IAdditionCalculator calculator: + return calculator.Add(Left, Right); + case OperatorType.Sub when this is ISubtractionCalculator calculator: + return calculator.Subtract(Left, Right); + case OperatorType.Mul when this is IMultiplicationCalculator calculator: + return calculator.Multiply(Left, Right); + case OperatorType.Div when this is IDivisionCalculator calculator: + return calculator.Divide(Left, Right); + case OperatorType.Mod when this is IModulationCalculator calculator: + return calculator.Modulo(Left, Right); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(LeftCollector, x => Left = x, nameof(Left)), + CollectableMessageAnnotationFactory.Create(RightCollector, x => Right = x, nameof(Right)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create("Result"), + }; + } + + public interface IAdditionCalculator : IAdditionCalculator + { + } + + public interface IAdditionCalculator + { + TLeftValue Add(TLeftValue left, TRightValue right); + } + + public interface ISubtractionCalculator : ISubtractionCalculator + { + } + + public interface ISubtractionCalculator + { + TLeftValue Subtract(TLeftValue left, TRightValue right); + } + + public interface IMultiplicationCalculator : IMultiplicationCalculator + { + } + + public interface IMultiplicationCalculator + { + TLeftValue Multiply(TLeftValue left, TRightValue right); + } + + public interface IDivisionCalculator : IDivisionCalculator + { + } + + public interface IDivisionCalculator + { + TLeftValue Divide(TLeftValue left, TRightValue right); + } + + public interface IModulationCalculator : IModulationCalculator + { + } + + public interface IModulationCalculator + { + TLeftValue Modulo(TLeftValue left, TRightValue right); + } + + public interface IFourArithmeticCalculator : IFourArithmeticCalculator + { + } + + public interface IFourArithmeticCalculator : IAdditionCalculator, ISubtractionCalculator, IMultiplicationCalculator, IDivisionCalculator + { + } + + public enum OperatorType + { + Add, + Sub, + Mul, + Div, + Mod, + } +} diff --git a/Assets/Scripts/Connector/Calculator/CalculatorBase.cs.meta b/Assets/Scripts/Connector/Calculator/CalculatorBase.cs.meta new file mode 100644 index 0000000..c9cd049 --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/CalculatorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1e7a8d961bd544b2b69695d8f0ecd07e +timeCreated: 1571561858 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator/FloatExpression.cs b/Assets/Scripts/Connector/Calculator/FloatExpression.cs new file mode 100644 index 0000000..6c35853 --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/FloatExpression.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace UniFlow.Connector.Calculator +{ + [AddComponentMenu("UniFlow/Calculator/FloatCalculator", (int) ConnectorType.FloatCalculator)] + public class FloatCalculator : CalculatorBase, IFourArithmeticCalculator, IModulationCalculator + { + float IAdditionCalculator.Add(float left, float right) + { + return left + right; + } + + float ISubtractionCalculator.Subtract(float left, float right) + { + return left - right; + } + + float IMultiplicationCalculator.Multiply(float left, float right) + { + return left * right; + } + + float IDivisionCalculator.Divide(float left, float right) + { + return left / right; + } + + float IModulationCalculator.Modulo(float left, float right) + { + return left % right; + } + } +} diff --git a/Assets/Scripts/Connector/Calculator/FloatExpression.cs.meta b/Assets/Scripts/Connector/Calculator/FloatExpression.cs.meta new file mode 100644 index 0000000..9b00eff --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/FloatExpression.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 05dce89e70814e83ae51456b109e6c32 +timeCreated: 1571562576 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator/IntCalculator.cs b/Assets/Scripts/Connector/Calculator/IntCalculator.cs new file mode 100644 index 0000000..b30decf --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/IntCalculator.cs @@ -0,0 +1,33 @@ +using UnityEngine; + +namespace UniFlow.Connector.Calculator +{ + [AddComponentMenu("UniFlow/Calculator/IntCalculator", (int) ConnectorType.IntCalculator)] + public class IntCalculator : CalculatorBase, IFourArithmeticCalculator, IModulationCalculator + { + int IAdditionCalculator.Add(int left, int right) + { + return left + right; + } + + int ISubtractionCalculator.Subtract(int left, int right) + { + return left - right; + } + + int IMultiplicationCalculator.Multiply(int left, int right) + { + return left * right; + } + + int IDivisionCalculator.Divide(int left, int right) + { + return left / right; + } + + int IModulationCalculator.Modulo(int left, int right) + { + return left % right; + } + } +} diff --git a/Assets/Scripts/Connector/Calculator/IntCalculator.cs.meta b/Assets/Scripts/Connector/Calculator/IntCalculator.cs.meta new file mode 100644 index 0000000..6aaa32e --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/IntCalculator.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 058d2d85c28f40018409695051946a89 +timeCreated: 1571560976 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Calculator/StringExpression.cs b/Assets/Scripts/Connector/Calculator/StringExpression.cs new file mode 100644 index 0000000..90867aa --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/StringExpression.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace UniFlow.Connector.Calculator +{ + [AddComponentMenu("UniFlow/Calculator/StringCalculator", (int) ConnectorType.StringCalculator)] + public class StringCalculator : CalculatorBase, IAdditionCalculator + { + string IAdditionCalculator.Add(string left, string right) + { + return left + right; + } + } +} diff --git a/Assets/Scripts/Connector/Calculator/StringExpression.cs.meta b/Assets/Scripts/Connector/Calculator/StringExpression.cs.meta new file mode 100644 index 0000000..a9ce28c --- /dev/null +++ b/Assets/Scripts/Connector/Calculator/StringExpression.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 47eb997c93a0401b8e06188453cdacd6 +timeCreated: 1571562814 \ No newline at end of file diff --git a/Assets/Scripts/Connector/CameraEvent.cs b/Assets/Scripts/Connector/CameraEvent.cs deleted file mode 100644 index c147688..0000000 --- a/Assets/Scripts/Connector/CameraEvent.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/CameraEvent", 104)] - public class CameraEvent : EventPublisher - { - [SerializeField] private CameraEventType cameraEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private CameraEventType CameraEventType => cameraEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(_ => EventMessage.Create(EventType.CameraEvent, Component, CameraEventData.Create(CameraEventType))); - - private IObservable OnEventAsObservable() - { - switch (CameraEventType) - { - case CameraEventType.BecomeVisible: - return Component.OnBecameVisibleAsObservable(); - case CameraEventType.BecomeInvisible: - return Component.OnBecameInvisibleAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum CameraEventType - { - BecomeVisible, - BecomeInvisible, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex.meta b/Assets/Scripts/Connector/Complex.meta new file mode 100644 index 0000000..29edd8d --- /dev/null +++ b/Assets/Scripts/Connector/Complex.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 747fddd2be8d47c8939dfeb09737f832 +timeCreated: 1571343186 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs b/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs new file mode 100644 index 0000000..ac298af --- /dev/null +++ b/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using UniFlow; +using UniFlow.Utility; +using UniRx; +using UnityEngine; +using UnityEngine.UI; + +namespace PretendLand.Edwin.Scripts.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/GaugeImageRenderer", (int) ConnectorType.GaugeImageRenderer)] + public class GaugeImageRenderer : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private Image image = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private Image Image + { + get => image != default ? image : image = this.GetOrAddComponent(); + set => image = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private ImageCollector imageCollector = new ImageCollector(); + [SerializeField] private FloatObservableCollector floatObservableCollector = new FloatObservableCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private ImageCollector ImageCollector => imageCollector; + private FloatObservableCollector FloatObservableCollector => floatObservableCollector; + + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(ImageCollector, x => Image = x, nameof(Image)), + CollectableMessageAnnotationFactory.Create(FloatObservableCollector, observable => observable.Subscribe(x => Image.fillAmount = x), "FillAmountObservable"), + }; + } +} diff --git a/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs.meta b/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs.meta new file mode 100644 index 0000000..538a840 --- /dev/null +++ b/Assets/Scripts/Connector/Complex/GaugeImageRenderer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4eac16c066ec49e7bf076010a1b48107 +timeCreated: 1571595158 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/MusicDuckingController.cs b/Assets/Scripts/Connector/Complex/MusicDuckingController.cs new file mode 100644 index 0000000..9205afd --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicDuckingController.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UniFlow; +using UniRx; +using UnityEngine; + +namespace PretendLand.Edwin.Scripts.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/MusicDuckingController", (int) ConnectorType.MusicDuckingController)] + public class MusicDuckingController : ConnectorBase, IMessageCollectable + { + [SerializeField] private AudioSource audioSource = default; + [SerializeField] private float volume = default; + [SerializeField] private float duration = default; + + private AudioSource AudioSource + { + get => audioSource != default ? audioSource : audioSource = MusicPlayer.BaseGameObject.GetOrAddComponent(); + set => audioSource = value; + } + private float Volume + { + get => volume; + set => volume = value; + } + private float Duration + { + get => duration; + set => duration = value; + } + + [SerializeField] private AudioSourceCollector audioSourceCollector = new AudioSourceCollector(); + [SerializeField] private FloatCollector volumeCollector = new FloatCollector(); + [SerializeField] private FloatCollector durationCollector = new FloatCollector(); + + private AudioSourceCollector AudioSourceCollector => audioSourceCollector; + private FloatCollector VolumeCollector => volumeCollector; + private FloatCollector DurationCollector => durationCollector; + + public override IObservable OnConnectAsObservable() + { + var subject = new Subject(); + ObservableTween + .Tween(() => AudioSource.volume, () => Volume, Duration, ObservableTween.EaseType.InOutSinusoidal) + .Subscribe( + x => AudioSource.volume = x, + () => subject.OnNext(Unit.Default) + ); + return subject.AsMessageObservable(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(AudioSourceCollector, x => AudioSource = x), + CollectableMessageAnnotationFactory.Create(VolumeCollector, x => Volume = x, nameof(Volume)), + CollectableMessageAnnotationFactory.Create(DurationCollector, x => Duration = x, nameof(Duration)), + }; + } +} diff --git a/Assets/Scripts/Connector/Complex/MusicDuckingController.cs.meta b/Assets/Scripts/Connector/Complex/MusicDuckingController.cs.meta new file mode 100644 index 0000000..a251a04 --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicDuckingController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 05cef80ea076421793a3e1e889dcf4b6 +timeCreated: 1572427329 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/MusicPitchController.cs b/Assets/Scripts/Connector/Complex/MusicPitchController.cs new file mode 100644 index 0000000..25e3bd6 --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicPitchController.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UniFlow; +using UniRx; +using UnityEngine; + +namespace PretendLand.Edwin.Scripts.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/MusicPitchController", (int) ConnectorType.MusicPitchController)] + public class MusicPitchController : ConnectorBase, IMessageCollectable + { + [SerializeField] private AudioSource audioSource = default; + [SerializeField] private float pitch = default; + [SerializeField] private float duration = default; + + private AudioSource AudioSource + { + get => audioSource != default ? audioSource : audioSource = MusicPlayer.BaseGameObject.GetOrAddComponent(); + set => audioSource = value; + } + private float Pitch + { + get => pitch; + set => pitch = value; + } + private float Duration + { + get => duration; + set => duration = value; + } + + [SerializeField] private AudioSourceCollector audioSourceCollector = new AudioSourceCollector(); + [SerializeField] private FloatCollector pitchCollector = new FloatCollector(); + [SerializeField] private FloatCollector durationCollector = new FloatCollector(); + + private AudioSourceCollector AudioSourceCollector => audioSourceCollector; + private FloatCollector PitchCollector => pitchCollector; + private FloatCollector DurationCollector => durationCollector; + + public override IObservable OnConnectAsObservable() + { + var subject = new Subject(); + ObservableTween + .Tween(() => AudioSource.pitch, () => Pitch, Duration, ObservableTween.EaseType.InOutSinusoidal) + .Subscribe( + x => AudioSource.pitch = x, + () => subject.OnNext(Unit.Default) + ); + return subject.AsMessageObservable(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(AudioSourceCollector, x => AudioSource = x), + CollectableMessageAnnotationFactory.Create(PitchCollector, x => Pitch = x, nameof(Pitch)), + CollectableMessageAnnotationFactory.Create(DurationCollector, x => Duration = x, nameof(Duration)), + }; + } +} diff --git a/Assets/Scripts/Connector/Complex/MusicPitchController.cs.meta b/Assets/Scripts/Connector/Complex/MusicPitchController.cs.meta new file mode 100644 index 0000000..c2df981 --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicPitchController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 12cf2a93a77a4017a659c453c2efbd96 +timeCreated: 1572509181 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/MusicPlayer.cs b/Assets/Scripts/Connector/Complex/MusicPlayer.cs new file mode 100644 index 0000000..020f13c --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicPlayer.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniFlow; +using UniFlow.Connector.Controller; +using UniFlow.Utility; +using UnityEngine; + +namespace PretendLand.Edwin.Scripts.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/MusicPlayer", (int) ConnectorType.MusicPlayer)] + public class MusicPlayer : ConnectorBase, IMessageCollectable + { + internal static GameObject BaseGameObject { get; private set; } + + [SerializeField] private AudioSource audioSource = default; + [SerializeField] private AudioControlMethod audioControlMethod = AudioControlMethod.Play; + [SerializeField] + [Tooltip("If you do not specify it will be obtained by AudioSource.clip")] + private AudioClip audioClip = default; + [SerializeField] private string key = default; + [SerializeField] private bool loop = true; + [SerializeField] private bool rewindSameClip = default; + + private AudioSource AudioSource + { + get => audioSource != default ? audioSource : audioSource = BaseGameObject.GetOrAddComponent(); + set => audioSource = value; + } + private AudioControlMethod AudioControlMethod + { + get => audioControlMethod; + set => audioControlMethod = value; + } + private AudioClip AudioClip + { + get => audioClip; + set => audioClip = value; + } + [UsedImplicitly] private string Key + { + get => string.IsNullOrEmpty(key) ? AudioClip.name : key; + set => key = value; + } + private bool Loop + { + get => loop; + set => loop = value; + } + private bool RewindSameClip + { + get => rewindSameClip; + set => rewindSameClip = value; + } + + [SerializeField] private AudioSourceCollector audioSourceCollector = new AudioSourceCollector(); + [SerializeField] private AudioControlMethodCollector audioControlMethodCollector = new AudioControlMethodCollector(); + [SerializeField] private AudioClipCollector audioClipCollector = new AudioClipCollector(); + [SerializeField] private BoolCollector loopCollector = default; + [SerializeField] private BoolCollector rewindSameClipCollector = new BoolCollector(); + + private AudioSourceCollector AudioSourceCollector => audioSourceCollector; + private AudioControlMethodCollector AudioControlMethodCollector => audioControlMethodCollector; + private AudioClipCollector AudioClipCollector => audioClipCollector; + private BoolCollector LoopCollector => loopCollector; + private BoolCollector RewindSameClipCollector => rewindSameClipCollector; + + private void Awake() + { + BaseGameObject = gameObject; + } + + public override IObservable OnConnectAsObservable() + { + InvokeAudioSourceMethod(); + return ObservableFactory.ReturnMessage(this); + } + + private void InvokeAudioSourceMethod() + { + switch (AudioControlMethod) + { + case AudioControlMethod.Play: + if (!AudioSource.isPlaying || AudioSource.name != Key || RewindSameClip) + { + // Set key to AudioSource.name to compare name + AudioSource.name = Key; + AudioSource.clip = AudioClip; + AudioSource.loop = Loop; + AudioSource.Play(); + } + break; + case AudioControlMethod.Stop: + AudioSource.Stop(); + break; + case AudioControlMethod.Pause: + AudioSource.Pause(); + break; + case AudioControlMethod.UnPause: + AudioSource.UnPause(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(AudioSourceCollector, x => AudioSource = x), + CollectableMessageAnnotationFactory.Create(AudioControlMethodCollector, x => AudioControlMethod = x), + CollectableMessageAnnotationFactory.Create(AudioClipCollector, x => AudioClip = x), + CollectableMessageAnnotationFactory.Create(LoopCollector, x => Loop = x, nameof(Loop)), + CollectableMessageAnnotationFactory.Create(RewindSameClipCollector, x => RewindSameClip = x, nameof(RewindSameClip)), + }; + } +} diff --git a/Assets/Scripts/Connector/Complex/MusicPlayer.cs.meta b/Assets/Scripts/Connector/Complex/MusicPlayer.cs.meta new file mode 100644 index 0000000..859a5ed --- /dev/null +++ b/Assets/Scripts/Connector/Complex/MusicPlayer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 34df34cf51f94a0aa12b51e31348fc19 +timeCreated: 1571361660 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs b/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs new file mode 100644 index 0000000..580b4ae --- /dev/null +++ b/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Cysharp.Threading.Tasks; +using UniRx; +using UnityEngine; +using UnityEngine.Assertions; +using UnityEngine.UI; + +namespace UniFlow.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/NumberImageRenderer", (int) ConnectorType.Custom)] + public class NumberImageRenderer : ConnectorBase, INumberRenderer, IBaseGameObjectSpecifyable, IMessageCollectable, IMessageComposable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private int current = default; + [SerializeField] private GameObject digitPrefab = default; + [SerializeField] private float delaySeconds = default; + [SerializeField] private int delayFrames = default; + [SerializeField] private int minimumValue = 0; + [SerializeField] private int maximumValue = int.MaxValue; + [SerializeField] private List digitGameObjects = default; + [SerializeField] private List numberImages = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private int Current + { + get => current; + set => current = value; + } + private GameObject DigitPrefab + { + get => digitPrefab; + set => digitPrefab = value; + } + private float DelaySeconds + { + get => delaySeconds; + set => delaySeconds = value; + } + private int DelayFrames + { + get => delayFrames; + set => delayFrames = value; + } + private int MinimumValue + { + get => minimumValue; + set => minimumValue = value; + } + private int MaximumValue + { + get => maximumValue; + set => maximumValue = value; + } + private IList DigitGameObjects => digitGameObjects; + private IList NumberImages => numberImages; + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private IntCollector currentCollector = new IntCollector(); + [SerializeField] private GameObjectCollector digitPrefabCollector = new GameObjectCollector(); + [SerializeField] private FloatCollector delaySecondsCollector = new FloatCollector(); + [SerializeField] private IntCollector delayFramesCollector = new IntCollector(); + [SerializeField] private IntCollector minimumValueCollector = new IntCollector(); + [SerializeField] private IntCollector maximumValueCollector = new IntCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private IntCollector CurrentCollector => currentCollector; + private GameObjectCollector DigitPrefabCollector => digitPrefabCollector; + private FloatCollector DelaySecondsCollector => delaySecondsCollector; + private IntCollector DelayFramesCollector => delayFramesCollector; + private IntCollector MinimumValueCollector => minimumValueCollector; + private IntCollector MaximumValueCollector => maximumValueCollector; + + private ISubject OnRenderSubject { get; } = new Subject(); + + public override IObservable OnConnectAsObservable() + { + ((INumberRenderer) this).Render(Mathf.Clamp(Current, MinimumValue, MaximumValue)); + return OnRenderSubject.AsMessageObservable(this, "Current"); + } + + void INumberRenderer.Render(int number) + { + Assert.AreEqual(10, NumberImages.Count); + + RenderAsync(number).Forget(); + } + + private async UniTask RenderAsync(int number) + { + var splittedDigits = SplitDigits(number).Reverse().ToList(); + + if (DigitPrefab == default && DigitGameObjects.Any()) + { + DigitPrefab = DigitGameObjects[0]; + } + + if (DelaySeconds > 0.0f) + { + await UniTask.Delay(TimeSpan.FromSeconds(DelaySeconds)); + } + + if (DelayFrames > 0) + { + await UniTask.DelayFrame(DelayFrames); + } + + while (splittedDigits.Count > DigitGameObjects.Count) + { + DigitGameObjects.Add(Instantiate(DigitPrefab, this.DeterminateTransform())); + } + + foreach (var (n, d) in splittedDigits.Select((x, d) => (number: x, digit: d))) + { + DigitGameObjects[d].GetOrAddComponent().sprite = NumberImages[n]; + } + + OnRenderSubject.OnNext(number); + } + + private static IEnumerable SplitDigits(int number) + { + IList result = new List(); + do + { + result.Add(number % 10); + number /= 10; + } while (number > 0); + + return result; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(CurrentCollector, x => Current = x, nameof(Current)), + CollectableMessageAnnotationFactory.Create(DigitPrefabCollector, x => DigitPrefab = x, nameof(DigitPrefab)), + CollectableMessageAnnotationFactory.Create(DelaySecondsCollector, x => DelaySeconds = x, nameof(DelaySeconds)), + CollectableMessageAnnotationFactory.Create(DelayFramesCollector, x => DelayFrames = x, nameof(DelayFrames)), + CollectableMessageAnnotationFactory.Create(MinimumValueCollector, x => MinimumValue = x, nameof(MinimumValue)), + CollectableMessageAnnotationFactory.Create(MaximumValueCollector, x => MaximumValue = x, nameof(MaximumValue)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(null, "Current"), + }; + } + + public interface INumberRenderer + { + void Render(int number); + } +} diff --git a/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs.meta b/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs.meta new file mode 100644 index 0000000..fad2d1c --- /dev/null +++ b/Assets/Scripts/Connector/Complex/NumberImageRenderer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 11d224f4a7944dfcb60777ab8d3cc64a +timeCreated: 1571343186 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs b/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs new file mode 100644 index 0000000..e98bbcc --- /dev/null +++ b/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using UniFlow; +using UniFlow.Utility; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace PretendLand.Edwin.Scripts.Connector.Complex +{ + [AddComponentMenu("UniFlow/Complex/ProgressiveTimer", (int) ConnectorType.ProgressiveTimer)] + public class ProgressiveTimer : ConnectorBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private float seconds = default; + [SerializeField] private ProgressDirection direction = default; + private float Seconds + { + get => seconds; + set => seconds = value; + } + private ProgressDirection Direction => direction; + + [SerializeField] private FloatCollector secondsCollector = new FloatCollector(); + private FloatCollector SecondsCollector => secondsCollector; + + private IObservable ProgressObservable { get; set; } + private float ProceedTime { get; set; } = 0.0f; + + public override IObservable OnConnectAsObservable() + { + var observable = this.UpdateAsObservable().TakeUntil(Observable.Timer(TimeSpan.FromSeconds(Seconds))).Share(); + observable.Subscribe(_ => ProceedTime += Time.deltaTime); + switch (Direction) + { + case ProgressDirection.Increase: + ProgressObservable = observable.Select(_ => ProceedTime / Seconds); + break; + case ProgressDirection.Decrease: + ProgressObservable = observable.Select(_ => 1.0f - ProceedTime / Seconds); + break; + default: + throw new ArgumentOutOfRangeException(); + } + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SecondsCollector, x => Seconds = x, nameof(Seconds)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => ProgressObservable, nameof(ProgressObservable)), + }; + + private enum ProgressDirection + { + Increase, + Decrease, + } + } +} diff --git a/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs.meta b/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs.meta new file mode 100644 index 0000000..3774fc9 --- /dev/null +++ b/Assets/Scripts/Connector/Complex/ProgressiveTimer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b4f05fb08b6d4e3091c784268cd55968 +timeCreated: 1571625934 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller.meta b/Assets/Scripts/Connector/Controller.meta new file mode 100644 index 0000000..2d7dd02 --- /dev/null +++ b/Assets/Scripts/Connector/Controller.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 475ae112d7c244e68f088ad2ccf34fff +timeCreated: 1567260047 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/ActivationController.cs b/Assets/Scripts/Connector/Controller/ActivationController.cs new file mode 100644 index 0000000..359b5b0 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/ActivationController.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/ActivationController", (int) ConnectorType.LoadScene)] + public class ActivationController : ConnectorBase, + IMessageCollectable + { + [SerializeField] private List targetGameObjects = default; + [SerializeField] private List targetBehaviours = default; + [SerializeField] private bool activated = default; + + [UsedImplicitly] public IList GameObjects + { + get => targetGameObjects; + set => targetGameObjects = value.ToList(); + } + [UsedImplicitly] public IList Behaviours + { + get => targetBehaviours; + set => targetBehaviours = value.ToList(); + } + public GameObject TargetGameObject + { + set => GameObjects.Add(value); + } + private Behaviour TargetBehaviour + { + set => Behaviours.Add(value); + } + private bool Activated + { + get => activated; + set => activated = value; + } + + [SerializeField] private BoolCollector activatedCollector = new BoolCollector(); + [SerializeField] private GameObjectCollector targetGameObjectCollector = new GameObjectCollector(); + [SerializeField] private BehaviourCollector targetBehaviourCollector = new BehaviourCollector(); + + private BoolCollector ActivatedCollector => activatedCollector; + private GameObjectCollector TargetGameObjectCollector => targetGameObjectCollector; + private BehaviourCollector TargetBehaviourCollector => targetBehaviourCollector; + + public override IObservable OnConnectAsObservable() + { + var gameObjects = GameObjects.Where(x => x.activeSelf != Activated).ToList(); + gameObjects.ForEach(x => x.SetActive(Activated)); + var monoBehaviours = Behaviours.Where(x => x.enabled != Activated).ToList(); + monoBehaviours.ForEach(x => x.enabled = Activated); + + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ActivatedCollector, x => Activated = x, nameof(Activated)), + CollectableMessageAnnotationFactory.Create(TargetGameObjectCollector, x => TargetGameObject = x, nameof(TargetGameObject)), + CollectableMessageAnnotationFactory.Create(TargetBehaviourCollector, x => TargetBehaviour = x, nameof(TargetBehaviour)), + }; + } +} diff --git a/Assets/Scripts/Connector/Controller/ActivationController.cs.meta b/Assets/Scripts/Connector/Controller/ActivationController.cs.meta new file mode 100644 index 0000000..b022e7b --- /dev/null +++ b/Assets/Scripts/Connector/Controller/ActivationController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d5dc990cbe0e4a4fbdff5998e2bcffad +timeCreated: 1567400525 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/AnimatorTrigger.cs b/Assets/Scripts/Connector/Controller/AnimatorTrigger.cs new file mode 100644 index 0000000..ee6ea8f --- /dev/null +++ b/Assets/Scripts/Connector/Controller/AnimatorTrigger.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/AnimatorTrigger", (int) ConnectorType.AnimatorTrigger)] + public class AnimatorTrigger : ConnectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] + [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] + private Animator animator = default; + [SerializeField] private string triggerName = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + public Animator Animator + { + get => animator ? animator : animator = this.GetOrAddComponent(); + private set => animator = value; + } + private string TriggerName + { + get => triggerName; + set => triggerName = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AnimatorCollector animatorCollector = new AnimatorCollector(); + [SerializeField] private StringCollector triggerNameCollector = new StringCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AnimatorCollector AnimatorCollector => animatorCollector; + private StringCollector TriggerNameCollector => triggerNameCollector; + + private int TriggerId => Animator.StringToHash(TriggerName); + + public override IObservable OnConnectAsObservable() + { + Animator.SetTrigger(TriggerId); + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AnimatorCollector, x => Animator = x), + CollectableMessageAnnotationFactory.Create(TriggerNameCollector, x => TriggerName = x, nameof(TriggerName)), + }; + } +} diff --git a/Assets/Scripts/Connector/AnimatorTrigger.cs.meta b/Assets/Scripts/Connector/Controller/AnimatorTrigger.cs.meta similarity index 100% rename from Assets/Scripts/Connector/AnimatorTrigger.cs.meta rename to Assets/Scripts/Connector/Controller/AnimatorTrigger.cs.meta diff --git a/Assets/Scripts/Connector/Controller/AudioController.cs b/Assets/Scripts/Connector/Controller/AudioController.cs new file mode 100644 index 0000000..410bbe3 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/AudioController.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/AudioController", (int) ConnectorType.AudioController)] + public class AudioController : ConnectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private AudioSource audioSource = default; + [SerializeField] private AudioControlMethod audioControlMethod = AudioControlMethod.Play; + [SerializeField] + [Tooltip("If you do not specify it will be obtained by AudioSource.clip")] + private AudioClip audioClip = default; + [SerializeField] private bool loop = default; + [SerializeField] private bool ignorePlayWhenPlaying = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + public AudioSource AudioSource + { + get => audioSource != default ? audioSource : audioSource = this.GetOrAddComponent(); + private set => audioSource = value; + } + private AudioControlMethod AudioControlMethod => audioControlMethod; + private AudioClip AudioClip + { + get => audioClip; + set => audioClip = value; + } + private bool Loop + { + get => loop; + set => loop = value; + } + private bool IgnorePlayWhenPlaying + { + get => ignorePlayWhenPlaying; + set => ignorePlayWhenPlaying = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AudioSourceCollector audioSourceCollector = new AudioSourceCollector(); + [SerializeField] private AudioClipCollector audioClipCollector = new AudioClipCollector(); + [SerializeField] private BoolCollector loopCollector = default; + [SerializeField] private BoolCollector ignorePlayWhenPlayingCollector = new BoolCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AudioSourceCollector AudioSourceCollector => audioSourceCollector; + private AudioClipCollector AudioClipCollector => audioClipCollector; + private BoolCollector LoopCollector => loopCollector; + private BoolCollector IgnorePlayWhenPlayingCollector => ignorePlayWhenPlayingCollector; + + public override IObservable OnConnectAsObservable() + { + InvokeAudioSourceMethod(); + return ObservableFactory.ReturnMessage(this); + } + + private void InvokeAudioSourceMethod() + { + if (AudioClip != default) + { + AudioSource.playOnAwake = false; + AudioSource.loop = Loop; + AudioSource.clip = AudioClip; + } + + switch (AudioControlMethod) + { + case AudioControlMethod.Play: + if (!IgnorePlayWhenPlaying || !AudioSource.isPlaying) + { + AudioSource.Play(); + } + break; + case AudioControlMethod.Stop: + AudioSource.Stop(); + break; + case AudioControlMethod.Pause: + AudioSource.Pause(); + break; + case AudioControlMethod.UnPause: + AudioSource.UnPause(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AudioSourceCollector, x => AudioSource = x), + CollectableMessageAnnotationFactory.Create(AudioClipCollector, x => AudioClip = x), + CollectableMessageAnnotationFactory.Create(LoopCollector, x => Loop = x, nameof(Loop)), + CollectableMessageAnnotationFactory.Create(IgnorePlayWhenPlayingCollector, x => IgnorePlayWhenPlaying = x, nameof(IgnorePlayWhenPlaying)), + }; + } + + public enum AudioControlMethod + { + Play, + Stop, + Pause, + UnPause, + } + + [Serializable] + public class AudioControlMethodCollector : ValueCollectorBase + { + } +} diff --git a/Assets/Scripts/Connector/AudioController.cs.meta b/Assets/Scripts/Connector/Controller/AudioController.cs.meta similarity index 100% rename from Assets/Scripts/Connector/AudioController.cs.meta rename to Assets/Scripts/Connector/Controller/AudioController.cs.meta diff --git a/Assets/Scripts/Connector/Controller/DestroyInstance.cs b/Assets/Scripts/Connector/Controller/DestroyInstance.cs new file mode 100644 index 0000000..70a9ce9 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/DestroyInstance.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniFlow.Utility; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/DestroyInstance", (int) ConnectorType.LoadScene)] + public class DestroyInstance : ConnectorBase, IMessageCollectable + { + [SerializeField] private List objects = new List(); + + [UsedImplicitly] public IList Objects + { + get => objects; + set => objects = value.ToList(); + } + + [SerializeField] private ObjectCollector objectCollector = new ObjectCollector(); + private ObjectCollector ObjectCollector => objectCollector; + + public override IObservable OnConnectAsObservable() + { + Objects.ToList().ForEach(Destroy); + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ObjectCollector, Objects.Add, "Object"), + }; + } +} diff --git a/Assets/Scripts/Connector/Controller/DestroyInstance.cs.meta b/Assets/Scripts/Connector/Controller/DestroyInstance.cs.meta new file mode 100644 index 0000000..d395eeb --- /dev/null +++ b/Assets/Scripts/Connector/Controller/DestroyInstance.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9a5167253986443d8edd6044e4750f02 +timeCreated: 1567400626 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs b/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs new file mode 100644 index 0000000..972dcda --- /dev/null +++ b/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs @@ -0,0 +1,16 @@ +using System; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/DontDestroyOnLoad", (int) ConnectorType.DontDestroyOnLoad)] + public class DontDestroyOnLoad : ConnectorBase + { + public override IObservable OnConnectAsObservable() + { + DontDestroyOnLoad(gameObject); + return ObservableFactory.ReturnMessage(this); + } + } +} diff --git a/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs.meta b/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs.meta new file mode 100644 index 0000000..7602f5e --- /dev/null +++ b/Assets/Scripts/Connector/Controller/DontDestroyOnLoad.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 100966f39e2146ff83ae6ecb77a56174 +timeCreated: 1570026181 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/EventHandlingController.cs b/Assets/Scripts/Connector/Controller/EventHandlingController.cs new file mode 100644 index 0000000..6aa3000 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/EventHandlingController.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using KeyEventHandler; +using UniFlow.Utility; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/EventHandlingController", (int) ConnectorType.EventHandlingController)] + public class EventHandlingController : ConnectorBase + { + [SerializeField] private EventHandlingControlMethod eventHandlingControlMethod = EventHandlingControlMethod.Activate; + [SerializeField] private List raycasters = default; + [SerializeField] private List keyEventLayers = default; + [SerializeField] private List graphics = default; + [SerializeField] private List colliders = default; + [SerializeField] private List collider2Ds = default; + [SerializeField] private List canvasGroups = default; + + [UsedImplicitly] private EventHandlingControlMethod EventHandlingControlMethod + { + get => eventHandlingControlMethod; + set => eventHandlingControlMethod = value; + } + [UsedImplicitly] private IEnumerable Raycasters + { + get => raycasters; + set => raycasters = value.ToList(); + } + [UsedImplicitly] private IEnumerable KeyEventLayers + { + get => keyEventLayers; + set => keyEventLayers = value.ToList(); + } + [UsedImplicitly] public IEnumerable Graphics + { + get => graphics; + set => graphics = value.ToList(); + } + [UsedImplicitly] public IEnumerable Colliders + { + get => colliders; + set => colliders = value.ToList(); + } + [UsedImplicitly] public IEnumerable Collider2Ds + { + get => collider2Ds; + set => collider2Ds = value.ToList(); + } + [UsedImplicitly] public IEnumerable CanvasGroups + { + get => canvasGroups; + set => canvasGroups = value.ToList(); + } + + public override IObservable OnConnectAsObservable() + { + HandleActivation(); + return ObservableFactory.ReturnMessage(this); + } + + private void HandleActivation() + { + var activate = EventHandlingControlMethod == EventHandlingControlMethod.Activate; + Raycasters.Where(x => x.enabled != activate).ToList().ForEach(x => x.enabled = activate); + KeyEventLayers.Where(x => x.enabled != activate).ToList().ForEach(x => x.enabled = activate); + Graphics.Where(x => x.raycastTarget != activate).ToList().ForEach(x => x.raycastTarget = activate); + Colliders.Where(x => x.enabled != activate).ToList().ForEach(x => x.enabled = activate); + Collider2Ds.Where(x => x.enabled != activate).ToList().ForEach(x => x.enabled = activate); + CanvasGroups.Where(x => x.blocksRaycasts != activate).ToList().ForEach(x => x.blocksRaycasts = activate); + } + } + + [PublicAPI] + public enum EventHandlingControlMethod + { + Activate, + Deactivate, + } +} diff --git a/Assets/Scripts/Connector/Controller/EventHandlingController.cs.meta b/Assets/Scripts/Connector/Controller/EventHandlingController.cs.meta new file mode 100644 index 0000000..331abfd --- /dev/null +++ b/Assets/Scripts/Connector/Controller/EventHandlingController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d57eab21d8ce4b0fac9fce7c95bd83ee +timeCreated: 1573732913 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs b/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs new file mode 100644 index 0000000..9a19887 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs @@ -0,0 +1,68 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/InstantiateGameObject", (int) ConnectorType.InstantiateGameObject)] + public class InstantiateGameObject : ConnectorBase, + IMessageCollectable, + IMessageComposable + { + [SerializeField] private GameObject source = default; + [SerializeField] private Transform parent = default; + + public GameObject Source + { + get => source == default ? gameObject : source; + private set => source = value; + } + private Transform Parent + { + get => parent == default ? transform : parent; + set => parent = value; + } + + [SerializeField] private GameObjectCollector sourceCollector = new GameObjectCollector(); + [SerializeField] private TransformCollector parentCollector = new TransformCollector(); + + private GameObjectCollector SourceCollector => sourceCollector; + private TransformCollector ParentCollector => parentCollector; + + protected GameObject Instantiated { get; set; } + + [Inject] private DiContainer DiContainer { get; } + + public override IObservable OnConnectAsObservable() + { + Instantiated = DiContainer.InstantiatePrefab(Source, Parent); + return ObservableFactory.ReturnMessage(this, nameof(Instantiated), Instantiated); + } + + protected override IEnumerable MergeMessageCollectableAnnotations() => + base.MergeMessageCollectableAnnotations() + .Concat( + new[] + { + CollectableMessageAnnotationFactory.Create(SourceCollector, x => Source = x, nameof(Source)), + CollectableMessageAnnotationFactory.Create(ParentCollector, x => Parent = x, nameof(Parent)), + } + ); + + protected override IEnumerable MergeMessageComposableAnnotations() => + base.MergeMessageComposableAnnotations() + .Concat( + new[] + { + ComposableMessageAnnotationFactory.Create(nameof(Instantiated)), + } + ); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => MergeMessageCollectableAnnotations(); + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => MergeMessageComposableAnnotations(); + } +} diff --git a/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs.meta b/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs.meta new file mode 100644 index 0000000..871d0b0 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/InstantiateGameObject.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9d96a435a8d74b1a8c60ffea57ac84fa +timeCreated: 1568130173 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs b/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs new file mode 100644 index 0000000..4a9f4d2 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + public abstract class InstantiateGameObjectWithInjectionBase : ConnectorBase, + IMessageCollectable, + IMessageComposable + { + [SerializeField] private GameObject source = default; + [SerializeField] private Transform parent = default; + + private GameObject Source + { + get => source == default ? gameObject : source; + set => source = value; + } + + private Transform Parent + { + get => parent == default ? transform : parent; + set => parent = value; + } + + [SerializeField] private GameObjectCollector sourceCollector = new GameObjectCollector(); + [SerializeField] private TransformCollector parentCollector = new TransformCollector(); + + private GameObjectCollector SourceCollector => sourceCollector; + private TransformCollector ParentCollector => parentCollector; + + private GameObject Instantiated { get; set; } + + [Inject] private DiContainer DiContainer { get; } + + public override IObservable OnConnectAsObservable() + { + Instantiated = DiContainer.InstantiatePrefab(Source, Parent); + GetMessageCollectableAnnotations().ToList().ForEach(x => x.Inject(Instantiated)); + return ObservableFactory.ReturnMessage(this); + } + + protected virtual IEnumerable GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SourceCollector, x => Source = x, nameof(Source)), + CollectableMessageAnnotationFactory.Create(ParentCollector, x => Parent = x, nameof(Parent)), + }; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + GetMessageCollectableAnnotations(); + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Instantiated), + }; + } +} diff --git a/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs.meta b/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs.meta new file mode 100644 index 0000000..840a211 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/InstantiateGameObjectWithInjectionBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1b2ad0b7623049c8b7bf4f3707bdbb8b +timeCreated: 1571233445 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/LoadScene.cs b/Assets/Scripts/Connector/Controller/LoadScene.cs new file mode 100644 index 0000000..aaf092f --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadScene.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/LoadScene", (int) ConnectorType.LoadScene)] + public class LoadScene : LoadSceneBase + { + [SerializeField] private List sceneNames = default; + + [UsedImplicitly] public override IEnumerable SceneNames + { + get => sceneNames; + set => sceneNames = value.ToList(); + } + } +} diff --git a/Assets/Scripts/Connector/Controller/LoadScene.cs.meta b/Assets/Scripts/Connector/Controller/LoadScene.cs.meta new file mode 100644 index 0000000..c53112a --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadScene.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 28abb11fbf954db080cb858d39c542f7 +timeCreated: 1565249834 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/LoadSceneBase.cs b/Assets/Scripts/Connector/Controller/LoadSceneBase.cs new file mode 100644 index 0000000..ad03f77 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadSceneBase.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using JetBrains.Annotations; +using UniRx; +using UnityEngine.SceneManagement; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + public abstract class LoadSceneBase : ConnectorBase + { + [UsedImplicitly] + public abstract IEnumerable SceneNames { get; set; } + + [InjectOptional] private AsyncLoadSceneDelegate AsyncLoadSceneDelegate { get; } = DefaultAsyncLoadScene; + + public override IObservable OnConnectAsObservable() + { + return AsyncLoadSceneDelegate(SceneNames) + .ToObservable() + .Select(this.CreateMessage); + } + + private static async UniTask DefaultAsyncLoadScene(IEnumerable sceneNames) + { + foreach (var sceneName in sceneNames) + { + await SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Additive); + } + } + } + + public delegate UniTask AsyncLoadSceneDelegate(IEnumerable sceneNames); +} diff --git a/Assets/Scripts/Connector/Controller/LoadSceneBase.cs.meta b/Assets/Scripts/Connector/Controller/LoadSceneBase.cs.meta new file mode 100644 index 0000000..7f1b32a --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadSceneBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 66350073e5a24e02b6106711d805b3da +timeCreated: 1568896106 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs b/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs new file mode 100644 index 0000000..89442dc --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using JetBrains.Annotations; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + public abstract class LoadSceneEnumBase : LoadSceneBase where TSceneName : Enum + { + [SerializeField] private List sceneNames = default; + + [InjectOptional(Id = InjectId.SceneNamePrefix)] private string SceneNamePrefix { get; } + + [UsedImplicitly] public override IEnumerable SceneNames + { + get => sceneNames.Select(x => $"{SceneNamePrefix}{x.ToString()}"); + set => sceneNames = value + .Select( + x => (TSceneName) Enum + .Parse( + typeof(TSceneName), + Regex.Replace(x, $"^{SceneNamePrefix}", string.Empty) + ) + ) + .ToList(); + } + } +} diff --git a/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs.meta b/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs.meta new file mode 100644 index 0000000..dc67245 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/LoadSceneEnumBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 557a18adcc3446dfa1cea49dd2800a06 +timeCreated: 1568895941 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/MoveParentTransform.cs b/Assets/Scripts/Connector/Controller/MoveParentTransform.cs new file mode 100644 index 0000000..3e50855 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/MoveParentTransform.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/MoveParentTransform", (int) ConnectorType.MoveParentTransform)] + public class MoveParentTransform : ConnectorBase, + IMessageCollectable + { + // ReSharper disable once InconsistentNaming + [SerializeField] private Transform targetTransform = default; + [SerializeField] private Transform parentTransform = default; + [SerializeField] private bool worldPositionStays = true; + + private Transform TargetTransform + { + get => targetTransform != default + ? targetTransform + : targetTransform = transform; + set => targetTransform = value; + } + private Transform ParentTransform + { + get => parentTransform; + set => parentTransform = value; + } + private bool WorldPositionStays + { + get => worldPositionStays; + set => worldPositionStays = value; + } + + [SerializeField] private TransformCollector targetTransformCollector = new TransformCollector(); + [SerializeField] private TransformCollector parentTransformCollector = new TransformCollector(); + [SerializeField] private BoolCollector worldPositionStaysCollector = new BoolCollector(); + + private TransformCollector TargetTransformCollector => targetTransformCollector; + private TransformCollector ParentTransformCollector => parentTransformCollector; + private BoolCollector WorldPositionStaysCollector => worldPositionStaysCollector; + + public override IObservable OnConnectAsObservable() + { + TargetTransform.SetParent(ParentTransform, WorldPositionStays); + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(TargetTransformCollector, x => TargetTransform = x, nameof(TargetTransform)), + CollectableMessageAnnotationFactory.Create(ParentTransformCollector, x => ParentTransform = x, nameof(ParentTransform)), + CollectableMessageAnnotationFactory.Create(WorldPositionStaysCollector, x => WorldPositionStays = x, nameof(WorldPositionStays)), + }; + } +} diff --git a/Assets/Scripts/Connector/Controller/MoveParentTransform.cs.meta b/Assets/Scripts/Connector/Controller/MoveParentTransform.cs.meta new file mode 100644 index 0000000..ff4ddba --- /dev/null +++ b/Assets/Scripts/Connector/Controller/MoveParentTransform.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9a52a20b5ede4c8ca6a5debe9b19c80b +timeCreated: 1566463259 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/PlayableController.cs b/Assets/Scripts/Connector/Controller/PlayableController.cs new file mode 100644 index 0000000..0e0f587 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/PlayableController.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/PlayableController", (int) ConnectorType.PlayableController)] + public class PlayableController : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private PlayableDirector playableDirector = default; + [SerializeField] private PlayableControlMethod playableControlMethod = PlayableControlMethod.Play; + [SerializeField] private TimelineAsset timelineAsset = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + + public PlayableDirector PlayableDirector + { + get => playableDirector != default ? playableDirector : playableDirector = this.GetOrAddComponent(); + private set => playableDirector = value; + } + private PlayableControlMethod PlayableControlMethod => playableControlMethod; + private TimelineAsset TimelineAsset + { + get => timelineAsset; + set => timelineAsset = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private PlayableDirectorCollector playableDirectorCollector = new PlayableDirectorCollector(); + [SerializeField] private TimelineAssetCollector timelineAssetCollector = new TimelineAssetCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private PlayableDirectorCollector PlayableDirectorCollector => playableDirectorCollector; + private TimelineAssetCollector TimelineAssetCollector => timelineAssetCollector; + + public override IObservable OnConnectAsObservable() + { + PreparePlayableDirector(); + InvokePlayableDirectorMethod(); + return ObservableFactory.ReturnMessage(this); + } + + private void PreparePlayableDirector() + { + if (PlayableDirector != default && TimelineAsset != default) + { + PlayableDirector.playableAsset = TimelineAsset; + } + } + + private void InvokePlayableDirectorMethod() + { + + switch (PlayableControlMethod) + { + case PlayableControlMethod.Play: + PlayableDirector.time = 0; + PlayableDirector.Play(); + break; + case PlayableControlMethod.Stop: + PlayableDirector.Stop(); + break; + case PlayableControlMethod.Pause: + PlayableDirector.Pause(); + break; + case PlayableControlMethod.Resume: + PlayableDirector.Resume(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PlayableDirectorCollector, x => PlayableDirector = x), + CollectableMessageAnnotationFactory.Create(TimelineAssetCollector, x => TimelineAsset = x), + }; + } + + public enum PlayableControlMethod + { + Play, + Stop, + Pause, + Resume, + } +} diff --git a/Assets/Scripts/Connector/PlayableController.cs.meta b/Assets/Scripts/Connector/Controller/PlayableController.cs.meta similarity index 100% rename from Assets/Scripts/Connector/PlayableController.cs.meta rename to Assets/Scripts/Connector/Controller/PlayableController.cs.meta diff --git a/Assets/Scripts/Connector/Controller/RaycastTargetController.cs b/Assets/Scripts/Connector/Controller/RaycastTargetController.cs new file mode 100644 index 0000000..a55f09a --- /dev/null +++ b/Assets/Scripts/Connector/Controller/RaycastTargetController.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniFlow.Utility; +using UniRx; +using UnityEngine; +using UnityEngine.UI; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/RaycastTargetController", (int) ConnectorType.RaycastTargetController)] + public class RaycastTargetController : ConnectorBase + { + [SerializeField] private RaycastTargetControlMethod raycastTargetControlMethod = RaycastTargetControlMethod.Activate; + [SerializeField] private List graphics = default; + [SerializeField] private List colliders = default; + [SerializeField] private List collider2Ds = default; + [SerializeField] private List canvasGroups = default; + + [UsedImplicitly] private RaycastTargetControlMethod RaycastTargetControlMethod + { + get => raycastTargetControlMethod; + set => raycastTargetControlMethod = value; + } + [UsedImplicitly] public IEnumerable Graphics + { + get => graphics; + set => graphics = value.ToList(); + } + [UsedImplicitly] public IEnumerable Colliders + { + get => colliders; + set => colliders = value.ToList(); + } + [UsedImplicitly] public IEnumerable Collider2Ds + { + get => collider2Ds; + set => collider2Ds = value.ToList(); + } + [UsedImplicitly] public IEnumerable CanvasGroups + { + get => canvasGroups; + set => canvasGroups = value.ToList(); + } + + private IDisposable Disposable { get; } = new CompositeDisposable(); + + public override IObservable OnConnectAsObservable() + { + HandleActivation(); + return ObservableFactory.ReturnMessage(this); + } + + private void HandleActivation() + { + var handleTargets = new Action[0] + .Concat( + Graphics + .Where(x => x.raycastTarget != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.raycastTarget = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + Colliders + .Where(x => x.enabled != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.enabled = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + Collider2Ds + .Where(x => x.enabled != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.enabled = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + CanvasGroups + .Where(x => x.blocksRaycasts != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.blocksRaycasts = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + GetComponents() + .Where(x => x.raycastTarget != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.raycastTarget = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + GetComponents() + .Where(x => x.enabled != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.enabled = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + GetComponents() + .Where(x => x.enabled != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.enabled = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .Concat( + GetComponents() + .Where(x => x.blocksRaycasts != (RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + .Select(x => new Action(() => x.blocksRaycasts = RaycastTargetControlMethod == RaycastTargetControlMethod.Activate)) + ) + .ToList(); + handleTargets.ForEach(x => x.Invoke()); + } + + private void OnDestroy() + { + Disposable.Dispose(); + } + } + + [PublicAPI] + public enum RaycastTargetControlMethod + { + Activate, + Deactivate, + } +} diff --git a/Assets/Scripts/Connector/Controller/RaycastTargetController.cs.meta b/Assets/Scripts/Connector/Controller/RaycastTargetController.cs.meta new file mode 100644 index 0000000..bb2a3e0 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/RaycastTargetController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: feefc9c6f64c4f74b9dcdc3462b2243d +timeCreated: 1566464568 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/RaycasterController.cs b/Assets/Scripts/Connector/Controller/RaycasterController.cs new file mode 100644 index 0000000..7c907e2 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/RaycasterController.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniFlow.Utility; +using UnityEngine; +using UnityEngine.EventSystems; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/RaycasterController", (int) ConnectorType.RaycasterController)] + public class RaycasterController : ConnectorBase + { + [SerializeField] private RaycasterControlMethod raycasterControlMethod = RaycasterControlMethod.Activate; + [SerializeField] private List raycasters = default; + + [UsedImplicitly] private RaycasterControlMethod RaycasterControlMethod + { + get => raycasterControlMethod; + set => raycasterControlMethod = value; + } + [UsedImplicitly] private IEnumerable Raycasters + { + get => raycasters; + set => raycasters = value.ToList(); + } + + public override IObservable OnConnectAsObservable() + { + HandleActivation(); + return ObservableFactory.ReturnMessage(this); + } + + private void HandleActivation() + { + var targets = Raycasters.Where(x => x.enabled != (RaycasterControlMethod == RaycasterControlMethod.Activate)).ToList(); + targets.ForEach(x => x.enabled = RaycasterControlMethod == RaycasterControlMethod.Activate); + } + } + + [PublicAPI] + public enum RaycasterControlMethod + { + Activate, + Deactivate, + } +} diff --git a/Assets/Scripts/Connector/Controller/RaycasterController.cs.meta b/Assets/Scripts/Connector/Controller/RaycasterController.cs.meta new file mode 100644 index 0000000..4d809f9 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/RaycasterController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 310968de5ced47a1ab75a25d6e50732a +timeCreated: 1566216860 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs b/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs new file mode 100644 index 0000000..ee47701 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs @@ -0,0 +1,149 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/SimpleAnimationController", (int) ConnectorType.SimpleAnimationController)] + public class SimpleAnimationController : ConnectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private Animator animator = default; + [SerializeField] private SimpleAnimation simpleAnimation = default; + [SerializeField] private SimpleAnimationControlMethod simpleAnimationControlMethod = SimpleAnimationControlMethod.Play; + [SerializeField] + [Tooltip("If you do not specify it will be used SimpleAnimation setting")] + private AnimationClip animationClip = default; + [SerializeField] private AnimatorCullingMode cullingMode = AnimatorCullingMode.AlwaysAnimate; + [SerializeField] private AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private Animator Animator + { + get => animator != default ? animator : animator = this.GetOrAddComponent(); + set => animator = value; + } + public SimpleAnimation SimpleAnimation + { + get => + simpleAnimation != default + ? simpleAnimation + : simpleAnimation = + Animator.GetComponent() != default + ? Animator.GetComponent() + : Animator.gameObject.AddComponent() + ; + private set => simpleAnimation = value; + } + private SimpleAnimationControlMethod SimpleAnimationControlMethod => simpleAnimationControlMethod; + private AnimationClip AnimationClip + { + get => animationClip; + set => animationClip = value; + } + private AnimatorCullingMode CullingMode => cullingMode; + private AnimatorUpdateMode UpdateMode => updateMode; + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AnimatorCollector animatorCollector = new AnimatorCollector(); + [SerializeField] private SimpleAnimationCollector simpleAnimationCollector = new SimpleAnimationCollector(); + [SerializeField] private AnimationClipCollector animationClipCollector = new AnimationClipCollector(); + // TODO: Implement EnumCollector + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AnimatorCollector AnimatorCollector => animatorCollector; + private SimpleAnimationCollector SimpleAnimationCollector => simpleAnimationCollector; + private AnimationClipCollector AnimationClipCollector => animationClipCollector; + + private IDisposable Disposable { get; } = new CompositeDisposable(); + + public override IObservable OnConnectAsObservable() + { + PrepareSimpleAnimation(); + InvokeSimpleAnimationMethod(); + return ObservableFactory.ReturnMessage(this); + } + + private void PrepareSimpleAnimation() + { + // ReSharper disable once InvertIf + // Automatic add components Animator and SimpleAnimation if AudioClip specified and Animator component does not exists. + if (AnimationClip != default && Animator != default && SimpleAnimation.GetStates().All(x => x.clip != AnimationClip)) + { + SimpleAnimation.AddClip(AnimationClip, AnimationClip.GetInstanceID().ToString()); + SimpleAnimation.cullingMode = CullingMode; + SimpleAnimation.playAutomatically = false; + Animator.updateMode = UpdateMode; + } + } + + private void InvokeSimpleAnimationMethod() + { + switch (SimpleAnimationControlMethod) + { + case SimpleAnimationControlMethod.Play: + if (AnimationClip == default) + { + SimpleAnimation.Rewind(); + SimpleAnimation.Play(); + } + else + { + SimpleAnimation.Rewind(AnimationClip.GetInstanceID().ToString()); + SimpleAnimation.Play(AnimationClip.GetInstanceID().ToString()); + } + break; + case SimpleAnimationControlMethod.Stop: + if (AnimationClip == default) + { + SimpleAnimation.Stop(); + } + else + { + SimpleAnimation.Stop(AnimationClip.GetInstanceID().ToString()); + } + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + + private void OnDestroy() + { + Disposable.Dispose(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AnimatorCollector, x => Animator = x), + CollectableMessageAnnotationFactory.Create(SimpleAnimationCollector, x => SimpleAnimation = x), + CollectableMessageAnnotationFactory.Create(AnimationClipCollector, x => AnimationClip = x), + }; + } + + public enum SimpleAnimationControlMethod + { + Play, + Stop, + } +} diff --git a/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs.meta b/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs.meta new file mode 100644 index 0000000..86f36ec --- /dev/null +++ b/Assets/Scripts/Connector/Controller/SimpleAnimationController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e354102254874aecbac12539fc4505b3 +timeCreated: 1565255438 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/TimeScaleController.cs b/Assets/Scripts/Connector/Controller/TimeScaleController.cs new file mode 100644 index 0000000..4601bea --- /dev/null +++ b/Assets/Scripts/Connector/Controller/TimeScaleController.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/TimeScaleController", (int) ConnectorType.TimeScaleController)] + public class TimeScaleController : ConnectorBase, IMessageCollectable + { + [SerializeField] private float timeScale = default; + [SerializeField] private float duration = default; + [SerializeField] private ObservableTween.EaseType easeType = default; + + private float TimeScale + { + get => timeScale; + set => timeScale = value; + } + private float Duration + { + get => duration; + set => duration = value; + } + private ObservableTween.EaseType EaseType + { + get => easeType; + set => easeType = value; + } + + [SerializeField] private FloatCollector timeScaleCollector = new FloatCollector(); + [SerializeField] private FloatCollector durationCollector = new FloatCollector(); + [SerializeField] private EaseTypeCollector easeTypeCollector = new EaseTypeCollector(); + + private FloatCollector TimeScaleCollector => timeScaleCollector; + private FloatCollector DurationCollector => durationCollector; + private EaseTypeCollector EaseTypeCollector => easeTypeCollector; + + private ISubject OnCompleteTweenSubject { get; } = new Subject(); + + public override IObservable OnConnectAsObservable() + { + ChangeTimeScale(); + return OnCompleteTweenSubject.Select(this.CreateMessage); + } + + private void ChangeTimeScale() + { + if (Mathf.Approximately(0.0f, Duration)) + { + Time.timeScale = TimeScale; + OnCompleteTweenSubject.OnNext(Unit.Default); + return; + } + + ObservableTween + .Tween( + Time.timeScale, + TimeScale, + Duration, + EaseType, + ObservableTween.LoopType.None, + () => OnCompleteTweenSubject.OnNext(Unit.Default), + true + ) + .Subscribe(x => Time.timeScale = x) + .AddTo(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(TimeScaleCollector, x => TimeScale = x, nameof(TimeScale)), + CollectableMessageAnnotationFactory.Create(DurationCollector, x => Duration = x, nameof(Duration)), + CollectableMessageAnnotationFactory.Create(EaseTypeCollector, x => EaseType = x, nameof(EaseType)), + }; + } +} diff --git a/Assets/Scripts/Connector/Controller/TimeScaleController.cs.meta b/Assets/Scripts/Connector/Controller/TimeScaleController.cs.meta new file mode 100644 index 0000000..ea70738 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/TimeScaleController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 296d09de4d5545b2898c66b8a4f7cbd9 +timeCreated: 1565694908 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/TransformSiblingController.cs b/Assets/Scripts/Connector/Controller/TransformSiblingController.cs new file mode 100644 index 0000000..6c0ce83 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/TransformSiblingController.cs @@ -0,0 +1,67 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/TransformSiblingController", (int) ConnectorType.TransformSiblingController)] + public class TransformSiblingController : ConnectorBase, IMessageCollectable + { + [SerializeField] private Transform targetTransform = default; + [SerializeField] private TransformSiblingControlMethod transformSiblingControlMethod = default; + [SerializeField] private int index = default; + + private Transform TargetTransform + { + get => targetTransform != default + ? targetTransform + : targetTransform = transform; + set => targetTransform = value; + } + private TransformSiblingControlMethod TransformSiblingControlMethod => transformSiblingControlMethod; + private int Index + { + get => index; + set => index = value; + } + + [SerializeField] private TransformCollector targetTransformCollector = new TransformCollector(); + [SerializeField] private IntCollector indexCollector = new IntCollector(); + private TransformCollector TargetTransformCollector => targetTransformCollector; + private IntCollector IndexCollector => indexCollector; + + public override IObservable OnConnectAsObservable() + { + switch (TransformSiblingControlMethod) + { + case TransformSiblingControlMethod.SetIndex: + TargetTransform.SetSiblingIndex(Index); + break; + case TransformSiblingControlMethod.AsFirst: + TargetTransform.SetAsFirstSibling(); + break; + case TransformSiblingControlMethod.AsLast: + TargetTransform.SetAsLastSibling(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + return ObservableFactory.ReturnMessage(this); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(TargetTransformCollector, x => TargetTransform = x, nameof(TargetTransform)), + CollectableMessageAnnotationFactory.Create(IndexCollector, x => Index = x, nameof(Index)), + }; + } + + public enum TransformSiblingControlMethod + { + SetIndex, + AsFirst, + AsLast, + } +} diff --git a/Assets/Scripts/Connector/Controller/TransformSiblingController.cs.meta b/Assets/Scripts/Connector/Controller/TransformSiblingController.cs.meta new file mode 100644 index 0000000..a97d743 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/TransformSiblingController.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 24638babb79546c7aa8f949cb8305d00 +timeCreated: 1570695094 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/UnloadScene.cs b/Assets/Scripts/Connector/Controller/UnloadScene.cs new file mode 100644 index 0000000..f7860b8 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadScene.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/Controller/UnloadScene", (int) ConnectorType.UnloadScene)] + public class UnloadScene : UnloadSceneBase + { + [SerializeField] private List sceneNames = default; + + [UsedImplicitly] public override IEnumerable SceneNames + { + get => sceneNames; + set => sceneNames = value.ToList(); + } + } +} diff --git a/Assets/Scripts/Connector/Controller/UnloadScene.cs.meta b/Assets/Scripts/Connector/Controller/UnloadScene.cs.meta new file mode 100644 index 0000000..7be582e --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadScene.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0a8555d88fa64fae816f0116869b471d +timeCreated: 1565249848 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs b/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs new file mode 100644 index 0000000..42a303e --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using Cysharp.Threading.Tasks; +using JetBrains.Annotations; +using UniRx; +using UnityEngine.SceneManagement; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + public abstract class UnloadSceneBase : ConnectorBase + { + [UsedImplicitly] + public abstract IEnumerable SceneNames { get; set; } + + [InjectOptional] private AsyncUnloadSceneDelegate AsyncUnloadSceneDelegate { get; } = DefaultAsyncUnloadScene; + + public override IObservable OnConnectAsObservable() + { + return AsyncUnloadSceneDelegate(SceneNames) + .ToObservable() + .Select(this.CreateMessage); + } + + private static async UniTask DefaultAsyncUnloadScene(IEnumerable sceneNames) + { + foreach (var sceneName in sceneNames) + { + await SceneManager.UnloadSceneAsync(sceneName); + } + } + } + + public delegate UniTask AsyncUnloadSceneDelegate(IEnumerable sceneNames); +} diff --git a/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs.meta b/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs.meta new file mode 100644 index 0000000..a983a55 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadSceneBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c5530ca1b3904569a5ca1c1c53a8732f +timeCreated: 1568896159 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs b/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs new file mode 100644 index 0000000..54b5976 --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using JetBrains.Annotations; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector.Controller +{ + public abstract class UnloadSceneEnumBase : UnloadSceneBase where TSceneName : Enum + { + [SerializeField] private List sceneNames = default; + + [InjectOptional(Id = InjectId.SceneNamePrefix)] private string SceneNamePrefix { get; } + + [UsedImplicitly] public override IEnumerable SceneNames + { + get => sceneNames.Select(x => $"{SceneNamePrefix}{x.ToString()}"); + set => sceneNames = value + .Select( + x => (TSceneName) Enum + .Parse( + typeof(TSceneName), + Regex.Replace(x, $"^{SceneNamePrefix}", string.Empty) + ) + ) + .ToList(); + } + } +} diff --git a/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs.meta b/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs.meta new file mode 100644 index 0000000..8c71f9c --- /dev/null +++ b/Assets/Scripts/Connector/Controller/UnloadSceneEnumBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb2ba5413cf043ef8fec32fc864eb1fe +timeCreated: 1568896041 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Empty.cs b/Assets/Scripts/Connector/Empty.cs deleted file mode 100644 index 0daf301..0000000 --- a/Assets/Scripts/Connector/Empty.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/Empty", 10000)] - public class Empty : EventPublisher - { - public override IObservable OnPublishAsObservable() => - Observable.Return(EventMessage.Create(EventType.Empty, this)); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/Event.meta b/Assets/Scripts/Connector/Event.meta new file mode 100644 index 0000000..e6ebe74 --- /dev/null +++ b/Assets/Scripts/Connector/Event.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0a477956e4fa4360a70470e06a0a1082 +timeCreated: 1567259943 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Event/AnimationEvent.cs b/Assets/Scripts/Connector/Event/AnimationEvent.cs new file mode 100644 index 0000000..0abf58b --- /dev/null +++ b/Assets/Scripts/Connector/Event/AnimationEvent.cs @@ -0,0 +1,122 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/AnimationEvent", (int) ConnectorType.AnimationEvent)] + public class AnimationEvent : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable, IMessageComposable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private Animator animator = default; + [SerializeField] private SimpleAnimation simpleAnimation = default; + [SerializeField] + [Tooltip("If you do not specify it will be used SimpleAnimation setting")] + private AnimationClip animationClip = default; + [SerializeField] private AnimatorCullingMode cullingMode = AnimatorCullingMode.AlwaysAnimate; + [SerializeField] private AnimatorUpdateMode updateMode = AnimatorUpdateMode.Normal; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + public Animator Animator + { + get => animator != default ? animator : animator = this.GetOrAddComponent(); + private set => animator = value; + } + private SimpleAnimation SimpleAnimation + { + get => + simpleAnimation != default + ? simpleAnimation + : simpleAnimation = + Animator.GetComponent() != default + ? Animator.GetComponent() + : Animator.gameObject.AddComponent() + ; + set => simpleAnimation = value; + } + private AnimationClip AnimationClip + { + get => animationClip; + set => animationClip = value; + } + private AnimatorCullingMode CullingMode => cullingMode; + private AnimatorUpdateMode UpdateMode => updateMode; + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AnimatorCollector animatorCollector = new AnimatorCollector(); + [SerializeField] private SimpleAnimationCollector simpleAnimationCollector = new SimpleAnimationCollector(); + [SerializeField] private AnimationClipCollector animationClipCollector = new AnimationClipCollector(); + // TODO: Implement EnumCollector + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AnimatorCollector AnimatorCollector => animatorCollector; + private SimpleAnimationCollector SimpleAnimationCollector => simpleAnimationCollector; + private AnimationClipCollector AnimationClipCollector => animationClipCollector; + + private ISubject Subject { get; } = new Subject(); + + private UnityEngine.AnimationEvent LatestAnimationEvent { get; set; } + + public override IObservable OnConnectAsObservable() + { + PrepareAnimationEvent(); + return Subject + .TakeUntil(CancellationSubject) + .Select(this.CreateMessage); + } + + /// + /// Invoked from AnimationEvent + /// + /// + [UsedImplicitly] + public void Dispatch(UnityEngine.AnimationEvent animationEvent) + { + Subject.OnNext(animationEvent); + LatestAnimationEvent = animationEvent; + } + + private void PrepareAnimationEvent() + { + // ReSharper disable once InvertIf + // Automatic add components Animator and SimpleAnimation if AudioClip specified and Animator component does not exists. + if (AnimationClip != default && Animator == default && SimpleAnimation.GetStates().All(x => x.clip != AnimationClip)) + { + SimpleAnimation.AddClip(AnimationClip, AnimationClip.GetInstanceID().ToString()); + SimpleAnimation.cullingMode = CullingMode; + Animator.updateMode = UpdateMode; + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AnimatorCollector, x => Animator = x), + CollectableMessageAnnotationFactory.Create(SimpleAnimationCollector, x => SimpleAnimation = x), + CollectableMessageAnnotationFactory.Create(AnimationClipCollector, x => AnimationClip = x), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => LatestAnimationEvent), + }; + } +} diff --git a/Assets/Scripts/Connector/AnimationEvent.cs.meta b/Assets/Scripts/Connector/Event/AnimationEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/AnimationEvent.cs.meta rename to Assets/Scripts/Connector/Event/AnimationEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/AudioEvent.cs b/Assets/Scripts/Connector/Event/AudioEvent.cs new file mode 100644 index 0000000..ab341ea --- /dev/null +++ b/Assets/Scripts/Connector/Event/AudioEvent.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/AudioEvent", (int) ConnectorType.AudioEvent)] + public class AudioEvent : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private AudioSource audioSource = default; + [SerializeField] private AudioEventType audioEventType = AudioEventType.Play; + [SerializeField] + [Tooltip("If you do not specify it will be obtained by AudioSource.clip")] + private AudioClip audioClip = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + public AudioSource AudioSource + { + get => audioSource != default ? audioSource : audioSource = this.GetOrAddComponent(); + private set => audioSource = value; + } + public AudioEventType AudioEventType => audioEventType; + private AudioClip AudioClip + { + get => audioClip; + set => audioClip = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AudioSourceCollector audioSourceCollector = new AudioSourceCollector(); + [SerializeField] private AudioClipCollector audioClipCollector = new AudioClipCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AudioSourceCollector AudioSourceCollector => audioSourceCollector; + private AudioClipCollector AudioClipCollector => audioClipCollector; + + private IReadOnlyReactiveProperty> TimePair { get; set; } + + public override IObservable OnConnectAsObservable() + { + return OnAudioEventAsObservable() + .Select(this.CreateMessage); + } + + private IObservable OnAudioEventAsObservable() + { + TimePair = AudioSource + .ObserveEveryValueChanged(x => x.time) + .Pairwise() + .ToReactiveProperty(); + switch (AudioEventType) + { + case AudioEventType.Play: + case AudioEventType.Stop: + case AudioEventType.Pause: + case AudioEventType.UnPause: + return AudioSource + .ObserveEveryValueChanged(x => x.isPlaying) + .Where(_ => AudioClip == default || AudioClip == AudioSource.clip) + .Select(x => DetectAudioEventType(x, AudioSource.clip)) + .Where(x => AudioEventType == x); + case AudioEventType.Loop: + return TimePair + .Where(_ => AudioClip == default || AudioClip == AudioSource.clip) + .Where(xs => AudioSource.isPlaying && xs.Current < xs.Previous && xs.Previous > 0.0f) + .Select(_ => AudioEventType.Loop); + default: + throw new ArgumentOutOfRangeException(); + } + } + + private AudioEventType DetectAudioEventType(bool isPlaying, AudioClip clip) + { + if (clip == default) + { + throw new ArgumentOutOfRangeException(); + } + + if (isPlaying && Mathf.Approximately(0.0f, TimePair.Value.Previous) && TimePair.Value.Current > 0.0f) + { + return AudioEventType.Play; + } + + if (!isPlaying && (Mathf.Approximately(clip.length, TimePair.Value.Current) || Mathf.Approximately(0.0f, TimePair.Value.Current) && TimePair.Value.Previous > 0.0f)) + { + return AudioEventType.Stop; + } + + if (!isPlaying && TimePair.Value.Current > 0.0f && TimePair.Value.Current > TimePair.Value.Previous) + { + return AudioEventType.Pause; + } + + if (isPlaying && TimePair.Value.Current > 0.0f && TimePair.Value.Current > TimePair.Value.Previous) + { + return AudioEventType.UnPause; + } + + return (AudioEventType) -1; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AudioSourceCollector, x => AudioSource = x), + CollectableMessageAnnotationFactory.Create(AudioClipCollector, x => AudioClip = x), + }; + } + + public enum AudioEventType + { + Play, + Stop, + Pause, + UnPause, // Follow method name in AudioClip + Loop, + } +} diff --git a/Assets/Scripts/Connector/AudioEvent.cs.meta b/Assets/Scripts/Connector/Event/AudioEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/AudioEvent.cs.meta rename to Assets/Scripts/Connector/Event/AudioEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/CameraEvent.cs b/Assets/Scripts/Connector/Event/CameraEvent.cs new file mode 100644 index 0000000..3321bb4 --- /dev/null +++ b/Assets/Scripts/Connector/Event/CameraEvent.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/CameraEvent", (int) ConnectorType.CameraEvent)] + public class CameraEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private CameraEventType cameraEventType = CameraEventType.BecomeVisible; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + public CameraEventType CameraEventType => cameraEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable().Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (CameraEventType) + { + case CameraEventType.BecomeVisible: + return Component.OnBecameVisibleAsObservable(); + case CameraEventType.BecomeInvisible: + return Component.OnBecameInvisibleAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum CameraEventType + { + BecomeVisible, + BecomeInvisible, + } +} diff --git a/Assets/Scripts/Connector/CameraEvent.cs.meta b/Assets/Scripts/Connector/Event/CameraEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/CameraEvent.cs.meta rename to Assets/Scripts/Connector/Event/CameraEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/KeyEvent.cs b/Assets/Scripts/Connector/Event/KeyEvent.cs new file mode 100644 index 0000000..d7b1d90 --- /dev/null +++ b/Assets/Scripts/Connector/Event/KeyEvent.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using KeyEventHandler; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/KeyEvent", (int) ConnectorType.KeyEvent)] + public class KeyEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private KeyCode keyCode = default; + [SerializeField] private KeyEventType keyEventType = default; + + private KeyCode KeyCode + { + get => keyCode; + set => keyCode = value; + } + private KeyEventType KeyEventType + { + get => keyEventType; + set => keyEventType = value; + } + + [SerializeField] private KeyCodeCollector keyCodeCollector = new KeyCodeCollector(); + [SerializeField] private KeyEventTypeCollector keyEventTypeCollector = new KeyEventTypeCollector(); + + private KeyCodeCollector KeyCodeCollector => keyCodeCollector; + private KeyEventTypeCollector KeyEventTypeCollector => keyEventTypeCollector; + + public override IObservable OnConnectAsObservable() + { + switch (KeyEventType) + { + case KeyEventType.Down: + return this.OnKeyDownAsObservable(KeyCode).AsMessageObservable(this); + case KeyEventType.Press: + return this.OnKeyPressAsObservable(KeyCode).AsMessageObservable(this); + case KeyEventType.Up: + return this.OnKeyUpAsObservable(KeyCode).AsMessageObservable(this); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(KeyCodeCollector, x => KeyCode = x, nameof(KeyCode)), + CollectableMessageAnnotationFactory.Create(KeyEventTypeCollector, x => KeyEventType = x, nameof(KeyEventType)), + }; + } + + public enum KeyEventType + { + Down, + Press, + Up, + } + + [Serializable] + public class KeyCodeCollector : ValueCollectorBase + { + } + + [Serializable] + public class KeyEventTypeCollector : ValueCollectorBase + { + } +} diff --git a/Assets/Scripts/Connector/Event/KeyEvent.cs.meta b/Assets/Scripts/Connector/Event/KeyEvent.cs.meta new file mode 100644 index 0000000..59f6701 --- /dev/null +++ b/Assets/Scripts/Connector/Event/KeyEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8c14f3a3d8fe4aada21f6a9e1d371b9f +timeCreated: 1565693346 \ No newline at end of file diff --git a/Assets/Scripts/Connector/LifecycleEvent.cs b/Assets/Scripts/Connector/Event/LifecycleEvent.cs similarity index 75% rename from Assets/Scripts/Connector/LifecycleEvent.cs rename to Assets/Scripts/Connector/Event/LifecycleEvent.cs index d5f1be5..fc112d5 100644 --- a/Assets/Scripts/Connector/LifecycleEvent.cs +++ b/Assets/Scripts/Connector/Event/LifecycleEvent.cs @@ -1,39 +1,32 @@ using System; -using EventConnector.Message; using UniRx; using UniRx.Triggers; using UnityEngine; -namespace EventConnector.Connector +namespace UniFlow.Connector.Event { - [AddComponentMenu("Event Connector/LifecycleEvent", 100)] - public class LifecycleEvent : EventPublisher + [AddComponentMenu("UniFlow/Event/LifecycleEvent", (int) ConnectorType.LifecycleEvent)] + public class LifecycleEvent : ConnectorBase { - [SerializeField] private LifecycleEventType lifecycleEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; + [SerializeField] private Component component = default; + [SerializeField] private LifecycleEventType lifecycleEventType = LifecycleEventType.Start; - private LifecycleEventType LifecycleEventType => lifecycleEventType; private Component Component => component ? component : component = this; + public LifecycleEventType LifecycleEventType => lifecycleEventType; private IReactiveProperty StartProperty { get; } = new BoolReactiveProperty(false); private IReactiveProperty OnEnableProperty { get; } = new BoolReactiveProperty(false); - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(_ => EventMessage.Create(EventType.LifecycleEvent, Component, LifecycleEventData.Create(LifecycleEventType))); - - private void Awake() + public override IObservable OnConnectAsObservable() { - OnEnableProperty.Value = enabled; + return OnEventAsObservable().Select(this.CreateMessage); } protected override void Start() { - base.Start(); - + OnEnableProperty.Value = enabled; StartProperty.Value = true; + base.Start(); } private void OnEnable() @@ -81,4 +74,4 @@ public enum LifecycleEventType Enable, Disable, } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Connector/LifecycleEvent.cs.meta b/Assets/Scripts/Connector/Event/LifecycleEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/LifecycleEvent.cs.meta rename to Assets/Scripts/Connector/Event/LifecycleEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/LoadSceneEvent.cs b/Assets/Scripts/Connector/Event/LoadSceneEvent.cs new file mode 100644 index 0000000..f0eba8c --- /dev/null +++ b/Assets/Scripts/Connector/Event/LoadSceneEvent.cs @@ -0,0 +1,43 @@ +using System; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/LoadSceneEvent", (int) ConnectorType.LoadSceneEvent)] + public class LoadSceneEvent : ConnectorBase + { + [SerializeField] private string sceneName = default; + + [UsedImplicitly] public string SceneName + { + get => sceneName; + set => sceneName = value; + } + + private ISubject Subject { get; } = new Subject(); + + public override IObservable OnConnectAsObservable() => Subject.AsMessageObservable(this); + + protected override void Start() + { + base.Start(); + SceneManager.sceneLoaded += DidLoadScene; + } + + private void OnDestroy() + { + SceneManager.sceneLoaded -= DidLoadScene; + } + + private void DidLoadScene(Scene loadedScene, LoadSceneMode mode) + { + if (loadedScene.name == SceneName) + { + Subject.OnNext(Unit.Default); + } + } + } +} diff --git a/Assets/Scripts/Connector/Event/LoadSceneEvent.cs.meta b/Assets/Scripts/Connector/Event/LoadSceneEvent.cs.meta new file mode 100644 index 0000000..7331b2e --- /dev/null +++ b/Assets/Scripts/Connector/Event/LoadSceneEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 82f9fc4f9d304012b041aeabb5634ba1 +timeCreated: 1570534045 \ No newline at end of file diff --git a/Assets/Scripts/Connector/MouseEvent.cs b/Assets/Scripts/Connector/Event/MouseEvent.cs similarity index 53% rename from Assets/Scripts/Connector/MouseEvent.cs rename to Assets/Scripts/Connector/Event/MouseEvent.cs index 72450ab..bcf53fe 100644 --- a/Assets/Scripts/Connector/MouseEvent.cs +++ b/Assets/Scripts/Connector/Event/MouseEvent.cs @@ -1,58 +1,75 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/MouseEvent", 106)] - public class MouseEvent : EventPublisher - { - [SerializeField] private MouseEventType mouseEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private MouseEventType MouseEventType => mouseEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(_ => EventMessage.Create(EventType.MouseEvent, Component, MouseEventData.Create(MouseEventType))); - - private IObservable OnEventAsObservable() - { - switch (MouseEventType) - { - case MouseEventType.MouseDown: - return Component.OnMouseDownAsObservable(); - case MouseEventType.MouseUp: - return Component.OnMouseUpAsObservable(); - case MouseEventType.MouseUpAsButton: - return Component.OnMouseUpAsButtonAsObservable(); - case MouseEventType.MouseEnter: - return Component.OnMouseEnterAsObservable(); - case MouseEventType.MouseExit: - return Component.OnMouseExitAsObservable(); - case MouseEventType.MouseOver: - return Component.OnMouseOverAsObservable(); - case MouseEventType.MouseDrag: - return Component.OnMouseDragAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum MouseEventType - { - MouseDown, - MouseUp, - MouseUpAsButton, - MouseEnter, - MouseExit, - MouseOver, - MouseDrag, - } -} \ No newline at end of file +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/MouseEvent", (int) ConnectorType.MouseEvent)] + public class MouseEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private MouseEventType mouseEventType = MouseEventType.MouseDown; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private MouseEventType MouseEventType => mouseEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable().Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { +#if !(UNITY_IOS || UNITY_ANDROID || UNITY_METRO) + switch (MouseEventType) + { + case MouseEventType.MouseDown: + return Component.OnMouseDownAsObservable(); + case MouseEventType.MouseUp: + return Component.OnMouseUpAsObservable(); + case MouseEventType.MouseUpAsButton: + return Component.OnMouseUpAsButtonAsObservable(); + case MouseEventType.MouseEnter: + return Component.OnMouseEnterAsObservable(); + case MouseEventType.MouseExit: + return Component.OnMouseExitAsObservable(); + case MouseEventType.MouseOver: + return Component.OnMouseOverAsObservable(); + case MouseEventType.MouseDrag: + return Component.OnMouseDragAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } +#else + throw new PlatformNotSupportedException("MouseEvent does not support mobile platform"); +#endif + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum MouseEventType + { + MouseDown, + MouseUp, + MouseUpAsButton, + MouseEnter, + MouseExit, + MouseOver, + MouseDrag, + } +} diff --git a/Assets/Scripts/Connector/MouseEvent.cs.meta b/Assets/Scripts/Connector/Event/MouseEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/MouseEvent.cs.meta rename to Assets/Scripts/Connector/Event/MouseEvent.cs.meta diff --git a/Assets/Scripts/Connector/ParticleEvent.cs b/Assets/Scripts/Connector/Event/ParticleEvent.cs similarity index 50% rename from Assets/Scripts/Connector/ParticleEvent.cs rename to Assets/Scripts/Connector/Event/ParticleEvent.cs index f7ed672..ea4deea 100644 --- a/Assets/Scripts/Connector/ParticleEvent.cs +++ b/Assets/Scripts/Connector/Event/ParticleEvent.cs @@ -1,25 +1,33 @@ using System; -using EventConnector.Message; +using System.Collections.Generic; using UniRx; using UniRx.Triggers; using UnityEngine; -namespace EventConnector.Connector +namespace UniFlow.Connector.Event { - [AddComponentMenu("Event Connector/ParticleEvent", 105)] - public class ParticleEvent : EventPublisher + [AddComponentMenu("UniFlow/Event/ParticleEvent", (int) ConnectorType.ParticleEvent)] + public class ParticleEvent : ConnectorBase, IMessageCollectable { - [SerializeField] private ParticleEventType particleEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; + [SerializeField] private Component component = default; + [SerializeField] private ParticleEventType particleEventType = ParticleEventType.ParticleCollision; + private Component Component + { + get => component ? component : component = this; + set => component = value; + } private ParticleEventType ParticleEventType => particleEventType; - private Component Component => component ? component : component = this; - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(x => EventMessage.Create(EventType.ParticleEvent, Component, ParticleEventData.Create(ParticleEventType, x))); + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable() + .Select(this.CreateMessage); + } private IObservable OnEventAsObservable() { @@ -36,6 +44,12 @@ private IObservable OnEventAsObservable() throw new ArgumentOutOfRangeException(); } } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; } public enum ParticleEventType @@ -44,4 +58,4 @@ public enum ParticleEventType ParticleTrigger, // ParticleSystemStopped, } -} \ No newline at end of file +} diff --git a/Assets/Scripts/Connector/ParticleEvent.cs.meta b/Assets/Scripts/Connector/Event/ParticleEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/ParticleEvent.cs.meta rename to Assets/Scripts/Connector/Event/ParticleEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/PhysicsCollision2DEvent.cs b/Assets/Scripts/Connector/Event/PhysicsCollision2DEvent.cs new file mode 100644 index 0000000..ebd9953 --- /dev/null +++ b/Assets/Scripts/Connector/Event/PhysicsCollision2DEvent.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/PhysicsCollision2DEvent", (int) ConnectorType.PhysicsCollision2DEvent)] + public class PhysicsCollision2DEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private PhysicsCollision2DEventType physicsCollision2DEventType = PhysicsCollision2DEventType.CollisionEnter2D; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private PhysicsCollision2DEventType PhysicsCollision2DEventType => physicsCollision2DEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable() + .Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (PhysicsCollision2DEventType) + { + case PhysicsCollision2DEventType.CollisionEnter2D: + return Component.OnCollisionEnter2DAsObservable(); + case PhysicsCollision2DEventType.CollisionExit2D: + return Component.OnCollisionExit2DAsObservable(); + case PhysicsCollision2DEventType.CollisionStay2D: + return Component.OnCollisionStay2DAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum PhysicsCollision2DEventType + { + CollisionEnter2D, + CollisionExit2D, + CollisionStay2D, + } +} diff --git a/Assets/Scripts/Connector/PhysicsCollision2DEvent.cs.meta b/Assets/Scripts/Connector/Event/PhysicsCollision2DEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/PhysicsCollision2DEvent.cs.meta rename to Assets/Scripts/Connector/Event/PhysicsCollision2DEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/PhysicsCollisionEvent.cs b/Assets/Scripts/Connector/Event/PhysicsCollisionEvent.cs new file mode 100644 index 0000000..ab3cc80 --- /dev/null +++ b/Assets/Scripts/Connector/Event/PhysicsCollisionEvent.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/PhysicsCollisionEvent", (int) ConnectorType.PhysicsCollisionEvent)] + public class PhysicsCollisionEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private PhysicsCollisionEventType physicsCollisionEventType = PhysicsCollisionEventType.CollisionEnter; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private PhysicsCollisionEventType PhysicsCollisionEventType => physicsCollisionEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable() + .Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (PhysicsCollisionEventType) + { + case PhysicsCollisionEventType.CollisionEnter: + return Component.OnCollisionEnterAsObservable(); + case PhysicsCollisionEventType.CollisionExit: + return Component.OnCollisionExitAsObservable(); + case PhysicsCollisionEventType.CollisionStay: + return Component.OnCollisionStayAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum PhysicsCollisionEventType + { + CollisionEnter, + CollisionExit, + CollisionStay, + } +} diff --git a/Assets/Scripts/Connector/PhysicsCollisionEvent.cs.meta b/Assets/Scripts/Connector/Event/PhysicsCollisionEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/PhysicsCollisionEvent.cs.meta rename to Assets/Scripts/Connector/Event/PhysicsCollisionEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/PhysicsTrigger2DEvent.cs b/Assets/Scripts/Connector/Event/PhysicsTrigger2DEvent.cs new file mode 100644 index 0000000..bbc7076 --- /dev/null +++ b/Assets/Scripts/Connector/Event/PhysicsTrigger2DEvent.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/PhysicsTrigger2DEvent", (int) ConnectorType.PhysicsTrigger2DEvent)] + public class PhysicsTrigger2DEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private PhysicsTrigger2DEventType physicsTrigger2DEventType = PhysicsTrigger2DEventType.TriggerEnter2D; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private PhysicsTrigger2DEventType PhysicsTrigger2DEventType => physicsTrigger2DEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable() + .Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (PhysicsTrigger2DEventType) + { + case PhysicsTrigger2DEventType.TriggerEnter2D: + return Component.OnTriggerEnter2DAsObservable(); + case PhysicsTrigger2DEventType.TriggerExit2D: + return Component.OnTriggerExit2DAsObservable(); + case PhysicsTrigger2DEventType.TriggerStay2D: + return Component.OnTriggerStay2DAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum PhysicsTrigger2DEventType + { + TriggerEnter2D, + TriggerExit2D, + TriggerStay2D, + } +} diff --git a/Assets/Scripts/Connector/PhysicsTrigger2DEvent.cs.meta b/Assets/Scripts/Connector/Event/PhysicsTrigger2DEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/PhysicsTrigger2DEvent.cs.meta rename to Assets/Scripts/Connector/Event/PhysicsTrigger2DEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/PhysicsTriggerEvent.cs b/Assets/Scripts/Connector/Event/PhysicsTriggerEvent.cs new file mode 100644 index 0000000..95b8d63 --- /dev/null +++ b/Assets/Scripts/Connector/Event/PhysicsTriggerEvent.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/PhysicsTriggerEvent", (int) ConnectorType.PhysicsTriggerEvent)] + public class PhysicsTriggerEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private PhysicsTriggerEventType physicsTriggerEventType = PhysicsTriggerEventType.TriggerEnter; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private PhysicsTriggerEventType PhysicsTriggerEventType => physicsTriggerEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable() + .Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (PhysicsTriggerEventType) + { + case PhysicsTriggerEventType.TriggerEnter: + return Component.OnTriggerEnterAsObservable(); + case PhysicsTriggerEventType.TriggerExit: + return Component.OnTriggerExitAsObservable(); + case PhysicsTriggerEventType.TriggerStay: + return Component.OnTriggerStayAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum PhysicsTriggerEventType + { + TriggerEnter, + TriggerExit, + TriggerStay, + } +} diff --git a/Assets/Scripts/Connector/PhysicsTriggerEvent.cs.meta b/Assets/Scripts/Connector/Event/PhysicsTriggerEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/PhysicsTriggerEvent.cs.meta rename to Assets/Scripts/Connector/Event/PhysicsTriggerEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/RectTransformEvent.cs b/Assets/Scripts/Connector/Event/RectTransformEvent.cs new file mode 100644 index 0000000..93c9b44 --- /dev/null +++ b/Assets/Scripts/Connector/Event/RectTransformEvent.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/RectTransformEvent", (int) ConnectorType.RectTransformEvent)] + public class RectTransformEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private RectTransformEventType rectTransformEventType = RectTransformEventType.CanvasGroupChanged; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private RectTransformEventType RectTransformEventType => rectTransformEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable().Select(this.CreateMessage); + } + + private IObservable OnEventAsObservable() + { + switch (RectTransformEventType) + { + case RectTransformEventType.CanvasGroupChanged: + return Component.OnCanvasGroupChangedAsObservable(); + case RectTransformEventType.RectTransformDimensionsChange: + return Component.OnRectTransformDimensionsChangeAsObservable(); + case RectTransformEventType.RectTransformRemoved: + return Component.OnRectTransformRemovedAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum RectTransformEventType + { + CanvasGroupChanged, + RectTransformDimensionsChange, + RectTransformRemoved, + } + } diff --git a/Assets/Scripts/Connector/RectTransformEvent.cs.meta b/Assets/Scripts/Connector/Event/RectTransformEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/RectTransformEvent.cs.meta rename to Assets/Scripts/Connector/Event/RectTransformEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs b/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs new file mode 100644 index 0000000..67165ee --- /dev/null +++ b/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs @@ -0,0 +1,131 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/SimpleAnimationEvent", (int) ConnectorType.SimpleAnimationEvent)] + public class SimpleAnimationEvent : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable + { + private const string MessageParameterKey = "SimpleAnimationEvent"; + + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private Animator animator = default; + [SerializeField] private SimpleAnimation simpleAnimation = default; + [SerializeField] private SimpleAnimationEventType simpleAnimationEventType = SimpleAnimationEventType.Play; + [SerializeField] + [Tooltip("If you do not specify it will not be filtered")] + private AnimationClip animationClip = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private Animator Animator + { + get => animator != default ? animator : animator = this.GetOrAddComponent(); + set => animator = value; + } + private SimpleAnimation SimpleAnimation + { + get => + simpleAnimation != default + ? simpleAnimation + : simpleAnimation = + Animator.GetComponent() != default + ? Animator.GetComponent() + : Animator.gameObject.AddComponent() + ; + set => simpleAnimation = value; + } + private SimpleAnimationEventType SimpleAnimationEventType => simpleAnimationEventType; + private AnimationClip AnimationClip + { + get => animationClip; + set => animationClip = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private AnimatorCollector animatorCollector = new AnimatorCollector(); + [SerializeField] private SimpleAnimationCollector simpleAnimationCollector = new SimpleAnimationCollector(); + [SerializeField] private AnimationClipCollector animationClipCollector = new AnimationClipCollector(); + // TODO: Implement EnumCollector + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private AnimatorCollector AnimatorCollector => animatorCollector; + private SimpleAnimationCollector SimpleAnimationCollector => simpleAnimationCollector; + private AnimationClipCollector AnimationClipCollector => animationClipCollector; + + private ISubject<(SimpleAnimationEventType eventType, AnimationClip animationClip)> CurrentStateSubject { get; } = new Subject<(SimpleAnimationEventType, AnimationClip)>(); + + private IDictionary PlayingStatuses { get; } = new Dictionary(); + + public override IObservable OnConnectAsObservable() + { + ObserveSimpleAnimation(); + return CurrentStateSubject + .TakeUntil(CancellationSubject) + .Where(x => (AnimationClip == default || x.animationClip == AnimationClip) && x.eventType == SimpleAnimationEventType) + .Select(x => this.CreateMessage(x, MessageParameterKey)); + } + + private void ObserveSimpleAnimation() + { + foreach (var state in SimpleAnimation.GetStates()) + { + PlayingStatuses[state] = false; + state + .ObserveEveryValueChanged(x => (SimpleAnimation.IsPlaying(x.name), x.normalizedTime)) + .Pairwise() + .TakeUntil(CancellationSubject) + .SubscribeWithState(state, OnChangeAnimatorStateInfo) + .AddTo(this); + } + } + + private void OnChangeAnimatorStateInfo(Pair<(bool isPlaying, float normalizedTime)> pair, SimpleAnimation.State state) + { + if (pair.Current.isPlaying && !PlayingStatuses[state]) + { + PlayingStatuses[state] = true; + CurrentStateSubject.OnNext((SimpleAnimationEventType.Play, state.clip)); + } + else if (pair.Previous.isPlaying && !pair.Current.isPlaying && PlayingStatuses[state]) + { + PlayingStatuses[state] = false; + CurrentStateSubject.OnNext((SimpleAnimationEventType.Stop, state.clip)); + } + else if (pair.Previous.normalizedTime < 1.0f && Mathf.Approximately(pair.Current.normalizedTime, 1.0f) && PlayingStatuses[state]) + { + PlayingStatuses[state] = false; + CurrentStateSubject.OnNext((SimpleAnimationEventType.Stop, state.clip)); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(AnimatorCollector, x => Animator = x), + CollectableMessageAnnotationFactory.Create(SimpleAnimationCollector, x => SimpleAnimation = x), + CollectableMessageAnnotationFactory.Create(AnimationClipCollector, x => AnimationClip = x), + }; + } + + public enum SimpleAnimationEventType + { + Play, + Stop, + } +} diff --git a/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs.meta b/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs.meta new file mode 100644 index 0000000..daba3a7 --- /dev/null +++ b/Assets/Scripts/Connector/Event/SimpleAnimationEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6fc6fac5bf554d4da6db3c2feda04ca8 +timeCreated: 1566462036 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Event/TimelineEvent.cs b/Assets/Scripts/Connector/Event/TimelineEvent.cs new file mode 100644 index 0000000..042da12 --- /dev/null +++ b/Assets/Scripts/Connector/Event/TimelineEvent.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.TimelineSignal; +using UniRx; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/TimelineEvent", (int) ConnectorType.TimelineEvent)] + public class TimelineEvent : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private PlayableDirector playableDirector = default; + [SerializeField] private TimelineEventType timelineEventType = TimelineEventType.Play; + [SerializeField] private TimelineAsset timelineAsset = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set + { + baseGameObject = value; + transformPath = default; + playableDirector = default; + timelineAsset = default; + // Try to re-register when TimelineAsset may change + // Note: Marker is ignored if Playable has already been played, so a hack such as delaying playback by 1 frame is required + RegisterSignal(); + } + } + + public string TransformPath + { + get => transformPath; + private set + { + transformPath = value; + playableDirector = default; + timelineAsset = default; + // Try to re-register when TimelineAsset may change + // Note: Marker is ignored if Playable has already been played, so a hack such as delaying playback by 1 frame is required + RegisterSignal(); + } + } + + private PlayableDirector PlayableDirector + { + get => playableDirector != default ? playableDirector : playableDirector = this.GetOrAddComponent(); + set + { + playableDirector = value; + timelineAsset = default; + // Try to re-register when TimelineAsset may change + // Note: Marker is ignored if Playable has already been played, so a hack such as delaying playback by 1 frame is required + RegisterSignal(); + } + } + + private TimelineEventType TimelineEventType => timelineEventType; + private TimelineAsset TimelineAsset + { + get => timelineAsset != default ? timelineAsset : PlayableDirector.playableAsset as TimelineAsset; + set + { + timelineAsset = value; + // Try to re-register when TimelineAsset may change + // Note: Marker is ignored if Playable has already been played, so a hack such as delaying playback by 1 frame is required + RegisterSignal(); + } + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private PlayableDirectorCollector playableDirectorCollector = new PlayableDirectorCollector(); + [SerializeField] private TimelineAssetCollector timelineAssetCollector = new TimelineAssetCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private PlayableDirectorCollector PlayableDirectorCollector => playableDirectorCollector; + private TimelineAssetCollector TimelineAssetCollector => timelineAssetCollector; + + private static Begin beginSignal = default; + private static End endSignal = default; + private static Begin BeginSignal + { + get + { + // ReSharper disable once InvertIf + if (beginSignal == default) + { + beginSignal = ScriptableObject.CreateInstance(); + beginSignal.IsTemporaryInstance = true; + } + return beginSignal; + } + } + + private static End EndSignal + { + get + { + // ReSharper disable once InvertIf + if (endSignal == default) + { + endSignal = ScriptableObject.CreateInstance(); + endSignal.IsTemporaryInstance = true; + } + return endSignal; + } + } + + private ISubject SignalEmittedSubject { get; } = new Subject(); + + private MarkerTrack MarkerTrack { get; set; } + + private void Awake() + { + RegisterSignal(); + } + + private void OnDestroy() + { + if (MarkerTrack == default) + { + return; + } + + foreach (var marker in MarkerTrack.GetMarkers().OfType().Where(x => x.asset is SignalAssetBase signalAsset && signalAsset.IsTemporaryInstance)) + { + MarkerTrack.DeleteMarker(marker); + } + } + + public override IObservable OnConnectAsObservable() + { + return SignalEmittedSubject + .Select(this.CreateMessage); + } + + private void RegisterSignal() + { + if (!(TimelineAsset is TimelineAsset timeline)) + { + return; + } + + var time = TimelineEventType == TimelineEventType.Play ? 0 : timeline.duration; + var signal = TimelineEventType == TimelineEventType.Play ? (SignalAsset) BeginSignal : EndSignal; + MarkerTrack = timeline.markerTrack; + var emitter = MarkerTrack + .GetMarkers() + .FirstOrDefault( + x => x is SignalEmitter signalEmitter + && signalEmitter != default + && Math.Abs(signalEmitter.time - time) < double.Epsilon + && signalEmitter.asset != default + && signalEmitter.asset.GetType() == signal.GetType() + ) as SignalEmitter; + if (emitter == default) + { + emitter = MarkerTrack.CreateMarker(time); + emitter.asset = signal; + } + + var receiver = PlayableDirector.gameObject.GetComponent(); + if (receiver == default) + { + receiver = PlayableDirector.gameObject.AddComponent(); + } + + if (receiver.GetReaction(signal) == default) + { + receiver.AddReaction(signal, new UnityEvent()); + } + + receiver.GetReaction(signal).AddListener(TimelineEventType == TimelineEventType.Play ? (UnityAction) DispatchBegin : DispatchEnd); + } + + private void DispatchBegin() + { + SignalEmittedSubject.OnNext(TimelineEventType.Play); + } + + private void DispatchEnd() + { + SignalEmittedSubject.OnNext(TimelineEventType.Stop); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PlayableDirectorCollector, x => PlayableDirector = x), + CollectableMessageAnnotationFactory.Create(TimelineAssetCollector, x => TimelineAsset = x), + }; + } + + public enum TimelineEventType + { + Play, + Stop, + } +} diff --git a/Assets/Scripts/Connector/Event/TimelineEvent.cs.meta b/Assets/Scripts/Connector/Event/TimelineEvent.cs.meta new file mode 100644 index 0000000..2c50d86 --- /dev/null +++ b/Assets/Scripts/Connector/Event/TimelineEvent.cs.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +guid: 7e0c3e70e31f4801a6fdf1ac6facdab6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: + - beginSignal: {fileID: 11400000, guid: 3dbc3d1c5a0704ea6ade5b04509bc240, type: 2} + - endSignal: {fileID: 11400000, guid: 51b2d11bb0d2d403d8f39dde22b9effd, type: 2} + - timelineAsset: {instanceID: 0} + - playableDirector: {instanceID: 0} + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Connector/Event/TimelineSignal.cs b/Assets/Scripts/Connector/Event/TimelineSignal.cs new file mode 100644 index 0000000..d10a8bd --- /dev/null +++ b/Assets/Scripts/Connector/Event/TimelineSignal.cs @@ -0,0 +1,53 @@ +using System; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace UniFlow.Connector.Event +{ + // Timeline SignalReceiver cannot serialize [Serializable] class + // So I provide overloads to construct TimelineEventData + [AddComponentMenu("UniFlow/Event/TimelineSignal", (int) ConnectorType.TimelineSignal)] + public class TimelineSignal : ConnectorBase + { + private const string MessageParameterKey = "TimelineSignal"; + + private ISubject<(int intParameter, float floatParameter, string stringParameter, Object objectParameter)> Subject { get; } = new Subject<(int intParameter, float floatParameter, string stringParameter, Object objectParameter)>(); + + public override IObservable OnConnectAsObservable() + { + return Subject.AsMessageObservable(this, MessageParameterKey); + } + + [UsedImplicitly] + public void Dispatch() + { + Subject.OnNext((default, default, default, default)); + } + + [UsedImplicitly] + public void Dispatch(int intParameter) + { + Subject.OnNext((intParameter, default, default, default)); + } + + [UsedImplicitly] + public void Dispatch(float floatParameter) + { + Subject.OnNext((default, floatParameter, default, default)); + } + + [UsedImplicitly] + public void Dispatch(string stringParameter) + { + Subject.OnNext((default, default, stringParameter, default)); + } + + [UsedImplicitly] + public void Dispatch(Object objectReferenceParameter) + { + Subject.OnNext((default, default, default, objectReferenceParameter)); + } + } +} diff --git a/Assets/Scripts/Connector/TimelineSignal.cs.meta b/Assets/Scripts/Connector/Event/TimelineSignal.cs.meta similarity index 100% rename from Assets/Scripts/Connector/TimelineSignal.cs.meta rename to Assets/Scripts/Connector/Event/TimelineSignal.cs.meta diff --git a/Assets/Scripts/Connector/Event/TransformEvent.cs b/Assets/Scripts/Connector/Event/TransformEvent.cs new file mode 100644 index 0000000..06658e3 --- /dev/null +++ b/Assets/Scripts/Connector/Event/TransformEvent.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/TransformEvent", (int) ConnectorType.TransformEvent)] + public class TransformEvent : ConnectorBase, IMessageCollectable + { + [SerializeField] private Component component = default; + [SerializeField] private TransformEventType transformEventType = TransformEventType.TransformChildrenChanged; + + private Component Component + { + get => component ? component : component = this; + set => component = value; + } + private TransformEventType TransformEventType => transformEventType; + + [SerializeField] private ComponentCollector componentCollector = new ComponentCollector(); + + private ComponentCollector ComponentCollector => componentCollector; + + public override IObservable OnConnectAsObservable() + { + return OnEventAsObservable().AsMessageObservable(this); + } + + private IObservable OnEventAsObservable() + { + switch (TransformEventType) + { + case TransformEventType.BeforeTransformParentChanged: + return Component.OnBeforeTransformParentChangedAsObservable(); + case TransformEventType.TransformParentChanged: + return Component.OnTransformParentChangedAsObservable(); + case TransformEventType.TransformChildrenChanged: + return Component.OnTransformChildrenChangedAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ComponentCollector, x => Component = x), + }; + } + + public enum TransformEventType + { + BeforeTransformParentChanged, + TransformParentChanged, + TransformChildrenChanged, + } +} diff --git a/Assets/Scripts/Connector/TransformEvent.cs.meta b/Assets/Scripts/Connector/Event/TransformEvent.cs.meta similarity index 100% rename from Assets/Scripts/Connector/TransformEvent.cs.meta rename to Assets/Scripts/Connector/Event/TransformEvent.cs.meta diff --git a/Assets/Scripts/Connector/Event/UIBehaviourEventTrigger.cs b/Assets/Scripts/Connector/Event/UIBehaviourEventTrigger.cs new file mode 100644 index 0000000..e1ee1a4 --- /dev/null +++ b/Assets/Scripts/Connector/Event/UIBehaviourEventTrigger.cs @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UniRx.Triggers; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/UIBehaviourEventTrigger", (int) ConnectorType.UIBehaviourEventTrigger)] + public class UIBehaviourEventTrigger : ConnectorBase, IBaseGameObjectSpecifyable, IMessageCollectable, IMessageComposable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private UIBehaviour uiBehaviour = default; + [SerializeField] private EventTriggerType eventTriggerType = EventTriggerType.PointerClick; + [SerializeField] private bool activateBeforeConnect = default; + [SerializeField] private bool deactivateAfterConnect = default; + + public GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + private set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + public UIBehaviour UIBehaviour + { + get => uiBehaviour ? uiBehaviour : uiBehaviour = ((IBaseGameObjectSpecifyable) this).GetComponent(); + private set => uiBehaviour = value; + } + private EventTriggerType EventTriggerType => eventTriggerType; + private bool ActivateBeforeConnect + { + get => activateBeforeConnect; + set => activateBeforeConnect = value; + } + private bool DeactivateAfterConnect + { + get => deactivateAfterConnect; + set => deactivateAfterConnect = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private UIBehaviourCollector uiBehaviourCollector = new UIBehaviourCollector(); + [SerializeField] private BoolCollector activateBeforeConnectCollector = new BoolCollector(); + [SerializeField] private BoolCollector deactivateAfterConnectCollector = new BoolCollector(); + // TODO: Implement EnumCollector + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private UIBehaviourCollector UIBehaviourCollector => uiBehaviourCollector; + private BoolCollector ActivateBeforeConnectCollector => activateBeforeConnectCollector; + private BoolCollector DeactivateAfterConnectCollector => deactivateAfterConnectCollector; + + private IDisposable Disposable { get; } = new CompositeDisposable(); + + public override IObservable OnConnectAsObservable() + { + return Observable + .ReturnUnit() + .Do( + _ => + { + if (ActivateBeforeConnect && UIBehaviour is Graphic graphic) + { + graphic.raycastTarget = true; + } + } + ) + .SelectMany(_ => OnEventTriggerAsObservable()) + .Do( + _ => + { + if (DeactivateAfterConnect && UIBehaviour is Graphic graphic) + { + graphic.raycastTarget = false; + } + } + ) + .AsMessageObservable(this, "EventData"); + } + + private IObservable OnEventTriggerAsObservable() + { + switch (EventTriggerType) + { + case EventTriggerType.PointerEnter: + return UIBehaviour.OnPointerEnterAsObservable(); + case EventTriggerType.PointerExit: + return UIBehaviour.OnPointerExitAsObservable(); + case EventTriggerType.PointerDown: + return UIBehaviour.OnPointerDownAsObservable(); + case EventTriggerType.PointerUp: + return UIBehaviour.OnPointerUpAsObservable(); + case EventTriggerType.PointerClick: + return UIBehaviour.OnPointerClickAsObservable(); + case EventTriggerType.Drag: + return UIBehaviour.OnDragAsObservable(); + case EventTriggerType.Drop: + return UIBehaviour.OnDropAsObservable(); + case EventTriggerType.Scroll: + return UIBehaviour.OnScrollAsObservable(); + case EventTriggerType.UpdateSelected: + return UIBehaviour.OnUpdateSelectedAsObservable(); + case EventTriggerType.Select: + return UIBehaviour.OnSelectAsObservable(); + case EventTriggerType.Deselect: + return UIBehaviour.OnDeselectAsObservable(); + case EventTriggerType.Move: + return UIBehaviour.OnMoveAsObservable(); + case EventTriggerType.InitializePotentialDrag: + return UIBehaviour.OnInitializePotentialDragAsObservable(); + case EventTriggerType.BeginDrag: + return UIBehaviour.OnBeginDragAsObservable(); + case EventTriggerType.EndDrag: + return UIBehaviour.OnEndDragAsObservable(); + case EventTriggerType.Submit: + return UIBehaviour.OnSubmitAsObservable(); + case EventTriggerType.Cancel: + return UIBehaviour.OnCancelAsObservable(); + default: + throw new ArgumentOutOfRangeException(); + } + } + + private void OnDestroy() + { + Disposable.Dispose(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(UIBehaviourCollector, x => UIBehaviour = x), + CollectableMessageAnnotationFactory.Create(ActivateBeforeConnectCollector, x => ActivateBeforeConnect = x, nameof(ActivateBeforeConnect)), + CollectableMessageAnnotationFactory.Create(DeactivateAfterConnectCollector, x => DeactivateAfterConnect = x, nameof(DeactivateAfterConnect)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(null, "EventData"), + }; + } +} diff --git a/Assets/Scripts/Connector/UIBehaviourEventTrigger.cs.meta b/Assets/Scripts/Connector/Event/UIBehaviourEventTrigger.cs.meta similarity index 100% rename from Assets/Scripts/Connector/UIBehaviourEventTrigger.cs.meta rename to Assets/Scripts/Connector/Event/UIBehaviourEventTrigger.cs.meta diff --git a/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs b/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs new file mode 100644 index 0000000..5aed806 --- /dev/null +++ b/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs @@ -0,0 +1,43 @@ +using System; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; +using UnityEngine.SceneManagement; + +namespace UniFlow.Connector.Event +{ + [AddComponentMenu("UniFlow/Event/UnloadSceneEvent", (int) ConnectorType.UnloadSceneEvent)] + public class UnloadSceneEvent : ConnectorBase + { + [SerializeField] private string sceneName = default; + + [UsedImplicitly] public string SceneName + { + get => sceneName; + set => sceneName = value; + } + + private ISubject Subject { get; } = new Subject(); + + public override IObservable OnConnectAsObservable() => Subject.AsMessageObservable(this); + + protected override void Start() + { + base.Start(); + SceneManager.sceneUnloaded += DidUnloadScene; + } + + private void OnDestroy() + { + SceneManager.sceneUnloaded -= DidUnloadScene; + } + + private void DidUnloadScene(Scene unloadedScene) + { + if (unloadedScene.name == SceneName) + { + Subject.OnNext(Unit.Default); + } + } + } +} diff --git a/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs.meta b/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs.meta new file mode 100644 index 0000000..72bd635 --- /dev/null +++ b/Assets/Scripts/Connector/Event/UnloadSceneEvent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: acad2337f85040d398d5626fa6914067 +timeCreated: 1569396014 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Expression.meta b/Assets/Scripts/Connector/Expression.meta new file mode 100644 index 0000000..d549b80 --- /dev/null +++ b/Assets/Scripts/Connector/Expression.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9ef5fd6a410a4aac838f670a8fb6bc98 +timeCreated: 1570698173 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Expression/And.cs b/Assets/Scripts/Connector/Expression/And.cs new file mode 100644 index 0000000..727411b --- /dev/null +++ b/Assets/Scripts/Connector/Expression/And.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Expression +{ + [AddComponentMenu("UniFlow/Expression/And", (int) ConnectorType.And)] + public class And : ConnectorBase, IMessageCollectable + { + private IList Conditions { get; } = new List(); + + private bool Value + { + get => Conditions.All(x => x); + set => Conditions.Add(value); + } + + [SerializeField] private BoolCollector valueCollector = new BoolCollector(); + private BoolCollector ValueCollector => valueCollector; + + public override IObservable OnConnectAsObservable() + { + return Value ? ObservableFactory.ReturnMessage(this) : ObservableFactory.EmptyMessage(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ValueCollector, x => Value = x, nameof(Value)), + }; + } +} diff --git a/Assets/Scripts/Connector/Expression/And.cs.meta b/Assets/Scripts/Connector/Expression/And.cs.meta new file mode 100644 index 0000000..99f6600 --- /dev/null +++ b/Assets/Scripts/Connector/Expression/And.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dbd6c658e45e428dbad1bcf00f3d0b41 +timeCreated: 1570697873 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Expression/Not.cs b/Assets/Scripts/Connector/Expression/Not.cs new file mode 100644 index 0000000..8750cb3 --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Not.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Expression +{ + [AddComponentMenu("UniFlow/Expression/Not", (int) ConnectorType.Not)] + public class Not : ConnectorBase, IMessageCollectable + { + private IList Conditions { get; } = new List(); + + private bool Value + { + get => Conditions.All(x => !x); + set => Conditions.Add(value); + } + + [SerializeField] private BoolCollector valueCollector = new BoolCollector(); + private BoolCollector ValueCollector => valueCollector; + + public override IObservable OnConnectAsObservable() + { + return Value ? ObservableFactory.ReturnMessage(this) : ObservableFactory.EmptyMessage(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ValueCollector, x => Value = x, nameof(Value)), + }; + } +} diff --git a/Assets/Scripts/Connector/Expression/Not.cs.meta b/Assets/Scripts/Connector/Expression/Not.cs.meta new file mode 100644 index 0000000..ef2791a --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Not.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 81a19da1e9cb4927bcfaf06a4d3f4b18 +timeCreated: 1570698484 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Expression/Or.cs b/Assets/Scripts/Connector/Expression/Or.cs new file mode 100644 index 0000000..e860b43 --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Or.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Expression +{ + [AddComponentMenu("UniFlow/Expression/Or", (int) ConnectorType.Or)] + public class Or : ConnectorBase, IMessageCollectable + { + private IList Conditions { get; } = new List(); + + private bool Value + { + get => Conditions.Any(x => x); + set => Conditions.Add(value); + } + + [SerializeField] private BoolCollector valueCollector = new BoolCollector(); + private BoolCollector ValueCollector => valueCollector; + + public override IObservable OnConnectAsObservable() + { + return Value ? ObservableFactory.ReturnMessage(this) : ObservableFactory.EmptyMessage(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ValueCollector, x => Value = x, nameof(Value)), + }; + } +} diff --git a/Assets/Scripts/Connector/Expression/Or.cs.meta b/Assets/Scripts/Connector/Expression/Or.cs.meta new file mode 100644 index 0000000..2ee7084 --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Or.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 96712457dd254e3dabf5e90b9a8d0b58 +timeCreated: 1570698091 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Expression/Xor.cs b/Assets/Scripts/Connector/Expression/Xor.cs new file mode 100644 index 0000000..a80007b --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Xor.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Expression +{ + [AddComponentMenu("UniFlow/Expression/Xor", (int) ConnectorType.Xor)] + public class Xor : ConnectorBase, IMessageCollectable + { + private bool Left { get; set; } + private bool Right { get; set; } + + [SerializeField] private BoolCollector leftCollector = new BoolCollector(); + [SerializeField] private BoolCollector rightCollector = new BoolCollector(); + + private BoolCollector LeftCollector => leftCollector; + private BoolCollector RightCollector => rightCollector; + + public override IObservable OnConnectAsObservable() + { + return Left ^ Right ? ObservableFactory.ReturnMessage(this) : ObservableFactory.EmptyMessage(); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(LeftCollector, x => Left = x, nameof(Left)), + CollectableMessageAnnotationFactory.Create(RightCollector, x => Right = x, nameof(Right)), + }; + } +} diff --git a/Assets/Scripts/Connector/Expression/Xor.cs.meta b/Assets/Scripts/Connector/Expression/Xor.cs.meta new file mode 100644 index 0000000..7812a36 --- /dev/null +++ b/Assets/Scripts/Connector/Expression/Xor.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9866f4f694fb4034967352fe08366978 +timeCreated: 1570698518 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Interval.cs b/Assets/Scripts/Connector/Interval.cs deleted file mode 100644 index fc714e7..0000000 --- a/Assets/Scripts/Connector/Interval.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/Interval", 9001)] - public class Interval : EventPublisher - { - [SerializeField] private float seconds = default; - private float Seconds => seconds; - - public override IObservable OnPublishAsObservable() => - Observable - .Interval(TimeSpan.FromSeconds(Seconds)) - .Select(_ => EventMessage.Create(EventType.Interval, this, Seconds)); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic.meta b/Assets/Scripts/Connector/Logic.meta new file mode 100644 index 0000000..5f8cb41 --- /dev/null +++ b/Assets/Scripts/Connector/Logic.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7c45d5f01cd44fc5bb48d6cc72ae9df1 +timeCreated: 1567260030 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic/Counter.cs b/Assets/Scripts/Connector/Logic/Counter.cs new file mode 100644 index 0000000..0293540 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/Counter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/Counter", (int) ConnectorType.Counter)] + public class Counter : ConnectorBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private IntCollector initialCountCollector = default; + private IntCollector InitialCountCollector => initialCountCollector; + + private IReactiveProperty CounterProperty { get; } = new IntReactiveProperty(); + + public override IObservable OnConnectAsObservable() + { + CounterProperty.Value++; + return CounterProperty.AsMessageObservable(this, "Count"); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(InitialCountCollector, x => CounterProperty.Value = x, "InitialCount"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => CounterProperty.Value, "Count"), + }; + } +} diff --git a/Assets/Scripts/Connector/Logic/Counter.cs.meta b/Assets/Scripts/Connector/Logic/Counter.cs.meta new file mode 100644 index 0000000..7745f91 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/Counter.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fd840434b6a44fa78b7d56851568411d +timeCreated: 1571557099 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic/Empty.cs b/Assets/Scripts/Connector/Logic/Empty.cs new file mode 100644 index 0000000..d27e0d1 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/Empty.cs @@ -0,0 +1,15 @@ +using System; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/Empty", (int) ConnectorType.Empty)] + public class Empty : ConnectorBase + { + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this); + } + } +} diff --git a/Assets/Scripts/Connector/Empty.cs.meta b/Assets/Scripts/Connector/Logic/Empty.cs.meta similarity index 100% rename from Assets/Scripts/Connector/Empty.cs.meta rename to Assets/Scripts/Connector/Logic/Empty.cs.meta diff --git a/Assets/Scripts/Connector/Logic/Interval.cs b/Assets/Scripts/Connector/Logic/Interval.cs new file mode 100644 index 0000000..bbd2e71 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/Interval.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/Interval", (int) ConnectorType.Interval)] + public class Interval : ConnectorBase, IMessageCollectable + { + private const string MessageParameterKey = "Count"; + + [SerializeField] private float seconds = default; + [SerializeField] private bool ignoreTimeScale = default; + + [UsedImplicitly] public float Seconds + { + get => seconds; + set => seconds = value; + } + [UsedImplicitly] private bool IgnoreTimeScale + { + get => ignoreTimeScale; + set => ignoreTimeScale = value; + } + + [SerializeField] private FloatCollector secondsCollector = new FloatCollector(); + [SerializeField] private BoolCollector ignoreTimeScaleCollector = new BoolCollector(); + + private FloatCollector SecondsCollector => secondsCollector; + private BoolCollector IgnoreTimeScaleCollector => ignoreTimeScaleCollector; + + public override IObservable OnConnectAsObservable() + { + return Observable + .Interval(TimeSpan.FromSeconds(Seconds), IgnoreTimeScale ? Scheduler.MainThreadIgnoreTimeScale : Scheduler.MainThread) + .AsMessageObservable(this, MessageParameterKey); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SecondsCollector, x => Seconds = x, nameof(Seconds)), + CollectableMessageAnnotationFactory.Create(IgnoreTimeScaleCollector, x => IgnoreTimeScale = x, nameof(IgnoreTimeScale)), + }; + } +} diff --git a/Assets/Scripts/Connector/Interval.cs.meta b/Assets/Scripts/Connector/Logic/Interval.cs.meta similarity index 100% rename from Assets/Scripts/Connector/Interval.cs.meta rename to Assets/Scripts/Connector/Logic/Interval.cs.meta diff --git a/Assets/Scripts/Connector/Logic/IntervalFrame.cs b/Assets/Scripts/Connector/Logic/IntervalFrame.cs new file mode 100644 index 0000000..fadcaea --- /dev/null +++ b/Assets/Scripts/Connector/Logic/IntervalFrame.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/IntervalFrame", (int) ConnectorType.IntervalFrame)] + public class IntervalFrame : ConnectorBase, IMessageCollectable + { + private const string MessageParameterKey = "Count"; + + [SerializeField] private int frames = default; + [SerializeField] private FrameCountType frameCountType = FrameCountType.Update; + + [UsedImplicitly] public int Frames + { + get => frames; + set => frames = value; + } + [UsedImplicitly] private FrameCountType FrameCountType + { + get => frameCountType; + set => frameCountType = value; + } + + [SerializeField] private IntCollector framesCollector = new IntCollector(); + [SerializeField] private FrameCountTypeCollector frameCountTypeCollector = new FrameCountTypeCollector(); + + private IntCollector FramesCollector => framesCollector; + private FrameCountTypeCollector FrameCountTypeCollector => frameCountTypeCollector; + + public override IObservable OnConnectAsObservable() + { + return Observable + .IntervalFrame(Frames, FrameCountType) + .AsMessageObservable(this, MessageParameterKey); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(FramesCollector, x => Frames = x, nameof(Frames)), + CollectableMessageAnnotationFactory.Create(FrameCountTypeCollector, x => FrameCountType = x, nameof(FrameCountType)), + }; + } +} diff --git a/Assets/Scripts/Connector/Logic/IntervalFrame.cs.meta b/Assets/Scripts/Connector/Logic/IntervalFrame.cs.meta new file mode 100644 index 0000000..25f4c1c --- /dev/null +++ b/Assets/Scripts/Connector/Logic/IntervalFrame.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 630c642b63294c189aca21080b19d66f +timeCreated: 1570784067 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic/RandomFloat.cs b/Assets/Scripts/Connector/Logic/RandomFloat.cs new file mode 100644 index 0000000..a13b776 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/RandomFloat.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; +using Random = UnityEngine.Random; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/RandomFloat", (int) ConnectorType.RandomFloat)] + public class RandomFloat : ConnectorBase, IMessageCollectable, IMessageComposable + { + [SerializeField][Tooltip("Inclusive")] private float min = default; + [SerializeField][Tooltip("Inclusive")] private float max = default; + + private float Min + { + get => min; + set => min = value; + } + + private float Max + { + get => max; + set => max = value; + } + + private float Value { get; set; } + + [SerializeField] private FloatCollector minCollector = new FloatCollector(); + [SerializeField] private FloatCollector maxCollector = new FloatCollector(); + private FloatCollector MinCollector => minCollector; + private FloatCollector MaxCollector => maxCollector; + + public override IObservable OnConnectAsObservable() + { + Value = Random.Range(Min, Max); + return ObservableFactory.ReturnMessage(this, nameof(Value), Value); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(MinCollector, x => Min = x, nameof(Min)), + CollectableMessageAnnotationFactory.Create(MaxCollector, x => Max = x, nameof(Max)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(nameof(Value)), + }; + } +} diff --git a/Assets/Scripts/Connector/Logic/RandomFloat.cs.meta b/Assets/Scripts/Connector/Logic/RandomFloat.cs.meta new file mode 100644 index 0000000..6eeefa0 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/RandomFloat.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c6e1cb4b72c34006b5aac5fb4f112a17 +timeCreated: 1571370328 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic/RandomInt.cs b/Assets/Scripts/Connector/Logic/RandomInt.cs new file mode 100644 index 0000000..e969565 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/RandomInt.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; +using Random = UnityEngine.Random; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/RandomInt", (int) ConnectorType.RandomInt)] + public class RandomInt : ConnectorBase, IMessageCollectable, IMessageComposable + { + [SerializeField][Tooltip("Inclusive")] private int min = default; + [SerializeField][Tooltip("Exclusive")] private int max = default; + + private int Min + { + get => min; + set => min = value; + } + + private int Max + { + get => max; + set => max = value; + } + + private int Value { get; set; } + + [SerializeField] private IntCollector minCollector = new IntCollector(); + [SerializeField] private IntCollector maxCollector = new IntCollector(); + private IntCollector MinCollector => minCollector; + private IntCollector MaxCollector => maxCollector; + + public override IObservable OnConnectAsObservable() + { + Value = Random.Range(Min, Max); + return ObservableFactory.ReturnMessage(this, nameof(Value), Value); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(MinCollector, x => Min = x, nameof(Min)), + CollectableMessageAnnotationFactory.Create(MaxCollector, x => Max = x, nameof(Max)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(null, nameof(Value)), + }; + } +} diff --git a/Assets/Scripts/Connector/Logic/RandomInt.cs.meta b/Assets/Scripts/Connector/Logic/RandomInt.cs.meta new file mode 100644 index 0000000..7453b93 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/RandomInt.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6db01b8df4cc4359aef17a4615919c93 +timeCreated: 1571369898 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Logic/Timer.cs b/Assets/Scripts/Connector/Logic/Timer.cs new file mode 100644 index 0000000..8b8ab69 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/Timer.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/Timer", (int) ConnectorType.Timer)] + public class Timer : ConnectorBase, IMessageCollectable + { + private const string MessageParameterKey = "Count"; + + [SerializeField] private float seconds = default; + [SerializeField] private bool ignoreTimeScale = default; + + [UsedImplicitly] public float Seconds + { + get => seconds; + set => seconds = value; + } + [UsedImplicitly] private bool IgnoreTimeScale + { + get => ignoreTimeScale; + set => ignoreTimeScale = value; + } + + [SerializeField] private FloatCollector secondsCollector = new FloatCollector(); + [SerializeField] private BoolCollector ignoreTimeScaleCollector = new BoolCollector(); + + private FloatCollector SecondsCollector => secondsCollector; + private BoolCollector IgnoreTimeScaleCollector => ignoreTimeScaleCollector; + + public override IObservable OnConnectAsObservable() + { + return Observable + .Timer(TimeSpan.FromSeconds(Seconds), IgnoreTimeScale ? Scheduler.MainThreadIgnoreTimeScale : Scheduler.MainThread) + .AsMessageObservable(this, MessageParameterKey); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SecondsCollector, x => Seconds = x, nameof(Seconds)), + CollectableMessageAnnotationFactory.Create(IgnoreTimeScaleCollector, x => IgnoreTimeScale = x, nameof(IgnoreTimeScale)), + }; + } +} diff --git a/Assets/Scripts/Connector/Timer.cs.meta b/Assets/Scripts/Connector/Logic/Timer.cs.meta similarity index 100% rename from Assets/Scripts/Connector/Timer.cs.meta rename to Assets/Scripts/Connector/Logic/Timer.cs.meta diff --git a/Assets/Scripts/Connector/Logic/TimerFrame.cs b/Assets/Scripts/Connector/Logic/TimerFrame.cs new file mode 100644 index 0000000..1968a65 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/TimerFrame.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; + +namespace UniFlow.Connector.Logic +{ + [AddComponentMenu("UniFlow/Logic/TimerFrame", (int) ConnectorType.TimerFrame)] + public class TimerFrame : ConnectorBase, IMessageCollectable + { + private const string MessageParameterKey = "Count"; + + [SerializeField] private int frames = default; + [SerializeField] private FrameCountType frameCountType = FrameCountType.Update; + + [UsedImplicitly] public int Frames + { + get => frames; + set => frames = value; + } + [UsedImplicitly] private FrameCountType FrameCountType + { + get => frameCountType; + set => frameCountType = value; + } + + [SerializeField] private IntCollector framesCollector = new IntCollector(); + [SerializeField] private FrameCountTypeCollector frameCountTypeCollector = new FrameCountTypeCollector(); + + private IntCollector FramesCollector => framesCollector; + private FrameCountTypeCollector FrameCountTypeCollector => frameCountTypeCollector; + + public override IObservable OnConnectAsObservable() + { + return Observable + .TimerFrame(Frames, FrameCountType) + .AsMessageObservable(this, MessageParameterKey); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(FramesCollector, x => Frames = x, nameof(Frames)), + CollectableMessageAnnotationFactory.Create(FrameCountTypeCollector, x => FrameCountType = x, nameof(FrameCountType)), + }; + } + + [Serializable] + public class FrameCountTypeCollector : ValueCollectorBase + { + } +} diff --git a/Assets/Scripts/Connector/Logic/TimerFrame.cs.meta b/Assets/Scripts/Connector/Logic/TimerFrame.cs.meta new file mode 100644 index 0000000..e924c73 --- /dev/null +++ b/Assets/Scripts/Connector/Logic/TimerFrame.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b18415d1875b4818850abf7f449a7d81 +timeCreated: 1570783942 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Misc.meta b/Assets/Scripts/Connector/Misc.meta new file mode 100644 index 0000000..20686b0 --- /dev/null +++ b/Assets/Scripts/Connector/Misc.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f38f8a8f7028405bab60587ef43f6122 +timeCreated: 1568809846 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Misc/Receive.cs b/Assets/Scripts/Connector/Misc/Receive.cs new file mode 100644 index 0000000..04a0c78 --- /dev/null +++ b/Assets/Scripts/Connector/Misc/Receive.cs @@ -0,0 +1,24 @@ +using System; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Misc +{ + [AddComponentMenu("UniFlow/Misc/Receive", (int) ConnectorType.Receive)] + public class Receive : ConnectorBase + { + // force return false to prevent triggering + public override bool ActAsTrigger + { + get => false; + set + { + } + } + + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this); + } + } +} diff --git a/Assets/Scripts/Connector/Misc/Receive.cs.meta b/Assets/Scripts/Connector/Misc/Receive.cs.meta new file mode 100644 index 0000000..bf4da81 --- /dev/null +++ b/Assets/Scripts/Connector/Misc/Receive.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ddef13599bdc4654af51f346d00c9c72 +timeCreated: 1568622905 \ No newline at end of file diff --git a/Assets/Scripts/Connector/Misc/Toss.cs b/Assets/Scripts/Connector/Misc/Toss.cs new file mode 100644 index 0000000..f70865e --- /dev/null +++ b/Assets/Scripts/Connector/Misc/Toss.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.Misc +{ + [AddComponentMenu("UniFlow/Misc/Toss", (int) ConnectorType.Toss)] + public class Toss : ConnectorBase, IMessageCollectable + { + [SerializeField] private List targets = default; + private IList Targets => targets; + + private GameObject TargetGameObject + { + set => Targets.Add(value); + } + + [SerializeField] private GameObjectCollector targetGameObjectCollector = new GameObjectCollector(); + private GameObjectCollector TargetGameObjectCollector => targetGameObjectCollector; + + public override IObservable OnConnectAsObservable() + { + foreach (var target in Targets) + { + if (target != default && target.activeSelf) + { + (target.GetComponent() as IConnector)?.Connect(ObservableFactory.ReturnMessage(this)); + } + } + return ObservableFactory.ReturnMessage(this); + } + + public IEnumerable GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(TargetGameObjectCollector, x => TargetGameObject = x, nameof(TargetGameObject)), + }; + } +} diff --git a/Assets/Scripts/Connector/Misc/Toss.cs.meta b/Assets/Scripts/Connector/Misc/Toss.cs.meta new file mode 100644 index 0000000..a64af49 --- /dev/null +++ b/Assets/Scripts/Connector/Misc/Toss.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7fcda12b43d340ab9f5b06900efb58d1 +timeCreated: 1568622711 \ No newline at end of file diff --git a/Assets/Scripts/Connector/PhysicsCollision2DEvent.cs b/Assets/Scripts/Connector/PhysicsCollision2DEvent.cs deleted file mode 100644 index 74cdfc4..0000000 --- a/Assets/Scripts/Connector/PhysicsCollision2DEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/PhyticsCollision2DEvent", 201)] - public class PhysicsCollision2DEvent : EventPublisher - { - [SerializeField] private PhysicsCollision2DEventType physicsCollision2DEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private PhysicsCollision2DEventType PhysicsCollision2DEventType => physicsCollision2DEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(x => EventMessage.Create(EventType.PhysicsCollision2DEvent, Component, PhysicsCollision2DEventData.Create(PhysicsCollision2DEventType, x))); - - private IObservable OnEventAsObservable() - { - switch (PhysicsCollision2DEventType) - { - case PhysicsCollision2DEventType.CollisionEnter2D: - return Component.OnCollisionEnter2DAsObservable(); - case PhysicsCollision2DEventType.CollisionExit2D: - return Component.OnCollisionExit2DAsObservable(); - case PhysicsCollision2DEventType.CollisionStay2D: - return Component.OnCollisionStay2DAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum PhysicsCollision2DEventType - { - CollisionEnter2D, - CollisionExit2D, - CollisionStay2D, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/PhysicsCollisionEvent.cs b/Assets/Scripts/Connector/PhysicsCollisionEvent.cs deleted file mode 100644 index 8e2b8de..0000000 --- a/Assets/Scripts/Connector/PhysicsCollisionEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/PhysicsCollisionEvent", 200)] - public class PhysicsCollisionEvent : EventPublisher - { - [SerializeField] private PhysicsCollisionEventType physicsCollisionEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private PhysicsCollisionEventType PhysicsCollisionEventType => physicsCollisionEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(x => EventMessage.Create(EventType.PhysicsCollisionEvent, Component, PhysicsCollisionEventData.Create(PhysicsCollisionEventType, x))); - - private IObservable OnEventAsObservable() - { - switch (PhysicsCollisionEventType) - { - case PhysicsCollisionEventType.CollisionEnter: - return Component.OnCollisionEnterAsObservable(); - case PhysicsCollisionEventType.CollisionExit: - return Component.OnCollisionExitAsObservable(); - case PhysicsCollisionEventType.CollisionStay: - return Component.OnCollisionStayAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum PhysicsCollisionEventType - { - CollisionEnter, - CollisionExit, - CollisionStay, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/PhysicsTrigger2DEvent.cs b/Assets/Scripts/Connector/PhysicsTrigger2DEvent.cs deleted file mode 100644 index 29b1755..0000000 --- a/Assets/Scripts/Connector/PhysicsTrigger2DEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/PhysicsTrigger2DEvent", 203)] - public class PhysicsTrigger2DEvent : EventPublisher - { - [SerializeField] private PhysicsTrigger2DEventType physicsTrigger2DEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private PhysicsTrigger2DEventType PhysicsTrigger2DEventType => physicsTrigger2DEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(x => EventMessage.Create(EventType.PhysicsTrigger2DEvent, Component, PhysicsTrigger2DEventData.Create(PhysicsTrigger2DEventType, x))); - - private IObservable OnEventAsObservable() - { - switch (PhysicsTrigger2DEventType) - { - case PhysicsTrigger2DEventType.TriggerEnter2D: - return Component.OnTriggerEnter2DAsObservable(); - case PhysicsTrigger2DEventType.TriggerExit2D: - return Component.OnTriggerExit2DAsObservable(); - case PhysicsTrigger2DEventType.TriggerStay2D: - return Component.OnTriggerStay2DAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum PhysicsTrigger2DEventType - { - TriggerEnter2D, - TriggerExit2D, - TriggerStay2D, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/PhysicsTriggerEvent.cs b/Assets/Scripts/Connector/PhysicsTriggerEvent.cs deleted file mode 100644 index d2d8acd..0000000 --- a/Assets/Scripts/Connector/PhysicsTriggerEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/PhyticsTriggerEvent", 202)] - public class PhysicsTriggerEvent : EventPublisher - { - [SerializeField] private PhysicsTriggerEventType physicsTriggerEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private PhysicsTriggerEventType PhysicsTriggerEventType => physicsTriggerEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(x => EventMessage.Create(EventType.PhysicsTriggerEvent, Component, PhysicsTriggerEventData.Create(PhysicsTriggerEventType, x))); - - private IObservable OnEventAsObservable() - { - switch (PhysicsTriggerEventType) - { - case PhysicsTriggerEventType.TriggerEnter: - return Component.OnTriggerEnterAsObservable(); - case PhysicsTriggerEventType.TriggerExit: - return Component.OnTriggerExitAsObservable(); - case PhysicsTriggerEventType.TriggerStay: - return Component.OnTriggerStayAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum PhysicsTriggerEventType - { - TriggerEnter, - TriggerExit, - TriggerStay, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/PlayableController.cs b/Assets/Scripts/Connector/PlayableController.cs deleted file mode 100644 index 028a0ff..0000000 --- a/Assets/Scripts/Connector/PlayableController.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UnityEngine; -using UnityEngine.Playables; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/PlayableController", 304)] - public class PlayableController : EventPublisher - { - [SerializeField] - [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] - private PlayableDirector playableDirector = default; - private PlayableDirector PlayableDirector => playableDirector ? playableDirector : playableDirector = GetComponent(); - - private IDisposable Disposable { get; } = new CompositeDisposable(); - - public override IObservable OnPublishAsObservable() => - Observable - .Create( - observer => - { - PlayableDirector.Play(); - observer.OnNext(EventMessage.Create(EventType.PlayableController, PlayableDirector, PlayableControllerEventData.Create())); - return Disposable; - } - ); - - private void OnDestroy() - { - Disposable.Dispose(); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/RectTransformEvent.cs b/Assets/Scripts/Connector/RectTransformEvent.cs deleted file mode 100644 index 54561b4..0000000 --- a/Assets/Scripts/Connector/RectTransformEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/RectTransformEvent", 103)] - public class RectTransformEvent : EventPublisher - { - [SerializeField] private RectTransformEventType rectTransformEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private RectTransformEventType RectTransformEventType => rectTransformEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(_ => EventMessage.Create(EventType.RectTransformEvent, Component, RectTransformEventData.Create(RectTransformEventType))); - - private IObservable OnEventAsObservable() - { - switch (RectTransformEventType) - { - case RectTransformEventType.CanvasGroupChanged: - return Component.OnCanvasGroupChangedAsObservable(); - case RectTransformEventType.RectTransformDimensionsChange: - return Component.OnRectTransformDimensionsChangeAsObservable(); - case RectTransformEventType.RectTransformRemoved: - return Component.OnRectTransformRemovedAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum RectTransformEventType - { - CanvasGroupChanged, - RectTransformDimensionsChange, - RectTransformRemoved, - } - } \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher.meta b/Assets/Scripts/Connector/SignalPublisher.meta new file mode 100644 index 0000000..1b83d19 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 51ad1a3208304325969fb981ac2600e4 +timeCreated: 1570613103 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs b/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs new file mode 100644 index 0000000..c5943fe --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalPublisher +{ + [AddComponentMenu("UniFlow/SignalPublisher/HandleEventSignalPublisher", (int) ConnectorType.HandleEventSignalPublisher)] + public class HandleEventSignalPublisher : SignalPublisherBase, IMessageCollectable + { + [SerializeField] private HandleEventType handleEventType = default; + private HandleEventType HandleEventType + { + get => handleEventType; + set => handleEventType = value; + } + + [SerializeField] private HandleEventTypeCollector handleEventTypeCollector = new HandleEventTypeCollector(); + private HandleEventTypeCollector HandleEventTypeCollector => handleEventTypeCollector; + + protected override HandleEventSignal GetSignal() => + HandleEventSignal.Create(HandleEventType); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(HandleEventTypeCollector, x => HandleEventType = x, nameof(HandleEventType)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs.meta b/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs.meta new file mode 100644 index 0000000..8652111 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/HandleEventSignalPublisher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4427fa2e03fc4b37bfcfbb8b138ef7d0 +timeCreated: 1571659444 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs b/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs new file mode 100644 index 0000000..3dce4b4 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs @@ -0,0 +1,59 @@ +using System.Collections.Generic; +using UniFlow.Connector.Controller; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalPublisher +{ + [AddComponentMenu("UniFlow/SignalPublisher/MusicControlSignalPublisher", (int) ConnectorType.MusicControlSignalPublisher)] + public class MusicControlSignalPublisher : SignalPublisherBase, IMessageCollectable + { + [SerializeField] private AudioControlMethod audioControlMethod = default; + [SerializeField] private AudioClip audioClip = default; + [SerializeField] private bool loop = true; + [SerializeField] private bool rewindSameClip = false; + + private AudioControlMethod AudioControlMethod + { + get => audioControlMethod; + set => audioControlMethod = value; + } + private AudioClip AudioClip + { + get => audioClip; + set => audioClip = value; + } + private bool Loop + { + get => loop; + set => loop = value; + } + private bool RewindSameClip + { + get => rewindSameClip; + set => rewindSameClip = value; + } + + [SerializeField] private AudioControlMethodCollector audioControlMethodCollector = new AudioControlMethodCollector(); + [SerializeField] private AudioClipCollector audioClipCollector = new AudioClipCollector(); + [SerializeField] private BoolCollector loopCollector = default; + [SerializeField] private BoolCollector rewindSameClipCollector = new BoolCollector(); + + private AudioControlMethodCollector AudioControlMethodCollector => audioControlMethodCollector; + private AudioClipCollector AudioClipCollector => audioClipCollector; + private BoolCollector LoopCollector => loopCollector; + private BoolCollector RewindSameClipCollector => rewindSameClipCollector; + + protected override MusicControlSignal GetSignal() => + MusicControlSignal.Create(AudioControlMethod, AudioClip, Loop, RewindSameClip); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(AudioControlMethodCollector, x => AudioControlMethod = x, nameof(AudioControlMethod)), + CollectableMessageAnnotationFactory.Create(AudioClipCollector, x => AudioClip = x, nameof(AudioClip)), + CollectableMessageAnnotationFactory.Create(LoopCollector, x => Loop = x, nameof(Loop)), + CollectableMessageAnnotationFactory.Create(RewindSameClipCollector, x => RewindSameClip = x, nameof(RewindSameClip)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs.meta b/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs.meta new file mode 100644 index 0000000..d1ff8da --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicControlSignalPublisher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a0c997ccff6d44edadaae94badb1e543 +timeCreated: 1572430217 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs b/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs new file mode 100644 index 0000000..a69767a --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalPublisher +{ + [AddComponentMenu("UniFlow/SignalPublisher/MusicDuckingSignalPublisher", (int) ConnectorType.MusicDuckingSignalPublisher)] + public class MusicDuckingSignalPublisher : SignalPublisherBase, IMessageCollectable + { + [SerializeField] private float volume = default; + [SerializeField] private float duration = default; + + private float Volume + { + get => volume; + set => volume = value; + } + private float Duration + { + get => duration; + set => duration = value; + } + + [SerializeField] private FloatCollector volumeCollector = new FloatCollector(); + [SerializeField] private FloatCollector durationCollector = new FloatCollector(); + + private FloatCollector VolumeCollector => volumeCollector; + private FloatCollector DurationCollector => durationCollector; + + protected override MusicDuckingSignal GetSignal() => + MusicDuckingSignal.Create(Volume, Duration); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(VolumeCollector, x => Volume = x, nameof(Volume)), + CollectableMessageAnnotationFactory.Create(DurationCollector, x => Duration = x, nameof(Duration)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs.meta b/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs.meta new file mode 100644 index 0000000..aa5458f --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicDuckingSignalPublisher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7bdfb8091a24444cbc5977b215dca58b +timeCreated: 1572426589 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs b/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs new file mode 100644 index 0000000..a913ed6 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalPublisher +{ + [AddComponentMenu("UniFlow/SignalPublisher/MusicPitchSignalPublisher", (int) ConnectorType.MusicPitchSignalPublisher)] + public class MusicPitchSignalPublisher : SignalPublisherBase, IMessageCollectable + { + [SerializeField] private float pitch = default; + [SerializeField] private float duration = default; + + private float Pitch + { + get => pitch; + set => pitch = value; + } + private float Duration + { + get => duration; + set => duration = value; + } + + [SerializeField] private FloatCollector pitchCollector = new FloatCollector(); + [SerializeField] private FloatCollector durationCollector = new FloatCollector(); + + private FloatCollector PitchCollector => pitchCollector; + private FloatCollector DurationCollector => durationCollector; + + protected override MusicPitchSignal GetSignal() => + MusicPitchSignal.Create(Pitch, Duration); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(PitchCollector, x => Pitch = x, nameof(Pitch)), + CollectableMessageAnnotationFactory.Create(DurationCollector, x => Duration = x, nameof(Duration)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs.meta b/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs.meta new file mode 100644 index 0000000..43c118c --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/MusicPitchSignalPublisher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2e77cd52cefb4b8ba2c36e99f31fec94 +timeCreated: 1572509301 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs b/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs new file mode 100644 index 0000000..bfb0707 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs @@ -0,0 +1,99 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalPublisher +{ + [AddComponentMenu("UniFlow/SignalPublisher/StringSignalPublisher", (int) ConnectorType.StringSignalPublisher)] + public class StringSignalPublisher : SignalPublisherBase, + IMessageCollectable + { + [SerializeField] private string signalName = default; + [SerializeField] private bool boolParameter = default; + [SerializeField] private int intParameter = default; + [SerializeField] private float floatParameter = default; + [SerializeField] private string stringParameter = default; + [SerializeField] private Object objectParameter = default; + [SerializeField] private ScriptableObject scriptableObjectParameter = default; + + private string SignalName + { + get => signalName; + set => signalName = value; + } + private bool BoolParameter + { + get => boolParameter; + set => boolParameter = value; + } + private int IntParameter + { + get => intParameter; + set => intParameter = value; + } + private float FloatParameter + { + get => floatParameter; + set => floatParameter = value; + } + private string StringParameter + { + get => stringParameter; + set => stringParameter = value; + } + private Object ObjectParameter + { + get => objectParameter; + set => objectParameter = value; + } + private ScriptableObject ScriptableObjectParameter + { + get => scriptableObjectParameter; + set => scriptableObjectParameter = value; + } + + [SerializeField] private StringCollector signalNameCollector = new StringCollector(); + [SerializeField] private BoolCollector boolCollector = new BoolCollector(); + [SerializeField] private IntCollector intCollector = new IntCollector(); + [SerializeField] private FloatCollector floatCollector = new FloatCollector(); + [SerializeField] private StringCollector stringCollector = new StringCollector(); + [SerializeField] private ObjectCollector objectCollector = new ObjectCollector(); + [SerializeField] private ScriptableObjectCollector scriptableObjectCollector = new ScriptableObjectCollector(); + + private StringCollector SignalNameCollector => signalNameCollector; + private BoolCollector BoolCollector => boolCollector; + private IntCollector IntCollector => intCollector; + private FloatCollector FloatCollector => floatCollector; + private StringCollector StringCollector => stringCollector; + private ObjectCollector ObjectCollector => objectCollector; + private ScriptableObjectCollector ScriptableObjectCollector => scriptableObjectCollector; + + protected override StringSignal GetSignal() + { + return StringSignal + .Create( + SignalName, + new StringSignal.SignalParameter( + BoolParameter, + IntParameter, + FloatParameter, + StringParameter, + ObjectParameter, + ScriptableObjectParameter + ) + ); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SignalNameCollector, x => SignalName = x, nameof(SignalName)), + CollectableMessageAnnotationFactory.Create(BoolCollector, x => BoolParameter = x, nameof(BoolParameter)), + CollectableMessageAnnotationFactory.Create(IntCollector, x => IntParameter = x, nameof(IntParameter)), + CollectableMessageAnnotationFactory.Create(FloatCollector, x => FloatParameter = x, nameof(FloatParameter)), + CollectableMessageAnnotationFactory.Create(StringCollector, x => StringParameter = x, nameof(StringParameter)), + CollectableMessageAnnotationFactory.Create(ObjectCollector, x => ObjectParameter = x, nameof(ObjectParameter)), + CollectableMessageAnnotationFactory.Create(ScriptableObjectCollector, x => ScriptableObjectParameter = x, nameof(ScriptableObjectParameter)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs.meta b/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs.meta new file mode 100644 index 0000000..6e17e92 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisher/StringSignalPublisher.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 88cd519c3d124dacb1877d2fdcbe9d40 +timeCreated: 1570613103 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalPublisherBase.cs b/Assets/Scripts/Connector/SignalPublisherBase.cs new file mode 100644 index 0000000..72f243a --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisherBase.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using UniFlow.Signal; +using UniFlow.Utility; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector +{ + public abstract class SignalPublisherBase : ConnectorBase + where TSignal : ISignal + { + [SerializeField] private TSignal signal = default; + + [Inject] private ISignalPublisher Publisher { get; } + + // ReSharper disable once ConvertToAutoPropertyWhenPossible + protected TSignal Signal + { + get => signal; + set => signal = value; + } + + protected virtual TSignal GetSignal() + { + return Signal; + } + + public override IObservable OnConnectAsObservable() + { + Publisher.Publish(GetSignal()); + return ObservableFactory.ReturnMessage(this, nameof(Signal), GetSignal()); + } + } + + public abstract class SignalPublisherBase : SignalPublisherBase, IMessageCollectable + where TSignal : ISignal + where TSignalCollector : ValueCollectorBase, new() + { + [SerializeField] private TSignalCollector enumCollector = new TSignalCollector(); + + private TSignalCollector EnumCollector => enumCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(EnumCollector, x => Signal = x, nameof(Signal)), + }; + } + + public abstract class SignalPublisherWithParameterBase : SignalPublisherBase + where TSignal : SignalBase, new() + where TParameter : Enum + { + [SerializeField] private TParameter enumValue = default; + private TParameter EnumValue => enumValue; + + protected override TSignal GetSignal() + { + return SignalBase.Create(EnumValue); + } + } + + public abstract class SignalPublisherWithParameterBase : SignalPublisherBase, IMessageCollectable + where TSignal : SignalBase, new() + where TParameterCollector : ValueCollectorBase, new() + where TParameter : Enum + { + [SerializeField] private TParameter enumValue = default; + private TParameter EnumValue + { + get => enumValue; + set => enumValue = value; + } + + [SerializeField] private TParameterCollector enumCollector = new TParameterCollector(); + private TParameterCollector EnumCollector => enumCollector; + + protected override TSignal GetSignal() + { + return SignalBase.Create(EnumValue); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new [] + { + CollectableMessageAnnotationFactory.Create(EnumCollector, x => EnumValue = x, nameof(EnumValue)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalPublisherBase.cs.meta b/Assets/Scripts/Connector/SignalPublisherBase.cs.meta new file mode 100644 index 0000000..b7bf827 --- /dev/null +++ b/Assets/Scripts/Connector/SignalPublisherBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8879c3ee2da64f788d523a264173f92a +timeCreated: 1570585876 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver.meta b/Assets/Scripts/Connector/SignalReceiver.meta new file mode 100644 index 0000000..c5d6eb9 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7f5ca0679ad24724b4d549ec64037285 +timeCreated: 1570613813 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs b/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs new file mode 100644 index 0000000..af76aad --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalReceiver +{ + [AddComponentMenu("UniFlow/SignalReceiver/HandleEventSignalReceiver", (int) ConnectorType.HandleEventSignalPublisher)] + public class HandleEventSignalReceiver : SignalReceiverBase, IMessageCollectable + { + [SerializeField] private HandleEventType handleEventType = default; + private HandleEventType HandleEventType + { + get => handleEventType; + set => handleEventType = value; + } + + [SerializeField] private HandleEventTypeCollector handleEventTypeCollector = new HandleEventTypeCollector(); + private HandleEventTypeCollector HandleEventTypeCollector => handleEventTypeCollector; + + protected override HandleEventSignal GetSignal() => + HandleEventSignal.Create(HandleEventType); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(HandleEventTypeCollector, x => HandleEventType = x, nameof(HandleEventType)), + }; + } +} diff --git a/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs.meta b/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs.meta new file mode 100644 index 0000000..d42d515 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/HandleEventSignalReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2f6a4fa5c1694dc996f906163522641d +timeCreated: 1571659655 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs b/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs new file mode 100644 index 0000000..f0dbc99 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Linq; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalReceiver +{ + [AddComponentMenu("UniFlow/SignalReceiver/MusicControlSignalReceiver", (int) ConnectorType.MusicControlSignalReceiver)] + public class MusicControlSignalReceiver : SignalReceiverBase + { + protected override MusicControlSignal GetSignal() => + MusicControlSignal.Create(); + + public override IEnumerable GetMessageComposableAnnotations() => + base.GetMessageComposableAnnotations() + .Concat( + new[] + { + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.AudioControlMethod, nameof(ReceivedSignal.AudioControlMethod)), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.AudioClip, nameof(ReceivedSignal.AudioClip)), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Loop, nameof(ReceivedSignal.Loop)), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.RewindSameClip, nameof(ReceivedSignal.RewindSameClip)), + } + ); + } +} diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs.meta b/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs.meta new file mode 100644 index 0000000..4a67c0e --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicControlSignalReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 35a9753467824cca8a141e2771f39b93 +timeCreated: 1572430059 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs b/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs new file mode 100644 index 0000000..69fe852 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Linq; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalReceiver +{ + [AddComponentMenu("UniFlow/SignalReceiver/MusicDuckingSignalReceiver", (int) ConnectorType.MusicDuckingSignalReceiver)] + public class MusicDuckingSignalReceiver : SignalReceiverBase + { + protected override MusicDuckingSignal GetSignal() => + MusicDuckingSignal.Create(); + + public override IEnumerable GetMessageComposableAnnotations() => + base.GetMessageComposableAnnotations() + .Concat( + new[] + { + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Volume, nameof(ReceivedSignal.Volume)), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Duration, nameof(ReceivedSignal.Duration)), + } + ); + } +} diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs.meta b/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs.meta new file mode 100644 index 0000000..0d0dd4e --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicDuckingSignalReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 86ad318d1bf74d29aa9db8f6934ff5ae +timeCreated: 1572427115 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs b/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs new file mode 100644 index 0000000..abef868 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using System.Linq; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalReceiver +{ + [AddComponentMenu("UniFlow/SignalReceiver/MusicPitchSignalReceiver", (int) ConnectorType.MusicPitchSignalReceiver)] + public class MusicPitchSignalReceiver : SignalReceiverBase + { + protected override MusicPitchSignal GetSignal() => + MusicPitchSignal.Create(); + + public override IEnumerable GetMessageComposableAnnotations() => + base.GetMessageComposableAnnotations() + .Concat( + new[] + { + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Pitch, nameof(ReceivedSignal.Pitch)), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Duration, nameof(ReceivedSignal.Duration)), + } + ); + } +} diff --git a/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs.meta b/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs.meta new file mode 100644 index 0000000..4de3b3b --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/MusicPitchSignalReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 558f9d051a1f41f091d3695ea95e3ed0 +timeCreated: 1572509379 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs b/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs new file mode 100644 index 0000000..d75c736 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs @@ -0,0 +1,46 @@ +using System.Collections.Generic; +using UniFlow.Signal; +using UnityEngine; + +namespace UniFlow.Connector.SignalReceiver +{ + [AddComponentMenu("UniFlow/SignalReceiver/StringSignalReceiver", (int) ConnectorType.StringSignalReceiver)] + public class StringSignalReceiver : SignalReceiverBase, + IMessageCollectable, + IMessageComposable + { + [SerializeField] private string signalName = default; + + private string SignalName + { + get => signalName; + set => signalName = value; + } + + [SerializeField] private StringCollector signalNameCollector = new StringCollector(); + + private StringCollector SignalNameCollector => signalNameCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SignalNameCollector, x => SignalName = x, nameof(SignalName)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.BoolValue, "BoolParameter"), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.IntValue, "IntParameter"), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.FloatValue, "FloatParameter"), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.StringValue, "StringParameter"), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.ObjectValue, "ObjectParameter"), + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal.Parameter.ScriptableObjectValue, "ScriptableObjectParameter"), + }; + + protected override StringSignal GetSignal() + { + return StringSignal.Create(SignalName); + } + } +} diff --git a/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs.meta b/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs.meta new file mode 100644 index 0000000..15860d3 --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiver/StringSignalReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 99d4ba2251f74977b227ba722112eb59 +timeCreated: 1570613813 \ No newline at end of file diff --git a/Assets/Scripts/Connector/SignalReceiverBase.cs b/Assets/Scripts/Connector/SignalReceiverBase.cs new file mode 100644 index 0000000..9e81dae --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiverBase.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using UniFlow.Signal; +using UniFlow.Utility; +using UniRx; +using UnityEngine; +using Zenject; + +namespace UniFlow.Connector +{ + public abstract class SignalReceiverBase : ConnectorBase, IMessageComposable + { + [SerializeField] private TSignal signal = default; + + [Inject] private ISignalReceiver SignalReceiver { get; } + + protected TSignal Signal + { + get => signal; + set => signal = value; + } + + protected TSignal ReceivedSignal { get; private set; } + + protected virtual TSignal GetSignal() + { + return Signal; + } + + public override IObservable OnConnectAsObservable() + { + return SignalReceiver.OnReceiveAsObservable(GetSignal()).Do(x => ReceivedSignal = x).AsMessageObservable(this, "Signal"); + } + + public virtual IEnumerable GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => ReceivedSignal, "Signal"), + }; + } + + public abstract class SignalReceiverBase : SignalReceiverBase, IMessageCollectable + where TSignalCollector : ValueCollectorBase, new() + { + [SerializeField] private TSignalCollector signalCollector = new TSignalCollector(); + + private TSignalCollector SignalCollector => signalCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(SignalCollector, x => Signal = x, "Signal"), + }; + } + + + public abstract class SignalReceiverWithParameterBase : SignalReceiverBase + where TSignal : SignalBase, new() + where TParameter : Enum + { + [SerializeField] private TParameter enumValue = default; + private TParameter EnumValue => enumValue; + + protected override TSignal GetSignal() + { + return SignalBase.Create(EnumValue); + } + } +} diff --git a/Assets/Scripts/Connector/SignalReceiverBase.cs.meta b/Assets/Scripts/Connector/SignalReceiverBase.cs.meta new file mode 100644 index 0000000..35dd21a --- /dev/null +++ b/Assets/Scripts/Connector/SignalReceiverBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c999e5be3bec4c2d834a03fa9358302c +timeCreated: 1570613871 \ No newline at end of file diff --git a/Assets/Scripts/Connector/TimelineSignal.cs b/Assets/Scripts/Connector/TimelineSignal.cs deleted file mode 100644 index cdb453d..0000000 --- a/Assets/Scripts/Connector/TimelineSignal.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using EventConnector.Message; -using JetBrains.Annotations; -using UniRx; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace EventConnector.Connector -{ - // Timeline SignalReceiver cannot serialize [Serializable] class - // So I provide overloads to construct TimelineEventData - [AddComponentMenu("Event Connector/TimelineSignal", 305)] - public class TimelineSignal : EventPublisher - { - private ISubject Subject { get; } = new Subject(); - - public override IObservable OnPublishAsObservable() => - Subject - .Take(1) - .Select(x => EventMessage.Create(EventType.TimelineSignal, this, x)); - - [UsedImplicitly] - public void Dispatch() - { - Subject.OnNext(new TimelineEventData()); - } - - [UsedImplicitly] - public void Dispatch(float floatParameter) - { - Subject.OnNext(new TimelineEventData(floatParameter)); - } - - [UsedImplicitly] - public void Dispatch(int intParameter) - { - Subject.OnNext(new TimelineEventData(intParameter)); - } - - [UsedImplicitly] - public void Dispatch(string stringParameter) - { - Subject.OnNext(new TimelineEventData(stringParameter)); - } - - [UsedImplicitly] - public void Dispatch(Object objectReferenceParameter) - { - Subject.OnNext(new TimelineEventData(objectReferenceParameter)); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/Timer.cs b/Assets/Scripts/Connector/Timer.cs deleted file mode 100644 index bb88485..0000000 --- a/Assets/Scripts/Connector/Timer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using UniRx; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/Timer", 9000)] - public class Timer : EventPublisher - { - [SerializeField] private float seconds = default; - private float Seconds => seconds; - - public override IObservable OnPublishAsObservable() => - Observable - .Timer(TimeSpan.FromSeconds(Seconds)) - .Select(_ => EventMessage.Create(EventType.Timer, this, Seconds)); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/TransformEvent.cs b/Assets/Scripts/Connector/TransformEvent.cs deleted file mode 100644 index 9e590a2..0000000 --- a/Assets/Scripts/Connector/TransformEvent.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System; -using EventConnector.Message; -using UniRx; -using UniRx.Triggers; -using UnityEngine; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/TransformEvent", 102)] - public class TransformEvent : EventPublisher - { - [SerializeField] private TransformEventType transformEventType = default; - [SerializeField] - [Tooltip("If you do not specify it will be used self instance")] - private Component component = default; - - private TransformEventType TransformEventType => transformEventType; - private Component Component => component ? component : component = this; - - public override IObservable OnPublishAsObservable() => - OnEventAsObservable() - .Select(_ => EventMessage.Create(EventType.TransformEvent, Component, TransformEventData.Create(TransformEventType))); - - private IObservable OnEventAsObservable() - { - switch (TransformEventType) - { - case TransformEventType.BeforeTransformParentChanged: - return Component.OnBeforeTransformParentChangedAsObservable(); - case TransformEventType.TransformParentChanged: - return Component.OnTransformParentChangedAsObservable(); - case TransformEventType.TransformChildrenChanged: - return Component.OnTransformChildrenChangedAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } - - public enum TransformEventType - { - BeforeTransformParentChanged, - TransformParentChanged, - TransformChildrenChanged, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/UIBehaviourEventTrigger.cs b/Assets/Scripts/Connector/UIBehaviourEventTrigger.cs deleted file mode 100644 index dc0cc25..0000000 --- a/Assets/Scripts/Connector/UIBehaviourEventTrigger.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using UniRx; -using UniRx.Triggers; -using UnityEngine; -using UnityEngine.EventSystems; - -namespace EventConnector.Connector -{ - [AddComponentMenu("Event Connector/UIBehaviourEventTrigger", 101)] - public class UIBehaviourEventTrigger : EventPublisher - { - [SerializeField] private EventTriggerType eventTriggerType = default; - private EventTriggerType EventTriggerType => eventTriggerType; - - [SerializeField] - [Tooltip("If you do not specify it will be obtained by GameObject.GetComponent()")] - private UIBehaviour uiBehaviour = default; - private UIBehaviour UIBehaviour => uiBehaviour ? uiBehaviour : uiBehaviour = GetComponent(); - - public override IObservable OnPublishAsObservable() => - OnEventTriggerAsObservable() - .Select(x => EventMessage.Create(EventType.UIBehaviourEventTrigger, UIBehaviour, x)); - - private IObservable OnEventTriggerAsObservable() - { - switch (EventTriggerType) - { - case EventTriggerType.PointerEnter: - return UIBehaviour.OnPointerEnterAsObservable(); - case EventTriggerType.PointerExit: - return UIBehaviour.OnPointerExitAsObservable(); - case EventTriggerType.PointerDown: - return UIBehaviour.OnPointerDownAsObservable(); - case EventTriggerType.PointerUp: - return UIBehaviour.OnPointerUpAsObservable(); - case EventTriggerType.PointerClick: - return UIBehaviour.OnPointerClickAsObservable(); - case EventTriggerType.Drag: - return UIBehaviour.OnDragAsObservable(); - case EventTriggerType.Drop: - return UIBehaviour.OnDropAsObservable(); - case EventTriggerType.Scroll: - return UIBehaviour.OnScrollAsObservable(); - case EventTriggerType.UpdateSelected: - return UIBehaviour.OnUpdateSelectedAsObservable(); - case EventTriggerType.Select: - return UIBehaviour.OnSelectAsObservable(); - case EventTriggerType.Deselect: - return UIBehaviour.OnDeselectAsObservable(); - case EventTriggerType.Move: - return UIBehaviour.OnMoveAsObservable(); - case EventTriggerType.InitializePotentialDrag: - return UIBehaviour.OnInitializePotentialDragAsObservable(); - case EventTriggerType.BeginDrag: - return UIBehaviour.OnBeginDragAsObservable(); - case EventTriggerType.EndDrag: - return UIBehaviour.OnEndDragAsObservable(); - case EventTriggerType.Submit: - return UIBehaviour.OnSubmitAsObservable(); - case EventTriggerType.Cancel: - return UIBehaviour.OnCancelAsObservable(); - default: - throw new ArgumentOutOfRangeException(); - } - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer.meta b/Assets/Scripts/Connector/ValueComparer.meta new file mode 100644 index 0000000..66f582f --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dd05c638351a47eab94d86260758052a +timeCreated: 1568810234 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs b/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs new file mode 100644 index 0000000..ce3ac21 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/BoolComparer", (int) ConnectorType.ValueComparerBool)] + public class BoolComparer : ComparerBase + { + protected override bool Compare(bool actual) + { + return Expect == actual; + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs.meta new file mode 100644 index 0000000..0783c7e --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/BoolComparer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ed64fd013b5a441e9b3c2c65dafaecab +timeCreated: 1568882437 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs b/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs new file mode 100644 index 0000000..2c625f7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + public abstract class ComparerBase : ConnectorBase, IMessageCollectable, IMessageComposable + where TCollector : ValueCollectorBase, new() + { + private const string MessageParameterKey = "Result"; + + [SerializeField] private TValue expect = default; + + protected TValue Expect + { + get => expect; + private set => expect = value; + } + private TValue Actual { get; set; } + + [SerializeField] private TCollector expectCollector = new TCollector(); + [SerializeField] private TCollector actualCollector = new TCollector(); + + private TCollector ExpectCollector => expectCollector; + private TCollector ActualCollector => actualCollector; + + private bool Result { get; set; } + + public override IObservable OnConnectAsObservable() + { + Result = Compare(Actual); + return Result ? ObservableFactory.ReturnMessage(this, MessageParameterKey, true) : ObservableFactory.EmptyMessage(); + } + + protected abstract bool Compare(TValue actual); + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ExpectCollector, x => Expect = x, nameof(Expect)), + CollectableMessageAnnotationFactory.Create(ActualCollector, x => Actual = x, nameof(Actual)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Result, MessageParameterKey), + }; + } + + public abstract class ComparerBase : ComparerBase + where TOperator : Enum + where TCollector : ValueCollectorBase, new() + { + [SerializeField] private TOperator @operator = default; + + [UsedImplicitly] public TOperator Operator + { + get => @operator; + set => @operator = value; + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs.meta b/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs.meta new file mode 100644 index 0000000..fc60e61 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/ComparerBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8436b509b98c436f8563a5a1a9621768 +timeCreated: 1568810363 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs b/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs new file mode 100644 index 0000000..77df5e7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs @@ -0,0 +1,31 @@ +using System; + +namespace UniFlow.Connector.ValueComparer +{ + public abstract class EnumComparerBase : ComparerBase.OperatorType, TCollector> + where TCollector : ValueCollectorBase, new() + where TEnum : Enum + { + protected override bool Compare(TEnum actual) + { + switch (Operator) + { + case OperatorType.Equal: + return Equals(actual, Expect); + case OperatorType.NotEqual: + return !Equals(actual, Expect); + case OperatorType.HasFlag: + return Expect.HasFlag(actual); + default: + throw new ArgumentOutOfRangeException(); + } + } + + public enum OperatorType + { + Equal, + NotEqual, + HasFlag, + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs.meta b/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs.meta new file mode 100644 index 0000000..61e39c7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/EnumComparerBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f5d0824886be45ed953711fa6e921a52 +timeCreated: 1568810293 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs b/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs new file mode 100644 index 0000000..82fc081 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs @@ -0,0 +1,40 @@ +using System; +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/FloatComparer", (int) ConnectorType.ValueComparerFloat)] + public class FloatComparer : ComparerBase + { + protected override bool Compare(float actual) + { + switch (Operator) + { + case OperatorType.Equal: + return Mathf.Approximately(Expect, actual); + case OperatorType.NotEqual: + return !Mathf.Approximately(Expect, actual); + case OperatorType.Greater: + return actual > Expect; + case OperatorType.GreaterOrEqual: + return actual >= Expect; + case OperatorType.Less: + return actual < Expect; + case OperatorType.LessOrEqual: + return actual <= Expect; + default: + throw new ArgumentOutOfRangeException(); + } + } + + public enum OperatorType + { + Equal, + NotEqual, + Greater, + GreaterOrEqual, + Less, + LessOrEqual, + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs.meta new file mode 100644 index 0000000..3bf7949 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/FloatComparer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8d6d08a04b8f432c9fad27f8dd57c3c2 +timeCreated: 1568882422 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/IntComparer.cs b/Assets/Scripts/Connector/ValueComparer/IntComparer.cs new file mode 100644 index 0000000..f19e09f --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/IntComparer.cs @@ -0,0 +1,40 @@ +using System; +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/IntComparer", (int) ConnectorType.ValueComparerInt)] + public class IntComparer : ComparerBase + { + protected override bool Compare(int actual) + { + switch (Operator) + { + case OperatorType.Equal: + return actual == Expect; + case OperatorType.NotEqual: + return actual != Expect; + case OperatorType.Greater: + return actual > Expect; + case OperatorType.GreaterOrEqual: + return actual >= Expect; + case OperatorType.Less: + return actual < Expect; + case OperatorType.LessOrEqual: + return actual <= Expect; + default: + throw new ArgumentOutOfRangeException(); + } + } + + public enum OperatorType + { + Equal, + NotEqual, + Greater, + GreaterOrEqual, + Less, + LessOrEqual, + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/IntComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/IntComparer.cs.meta new file mode 100644 index 0000000..97147c6 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/IntComparer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 437562923d1344d3984c8db4fff1a095 +timeCreated: 1568810234 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs b/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs new file mode 100644 index 0000000..e3afa6a --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs @@ -0,0 +1,34 @@ +using System; +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/ObjectComparer", (int) ConnectorType.ValueComparerObject)] + public class ObjectComparer : ComparerBase + { + protected override bool Compare(UnityEngine.Object actual) + { + switch (Operator) + { + case OperatorType.Equal: + return Equals(actual, Expect); + case OperatorType.NotEqual: + return !Equals(actual, Expect); + case OperatorType.Null: + return actual == default; + case OperatorType.NotNull: + return actual != default; + default: + throw new ArgumentOutOfRangeException(); + } + } + + public enum OperatorType + { + Equal, + NotEqual, + Null, + NotNull, + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs.meta new file mode 100644 index 0000000..8977d78 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/ObjectComparer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 50fbdee7547024eeca4ccd8897acee3d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs b/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs new file mode 100644 index 0000000..88d6be7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/RuntimePlatformComparer", (int) ConnectorType.ValueComparerRuntimePlatform)] + public class RuntimePlatformComparer : EnumComparerBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs.meta new file mode 100644 index 0000000..8b44fc6 --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/RuntimePlatformComparer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: a7c266820be04ffb87162fa4820ab210 +timeCreated: 1570731972 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueComparer/StringComparer.cs b/Assets/Scripts/Connector/ValueComparer/StringComparer.cs new file mode 100644 index 0000000..11917dc --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/StringComparer.cs @@ -0,0 +1,40 @@ +using System; +using UnityEngine; + +namespace UniFlow.Connector.ValueComparer +{ + [AddComponentMenu("UniFlow/ValueComparer/StringComparer", (int) ConnectorType.ValueComparerString)] + public class StringComparer : ComparerBase + { + protected override bool Compare(string actual) + { + switch (Operator) + { + case OperatorType.Equal: + return actual == Expect; + case OperatorType.NotEqual: + return actual != Expect; + case OperatorType.NullOrEmpty: + return string.IsNullOrEmpty(actual); + case OperatorType.NotNullOrEmpty: + return !string.IsNullOrEmpty(actual); + case OperatorType.NullOrWhitespace: + return string.IsNullOrWhiteSpace(actual); + case OperatorType.NotNullOrWhitespace: + return !string.IsNullOrWhiteSpace(actual); + default: + throw new ArgumentOutOfRangeException(); + } + } + + public enum OperatorType + { + Equal, + NotEqual, + NullOrEmpty, + NotNullOrEmpty, + NullOrWhitespace, + NotNullOrWhitespace, + } + } +} diff --git a/Assets/Scripts/Connector/ValueComparer/StringComparer.cs.meta b/Assets/Scripts/Connector/ValueComparer/StringComparer.cs.meta new file mode 100644 index 0000000..be1506f --- /dev/null +++ b/Assets/Scripts/Connector/ValueComparer/StringComparer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e6097591daaf4ff1a4470b88a167b073 +timeCreated: 1568882430 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector.meta b/Assets/Scripts/Connector/ValueInjector.meta new file mode 100644 index 0000000..8feb001 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3284cdf11c92478186cfe6a387636323 +timeCreated: 1570081781 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs b/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs new file mode 100644 index 0000000..0966a74 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs @@ -0,0 +1,105 @@ +using System.Collections.Generic; +using UniFlow.Connector.ValueInjector; +using UnityEngine; +using UnityEngine.UI; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/ValueInjector/ImageInjector", (int) ConnectorType.ValueInjectorImage)] + public class ImageInjector : InjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private Image image = default; + [SerializeField] private Color color = default; + [SerializeField] private Sprite sprite = default; + [SerializeField] private bool invokeSetNativeSize = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private Image Image + { + get => image != default ? image : image = this.GetOrAddComponent(); + set => image = value; + } + private Sprite Sprite + { + get => sprite; + set + { + sprite = value; + HasInjectSprite = true; + } + } + private Color Color + { + get => color; + set + { + color = value; + HasInjectColor = true; + } + } + private bool InvokeSetNativeSize + { + get => invokeSetNativeSize; + set => invokeSetNativeSize = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private ImageCollector imageCollector = new ImageCollector(); + [SerializeField] private SpriteCollector spriteCollector = new SpriteCollector(); + [SerializeField] private ColorCollector colorCollector = new ColorCollector(); + [SerializeField] private BoolCollector invokeSetNativeSizeCollector = new BoolCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private ImageCollector ImageCollector => imageCollector; + private SpriteCollector SpriteCollector => spriteCollector; + private ColorCollector ColorCollector => colorCollector; + private BoolCollector InvokeSetNativeSizeCollector => invokeSetNativeSizeCollector; + + private bool HasInjectColor { get; set; } + private bool HasInjectSprite { get; set; } + + protected override void Inject() + { + if (HasInjectColor) + { + Image.color = Color; + } + + if (HasInjectSprite) + { + Image.sprite = Sprite; + } + + if (InvokeSetNativeSize) + { + Image.SetNativeSize(); + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(ImageCollector, x => Image = x, nameof(Image)), + CollectableMessageAnnotationFactory.Create(SpriteCollector, x => Sprite = x, nameof(Sprite)), + CollectableMessageAnnotationFactory.Create(ColorCollector, x => Color = x, nameof(Color)), + CollectableMessageAnnotationFactory.Create(InvokeSetNativeSizeCollector, x => InvokeSetNativeSize = x, nameof(InvokeSetNativeSize)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs.meta new file mode 100644 index 0000000..602c185 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/ImageInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c712524056354542a1b35e597dfcda03 +timeCreated: 1570028763 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs b/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs new file mode 100644 index 0000000..255712b --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs @@ -0,0 +1,19 @@ +using System; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.ValueInjector +{ + public abstract class InjectorBase : ConnectorBase + { + public abstract GameObject BaseGameObject { get; set; } + + public override IObservable OnConnectAsObservable() + { + Inject(); + return ObservableFactory.ReturnMessage(this); + } + + protected abstract void Inject(); + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs.meta b/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs.meta new file mode 100644 index 0000000..6a5c32a --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/InjectorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 69fa4534cd3444f58c7a3fe2e9f60654 +timeCreated: 1570084445 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs b/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs new file mode 100644 index 0000000..d9e9df1 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using UniFlow.Connector.ValueInjector; +using UnityEngine; +using UnityEngine.UI; + +namespace UniFlow.Connector.Controller +{ + [AddComponentMenu("UniFlow/ValueInjector/RawImageInjector", (int) ConnectorType.ValueInjectorRawImage)] + public class RawImageInjector : InjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private RawImage rawImage = default; + [SerializeField] private Texture texture = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private RawImage RawImage + { + get => rawImage != default ? rawImage : rawImage = this.GetOrAddComponent(); + set => rawImage = value; + } + private Texture Texture + { + get => texture; + set => texture = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private RawImageCollector rawImageCollector = new RawImageCollector(); + [SerializeField] private TextureCollector textureCollector = new TextureCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector ?? (baseGameObjectCollector = new GameObjectCollector {TargetConnector = this}); + private StringCollector TransformPathCollector => transformPathCollector ?? (transformPathCollector = new StringCollector {TargetConnector = this}); + private RawImageCollector RawImageCollector => rawImageCollector ?? (rawImageCollector = new RawImageCollector {TargetConnector = this}); + private TextureCollector TextureCollector => textureCollector ?? (textureCollector = new TextureCollector {TargetConnector = this}); + + protected override void Inject() + { + RawImage.texture = Texture; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(RawImageCollector, x => RawImage = x, nameof(RawImage)), + CollectableMessageAnnotationFactory.Create(TextureCollector, x => Texture = x, nameof(Texture)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs.meta new file mode 100644 index 0000000..8ebc915 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/RawImageInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ce1f1899b5db4d36aeaeaedbebbe4f78 +timeCreated: 1570029109 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs b/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs new file mode 100644 index 0000000..8874eb2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs @@ -0,0 +1,192 @@ +using System.Collections.Generic; +using UniFlow; +using UniFlow.Connector.ValueInjector; +using UnityEngine; + +namespace CAFUSample.Scripts.Connector.ValueInjector +{ + [AddComponentMenu("UniFlow/ValueInjector/RectTransformInjector", (int) ConnectorType.ValueInjectorRectTransform)] + public class RectTransformInjector : InjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private bool actAsLocal = true; + [SerializeField] private Vector3 position = default; + [SerializeField] private Quaternion rotation = default; + [SerializeField] private Vector3 rotationEuler = default; + [SerializeField] private Vector3 scale = default; + [SerializeField] private Vector2 anchoredPosition = default; + [SerializeField] private Vector2 anchoredPosition3D = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private bool ActAsLocal => actAsLocal; + private Vector3 Position + { + get => position; + set + { + position = value; + HasInjectPosition = true; + } + } + private Quaternion Rotation + { + get => rotation; + set + { + rotation = value; + HasInjectRotation = true; + } + } + private Vector3 RotationEuler + { + get => rotationEuler; + set + { + rotationEuler = value; + HasInjectRotationEuler = true; + } + } + private Vector3 Scale + { + get => scale; + set + { + scale = value; + HasInjectScale = true; + } + } + private Vector2 AnchoredPosition + { + get => anchoredPosition; + set + { + anchoredPosition = value; + HasInjectAnchoredPosition = true; + } + } + private Vector3 AnchoredPosition3D + { + get => anchoredPosition3D; + set + { + anchoredPosition3D = value; + HasInjectAnchoredPosition3D = true; + } + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private Vector3Collector positionCollector = new Vector3Collector(); + [SerializeField] private QuaternionCollector rotationCollector = new QuaternionCollector(); + [SerializeField] private Vector3Collector rotationEulerCollector = new Vector3Collector(); + [SerializeField] private Vector3Collector scaleCollector = new Vector3Collector(); + [SerializeField] private Vector2Collector anchoredPositionCollector = new Vector2Collector(); + [SerializeField] private Vector3Collector anchoredPosition3DCollector = new Vector3Collector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private Vector3Collector PositionCollector => positionCollector; + private QuaternionCollector RotationCollector => rotationCollector; + private Vector3Collector RotationEulerCollector => rotationEulerCollector; + private Vector3Collector ScaleCollector => scaleCollector; + private Vector2Collector AnchoredPositionCollector => anchoredPositionCollector; + private Vector3Collector AnchoredPosition3DCollector => anchoredPosition3DCollector; + + + private bool HasInjectPosition { get; set; } + private bool HasInjectRotation { get; set; } + private bool HasInjectRotationEuler { get; set; } + private bool HasInjectScale { get; set; } + private bool HasInjectAnchoredPosition { get; set; } + private bool HasInjectAnchoredPosition3D { get; set; } + + protected override void Inject() + { + var targetTransform = BaseGameObject.transform as RectTransform; + if (targetTransform == null) + { + return; + } + + if (HasInjectPosition) + { + if (ActAsLocal) + { + targetTransform.localPosition = Position; + } + else + { + targetTransform.position = Position; + } + } + + if (HasInjectRotationEuler) + { + if (ActAsLocal) + { + targetTransform.localRotation = Quaternion.Euler(RotationEuler); + } + else + { + targetTransform.rotation = Quaternion.Euler(RotationEuler); + } + } + + if (HasInjectRotation) + { + if (ActAsLocal) + { + targetTransform.localRotation = Rotation; + } + else + { + targetTransform.rotation = Rotation; + } + } + + // ReSharper disable once InvertIf + if (HasInjectScale) + { + if (ActAsLocal) + { + targetTransform.localScale = Scale; + } + } + + if (HasInjectAnchoredPosition) + { + targetTransform.anchoredPosition = AnchoredPosition; + } + + if (HasInjectAnchoredPosition3D) + { + targetTransform.anchoredPosition3D = AnchoredPosition3D; + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PositionCollector, x => Position = x, nameof(Position)), + CollectableMessageAnnotationFactory.Create(RotationCollector, x => Rotation = x, nameof(Rotation)), + CollectableMessageAnnotationFactory.Create(RotationEulerCollector, x => RotationEuler = x, nameof(RotationEuler)), + CollectableMessageAnnotationFactory.Create(ScaleCollector, x => Scale = x, nameof(Scale)), + CollectableMessageAnnotationFactory.Create(AnchoredPositionCollector, x => AnchoredPosition = x, nameof(AnchoredPosition)), + CollectableMessageAnnotationFactory.Create(AnchoredPosition3DCollector, x => AnchoredPosition3D = x, nameof(AnchoredPosition3D)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs.meta new file mode 100644 index 0000000..57cd7e6 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/RectTransformInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 58d576dc387f848d1a8e6bf88caf77d4 +timeCreated: 1571998192 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline.meta b/Assets/Scripts/Connector/ValueInjector/Timeline.meta new file mode 100644 index 0000000..b490fc7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 55fb9b35de7d47e8baee6457911dab9a +timeCreated: 1570083246 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs b/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs new file mode 100644 index 0000000..545504a --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.ValueInjector.Timeline +{ + [AddComponentMenu("UniFlow/ValueInjector/Timeline/AnimationTrack", (int) ConnectorType.ValueInjectorTimelineAnimationTrack)] + public class AnimationTrackInjector : TimelineInjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private PlayableDirector playableDirector = default; + [SerializeField] private string trackName = default; + [SerializeField] private string clipName = default; + [SerializeField] private AnimationClip animationClip = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + protected override PlayableDirector PlayableDirector + { + get => playableDirector != default ? playableDirector : playableDirector = this.GetOrAddComponent(); + set => playableDirector = value; + } + protected override string TrackName + { + get => trackName; + set => trackName = value; + } + protected override string ClipName + { + get => clipName; + set => clipName = value; + } + private AnimationClip AnimationClip + { + get => animationClip; + set => animationClip = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private PlayableDirectorCollector playableDirectorCollector = new PlayableDirectorCollector(); + [SerializeField] private StringCollector trackNameCollector = new StringCollector(); + [SerializeField] private StringCollector clipNameCollector = new StringCollector(); + [SerializeField] private AnimationClipCollector animationClipCollector = new AnimationClipCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private PlayableDirectorCollector PlayableDirectorCollector => playableDirectorCollector; + private StringCollector TrackNameCollector => trackNameCollector; + private StringCollector ClipNameCollector => clipNameCollector; + private AnimationClipCollector AnimationClipCollector => animationClipCollector; + + protected override void Inject(AnimationPlayableAsset playableAsset) + { + playableAsset.clip = AnimationClip; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PlayableDirectorCollector, x => PlayableDirector = x, nameof(PlayableDirector)), + CollectableMessageAnnotationFactory.Create(TrackNameCollector, x => TrackName = x, nameof(TrackName)), + CollectableMessageAnnotationFactory.Create(ClipNameCollector, x => ClipName = x, nameof(ClipName)), + CollectableMessageAnnotationFactory.Create(AnimationClipCollector, x => AnimationClip = x, nameof(AnimationClip)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs.meta new file mode 100644 index 0000000..1e44516 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/AnimationTrackInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b6719f10f734474f97340b59bc411d13 +timeCreated: 1570083974 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs b/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs new file mode 100644 index 0000000..ae834c2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs @@ -0,0 +1,81 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.ValueInjector.Timeline +{ + [AddComponentMenu("UniFlow/ValueInjector/Timeline/AudioTrack", (int) ConnectorType.ValueInjectorTimelineAudioTrack)] + public class AudioTrackInjector : TimelineInjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private PlayableDirector playableDirector = default; + [SerializeField] private string trackName = default; + [SerializeField] private string clipName = default; + [SerializeField] private AudioClip audioClip = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + protected override PlayableDirector PlayableDirector + { + get => playableDirector != default ? playableDirector : playableDirector = this.GetOrAddComponent(); + set => playableDirector = value; + } + protected override string TrackName + { + get => trackName; + set => trackName = value; + } + protected override string ClipName + { + get => clipName; + set => clipName = value; + } + private AudioClip AudioClip + { + get => audioClip; + set => audioClip = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private PlayableDirectorCollector playableDirectorCollector = new PlayableDirectorCollector(); + [SerializeField] private StringCollector trackNameCollector = new StringCollector(); + [SerializeField] private StringCollector clipNameCollector = new StringCollector(); + [SerializeField] private AudioClipCollector audioClipCollector = new AudioClipCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private PlayableDirectorCollector PlayableDirectorCollector => playableDirectorCollector; + private StringCollector TrackNameCollector => trackNameCollector; + private StringCollector ClipNameCollector => clipNameCollector; + private AudioClipCollector AudioClipCollector => audioClipCollector; + + protected override void Inject(AudioPlayableAsset playableAsset) + { + playableAsset.clip = AudioClip; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PlayableDirectorCollector, x => PlayableDirector = x, nameof(PlayableDirector)), + CollectableMessageAnnotationFactory.Create(TrackNameCollector, x => TrackName = x, nameof(TrackName)), + CollectableMessageAnnotationFactory.Create(ClipNameCollector, x => ClipName = x, nameof(ClipName)), + CollectableMessageAnnotationFactory.Create(AudioClipCollector, x => AudioClip = x, nameof(AudioClip)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs.meta new file mode 100644 index 0000000..70d740a --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/AudioTrackInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 046be94351354c25b22ecd1f6827aa52 +timeCreated: 1570083967 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs b/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs new file mode 100644 index 0000000..5e2f135 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs @@ -0,0 +1,97 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.ValueInjector.Timeline +{ + [AddComponentMenu("UniFlow/ValueInjector/Timeline/ControlTrack", (int) ConnectorType.ValueInjectorTimelineControlTrack)] + public class ControlTrackInjector : TimelineInjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private PlayableDirector playableDirector = default; + [SerializeField] private string trackName = default; + [SerializeField] private string clipName = default; + [SerializeField] private GameObject sourceGameObject = default; + [SerializeField] private GameObject prefabGameObject = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + protected override PlayableDirector PlayableDirector + { + get => playableDirector != default ? playableDirector : playableDirector = this.GetOrAddComponent(); + set => playableDirector = value; + } + protected override string TrackName + { + get => trackName; + set => trackName = value; + } + protected override string ClipName + { + get => clipName; + set => clipName = value; + } + public GameObject SourceGameObject + { + get => sourceGameObject; + set => sourceGameObject = value; + } + private GameObject PrefabGameObject + { + get => prefabGameObject; + set => prefabGameObject = value; + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private PlayableDirectorCollector playableDirectorCollector = new PlayableDirectorCollector(); + [SerializeField] private StringCollector trackNameCollector = new StringCollector(); + [SerializeField] private StringCollector clipNameCollector = new StringCollector(); + [SerializeField] private GameObjectCollector sourceGameObjectCollector = new GameObjectCollector(); + [SerializeField] private GameObjectCollector prefabGameObjectCollector = new GameObjectCollector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private PlayableDirectorCollector PlayableDirectorCollector => playableDirectorCollector; + private StringCollector TrackNameCollector => trackNameCollector; + private StringCollector ClipNameCollector => clipNameCollector; + private GameObjectCollector SourceGameObjectCollector => sourceGameObjectCollector; + private GameObjectCollector PrefabGameObjectCollector => prefabGameObjectCollector; + + protected override void Inject(ControlPlayableAsset playableAsset) + { + if (SourceGameObject != default) + { + PlayableDirector.SetReferenceValue(playableAsset.sourceGameObject.exposedName, SourceGameObject); + } + if (PrefabGameObject != default) + { + playableAsset.prefabGameObject = PrefabGameObject; + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PlayableDirectorCollector, x => PlayableDirector = x, nameof(PlayableDirector)), + CollectableMessageAnnotationFactory.Create(TrackNameCollector, x => TrackName = x, nameof(TrackName)), + CollectableMessageAnnotationFactory.Create(ClipNameCollector, x => ClipName = x, nameof(ClipName)), + CollectableMessageAnnotationFactory.Create(SourceGameObjectCollector, x => SourceGameObject = x, nameof(SourceGameObject)), + CollectableMessageAnnotationFactory.Create(PrefabGameObjectCollector, x => PrefabGameObject = x, nameof(PrefabGameObject)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs.meta new file mode 100644 index 0000000..9f3838e --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/Timeline/ControlTrackInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ba8042ef59eb434382859013aca5b8e1 +timeCreated: 1570083246 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs b/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs new file mode 100644 index 0000000..8d58cdf --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs @@ -0,0 +1,34 @@ +using System.Linq; +using System.Text.RegularExpressions; +using UnityEngine.Playables; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.ValueInjector +{ + public abstract class TimelineInjectorBase : InjectorBase where TPlayableAsset : PlayableAsset + { + protected abstract PlayableDirector PlayableDirector { get; set; } + protected abstract string TrackName { get; set; } + protected abstract string ClipName { get; set; } + + protected override void Inject() + { + if (!(PlayableDirector.playableAsset is TimelineAsset timelineAsset)) + { + return; + } + + timelineAsset + .GetOutputTracks() + .Where(x => x != default && (string.IsNullOrEmpty(TrackName) || Regex.IsMatch(x.name, TrackName))) + .SelectMany(x => x.GetClips()) + .Where(x => x != default && (string.IsNullOrEmpty(ClipName) || Regex.IsMatch(x.displayName, ClipName))) + .Select(x => x.asset) + .OfType() + .ToList() + .ForEach(Inject); + } + + protected abstract void Inject(TPlayableAsset playableAsset); + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs.meta b/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs.meta new file mode 100644 index 0000000..373828a --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/TimelineInjectorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bfe596f8205f4a8296c4e8606087f6eb +timeCreated: 1570081781 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs b/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs new file mode 100644 index 0000000..34db29f --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs @@ -0,0 +1,148 @@ +using System.Collections.Generic; +using UniFlow; +using UniFlow.Connector.ValueInjector; +using UnityEngine; + +namespace CAFUSample.Scripts.Connector.ValueInjector +{ + [AddComponentMenu("UniFlow/ValueInjector/TransformInjector", (int) ConnectorType.ValueInjectorTransform)] + public class TransformInjector : InjectorBase, + IBaseGameObjectSpecifyable, + IMessageCollectable + { + [SerializeField] private GameObject baseGameObject = default; + [SerializeField] private string transformPath = default; + [SerializeField] private bool actAsLocal = true; + [SerializeField] private Vector3 position = default; + [SerializeField] private Quaternion rotation = default; + [SerializeField] private Vector3 rotationEuler = default; + [SerializeField] private Vector3 scale = default; + + public override GameObject BaseGameObject + { + get => baseGameObject == default ? baseGameObject = gameObject : baseGameObject; + set => baseGameObject = value; + } + public string TransformPath + { + get => transformPath; + private set => transformPath = value; + } + private bool ActAsLocal => actAsLocal; + private Vector3 Position + { + get => position; + set + { + position = value; + HasInjectPosition = true; + } + } + private Quaternion Rotation + { + get => rotation; + set + { + rotation = value; + HasInjectRotation = true; + } + } + private Vector3 RotationEuler + { + get => rotationEuler; + set + { + rotationEuler = value; + HasInjectRotationEuler = true; + } + } + private Vector3 Scale + { + get => scale; + set + { + scale = value; + HasInjectScale = true; + } + } + + [SerializeField] private GameObjectCollector baseGameObjectCollector = new GameObjectCollector(); + [SerializeField] private StringCollector transformPathCollector = new StringCollector(); + [SerializeField] private Vector3Collector positionCollector = new Vector3Collector(); + [SerializeField] private QuaternionCollector rotationCollector = new QuaternionCollector(); + [SerializeField] private Vector3Collector rotationEulerCollector = new Vector3Collector(); + [SerializeField] private Vector3Collector scaleCollector = new Vector3Collector(); + + private GameObjectCollector BaseGameObjectCollector => baseGameObjectCollector; + private StringCollector TransformPathCollector => transformPathCollector; + private Vector3Collector PositionCollector => positionCollector; + private QuaternionCollector RotationCollector => rotationCollector; + private Vector3Collector RotationEulerCollector => rotationEulerCollector; + private Vector3Collector ScaleCollector => scaleCollector; + + private bool HasInjectPosition { get; set; } + private bool HasInjectRotation { get; set; } + private bool HasInjectRotationEuler { get; set; } + private bool HasInjectScale { get; set; } + + protected override void Inject() + { + var targetTransform = BaseGameObject.transform; + if (HasInjectPosition) + { + if (ActAsLocal) + { + targetTransform.localPosition = Position; + } + else + { + targetTransform.position = Position; + } + } + + if (HasInjectRotationEuler) + { + if (ActAsLocal) + { + targetTransform.localRotation = Quaternion.Euler(RotationEuler); + } + else + { + targetTransform.rotation = Quaternion.Euler(RotationEuler); + } + } + + if (HasInjectRotation) + { + if (ActAsLocal) + { + targetTransform.localRotation = Rotation; + } + else + { + targetTransform.rotation = Rotation; + } + } + + // ReSharper disable once InvertIf + if (HasInjectScale) + { + if (ActAsLocal) + { + targetTransform.localScale = Scale; + } + } + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(BaseGameObjectCollector, x => BaseGameObject = x, nameof(BaseGameObject)), + CollectableMessageAnnotationFactory.Create(TransformPathCollector, x => TransformPath = x, nameof(TransformPath)), + CollectableMessageAnnotationFactory.Create(PositionCollector, x => Position = x, nameof(Position)), + CollectableMessageAnnotationFactory.Create(RotationCollector, x => Rotation = x, nameof(Rotation)), + CollectableMessageAnnotationFactory.Create(RotationEulerCollector, x => RotationEuler = x, nameof(RotationEuler)), + CollectableMessageAnnotationFactory.Create(ScaleCollector, x => Scale = x, nameof(Scale)), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs.meta b/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs.meta new file mode 100644 index 0000000..45a4ed8 --- /dev/null +++ b/Assets/Scripts/Connector/ValueInjector/TransformInjector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5bdf624dc0f8461ab95051824fdf204b +timeCreated: 1571998192 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider.meta b/Assets/Scripts/Connector/ValueProvider.meta new file mode 100644 index 0000000..a5c0e48 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 83cf184f8e6d4a71861bc934fa056d17 +timeCreated: 1568893016 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs b/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs new file mode 100644 index 0000000..34d9930 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/BoolProvider", (int) ConnectorType.ValueProviderBool)] + public class BoolProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs.meta new file mode 100644 index 0000000..1940882 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/BoolProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f40afbbd3c18478284b25f52e2391fbb +timeCreated: 1569827844 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs b/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs new file mode 100644 index 0000000..d3262d7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/ByteProvider", (int) ConnectorType.ValueProviderByte)] + public class ByteProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs.meta new file mode 100644 index 0000000..c2d07f3 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ByteProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 375058f27f4b4eeeac51d96af5188ec6 +timeCreated: 1569917721 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs b/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs new file mode 100644 index 0000000..dc7f55e --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Color32Provider", (int) ConnectorType.ValueProviderColor32)] + public class Color32Provider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private ByteCollector rCollector = new ByteCollector(); + [SerializeField] private ByteCollector gCollector = new ByteCollector(); + [SerializeField] private ByteCollector bCollector = new ByteCollector(); + [SerializeField] private ByteCollector aCollector = new ByteCollector(); + + private ByteCollector RCollector => rCollector; + private ByteCollector GCollector => gCollector; + private ByteCollector BCollector => bCollector; + private ByteCollector ACollector => aCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(RCollector, x => Value = new Color32(x, Value.g, Value.b, Value.a), "R"), + CollectableMessageAnnotationFactory.Create(GCollector, x => Value = new Color32(Value.r, x, Value.b, Value.a), "G"), + CollectableMessageAnnotationFactory.Create(BCollector, x => Value = new Color32(Value.r, Value.g, x, Value.a), "B"), + CollectableMessageAnnotationFactory.Create(ACollector, x => Value = new Color32(Value.r, Value.g, Value.b, x), "A"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs.meta new file mode 100644 index 0000000..48badab --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Color32Provider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f7b8fae7b3e84afdb21533393417dc38 +timeCreated: 1569828529 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs b/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs new file mode 100644 index 0000000..9044379 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/ColorProvider", (int) ConnectorType.ValueProviderColor)] + public class ColorProvider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private FloatCollector rCollector = new FloatCollector(); + [SerializeField] private FloatCollector gCollector = new FloatCollector(); + [SerializeField] private FloatCollector bCollector = new FloatCollector(); + [SerializeField] private FloatCollector aCollector = new FloatCollector(); + + private FloatCollector RCollector => rCollector; + private FloatCollector GCollector => gCollector; + private FloatCollector BCollector => bCollector; + private FloatCollector ACollector => aCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(RCollector, x => Value = new Color(x, Value.g, Value.b, Value.a), "R"), + CollectableMessageAnnotationFactory.Create(GCollector, x => Value = new Color(Value.r, x, Value.b, Value.a), "G"), + CollectableMessageAnnotationFactory.Create(BCollector, x => Value = new Color(Value.r, Value.g, x, Value.a), "B"), + CollectableMessageAnnotationFactory.Create(ACollector, x => Value = new Color(Value.r, Value.g, Value.b, x), "A"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs.meta new file mode 100644 index 0000000..78a184d --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ColorProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0639b3698c8f436b8ccf44a4bd6e4305 +timeCreated: 1569828511 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs b/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs new file mode 100644 index 0000000..1f18513 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/CurrentRuntimePlatformProvider", (int) ConnectorType.ValueProviderCurrentRuntimePlatform)] + public class CurrentRuntimePlatformProvider : ConnectorBase, IMessageComposable + { + private const string MessageParameterKey = "Value"; + + private RuntimePlatform Value => Application.platform; + + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this, MessageParameterKey, Value); + } + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value, MessageParameterKey), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs.meta new file mode 100644 index 0000000..872e64c --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/CurrentRuntimePlatformProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5aa491aa255c4965a33b16241963cf07 +timeCreated: 1570731798 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs b/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs new file mode 100644 index 0000000..08d05e9 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniRx; + +namespace UniFlow.Connector.ValueProvider +{ + public abstract class EnumListProviderBase : ConnectorBase, IMessageComposable where TEnum : Enum + { + public override IObservable OnConnectAsObservable() + { + return Enum.GetValues(typeof(TEnum)) + .Cast() + .Where(Filter) + .ToList() + .ToObservable() + .AsMessageObservable(this, typeof(TEnum).Name); + } + + protected virtual bool Filter(TEnum value) + { + return true; + } + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + // Will compose parameter in OnConnectAsObservable() + ComposableMessageAnnotationFactory.Create(), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs.meta b/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs.meta new file mode 100644 index 0000000..4a4c8a9 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/EnumListProviderBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cbf509b347434772875d74fc2b029a93 +timeCreated: 1571261896 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs b/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs new file mode 100644 index 0000000..df2369e --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/FloatProvider", (int) ConnectorType.ValueProviderFloat)] + public class FloatProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs.meta new file mode 100644 index 0000000..c443565 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/FloatProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: c9eb534fafe24ff5be75bd0979935c75 +timeCreated: 1569827937 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs b/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs new file mode 100644 index 0000000..2a251ea --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/GameObjectProvider", (int) ConnectorType.ValueProviderGameObject)] + public class GameObjectProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs.meta new file mode 100644 index 0000000..86ca42c --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/GameObjectProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 5fa5d13e71a845a7ab44ffff33438af0 +timeCreated: 1569910725 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/IntProvider.cs b/Assets/Scripts/Connector/ValueProvider/IntProvider.cs new file mode 100644 index 0000000..b68f4fd --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/IntProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/IntProvider", (int) ConnectorType.ValueProviderInt)] + public class IntProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/IntProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/IntProvider.cs.meta new file mode 100644 index 0000000..ec90f3d --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/IntProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9f73964dfd154496ba8800ec1ac003c8 +timeCreated: 1569822622 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs b/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs new file mode 100644 index 0000000..2023452 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs @@ -0,0 +1,144 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniRx; +using UnityEngine; +using Random = System.Random; + +namespace UniFlow.Connector.ValueProvider +{ + public abstract class ListProviderBase : ConnectorBase, IInjectable>, IMessageComposable + { + [SerializeField] private List values = default; + + [SerializeField] private EnumerationType enumerationType = default; + + private EnumerationType EnumerationType => enumerationType; + + [UsedImplicitly] public IEnumerable Values + { + get => values; + set => values = value.ToList(); + } + + public override IObservable OnConnectAsObservable() + { + IEnumerable v; + switch (EnumerationType) + { + case EnumerationType.Normal: + v = Values; + break; + case EnumerationType.Reverse: + v = Values.Reverse(); + break; + case EnumerationType.Shuffle: + v = Values.Shuffle(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + + return v + .ToList() + .ToObservable() + .AsMessageObservable(this, typeof(TValue).Name); + } + + void IInjectable>.Inject(IEnumerable value) + { + Values = value; + } + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + // Will compose parameter in OnConnectAsObservable() + ComposableMessageAnnotationFactory.Create(), + }; + } + + public abstract class ListProviderBase : ConnectorBase, + IMessageCollectable, + IMessageComposable + where TValueCollector : ValueCollectorBase>, new() + { + [SerializeField] private List values = default; + + [SerializeField] private EnumerationType enumerationType = default; + + private EnumerationType EnumerationType => enumerationType; + + [UsedImplicitly] public IEnumerable Values + { + get => values; + set => values = value.ToList(); + } + + [SerializeField] private TValueCollector valuesCollector = new TValueCollector(); + private TValueCollector ValuesCollector => valuesCollector; + + public override IObservable OnConnectAsObservable() + { + IEnumerable v; + switch (EnumerationType) + { + case EnumerationType.Normal: + v = Values; + break; + case EnumerationType.Reverse: + v = Values.Reverse(); + break; + case EnumerationType.Shuffle: + v = Values.Shuffle(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + + return v + .ToList() + .ToObservable() + .AsMessageObservable(this, typeof(TValue).Name); + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(ValuesCollector, x => Values = x, $"{typeof(TValue).Name}List"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + // Will compose parameter in OnConnectAsObservable() + ComposableMessageAnnotationFactory.Create(), + }; + } + + public enum EnumerationType + { + Normal, + Reverse, + Shuffle, + } + + internal static class ListExtensions + { + private static Random Random { get; } = new Random(); + + internal static IEnumerable Shuffle(this IEnumerable source) + { + var elements = source.ToArray(); + + for (var n = 0; n < elements.Length; n++) + { + var k = Random.Next(n, elements.Length); + yield return elements[k]; + + elements[k] = elements[n]; + } + } + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs.meta b/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs.meta new file mode 100644 index 0000000..62052a7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ListProviderBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d8956625d693492eb20c1e6c6eb07ce1 +timeCreated: 1570799990 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs b/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs new file mode 100644 index 0000000..4bb8ffd --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/ObjectProvider", (int) ConnectorType.ValueProviderObject)] + public class ObjectProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs.meta new file mode 100644 index 0000000..8d9fbd2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ObjectProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 421990897f1b4ef7aeba179ca09d18d8 +timeCreated: 1569828035 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs b/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs new file mode 100644 index 0000000..ff15c31 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + public abstract class ProviderBase : ConnectorBase, IInjectable, IMessageComposable + { + private const string MessageParameterKey = "Value"; + + [SerializeField] private TValue value = default; + public TValue Value + { + get => value; + set => this.value = value; + } + + public override IObservable OnConnectAsObservable() + { + return ObservableFactory.ReturnMessage(this, MessageParameterKey, Value); + } + + void IInjectable.Inject(TValue v) + { + Value = v; + } + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value, MessageParameterKey), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs.meta b/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs.meta new file mode 100644 index 0000000..71c42b2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ProviderBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 95c0c457183c4c42ae0506c69581fabe +timeCreated: 1568810182 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs b/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs new file mode 100644 index 0000000..efc33e2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/QuaternionProvider", (int) ConnectorType.ValueProviderQuaternion)] + public class QuaternionProvider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private FloatCollector xCollector = new FloatCollector(); + [SerializeField] private FloatCollector yCollector = new FloatCollector(); + [SerializeField] private FloatCollector zCollector = new FloatCollector(); + [SerializeField] private FloatCollector wCollector = new FloatCollector(); + [SerializeField] private Vector3Collector eulerAngleCollector = new Vector3Collector(); + + private FloatCollector XCollector => xCollector; + private FloatCollector YCollector => yCollector; + private FloatCollector ZCollector => zCollector; + private FloatCollector WCollector => wCollector; + private Vector3Collector EulerAngleCollector => eulerAngleCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Quaternion(v, Value.y, Value.z, Value.w), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Quaternion(Value.x, v, Value.z, Value.w), "Y"), + CollectableMessageAnnotationFactory.Create(ZCollector, v => Value = new Quaternion(Value.x, Value.y, v, Value.w), "Z"), + CollectableMessageAnnotationFactory.Create(WCollector, v => Value = new Quaternion(Value.x, Value.y, Value.z, v), "W"), + CollectableMessageAnnotationFactory.Create(EulerAngleCollector, v => Value = Quaternion.Euler(v), "EulerAngle"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + ComposableMessageAnnotationFactory.Create(() => Value.eulerAngles), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs.meta new file mode 100644 index 0000000..c4a1a21 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/QuaternionProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1c5281b90d9b43acbf7f93ad83b830a8 +timeCreated: 1569828300 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs b/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs new file mode 100644 index 0000000..302d4ea --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/ScriptableObjectProvider", (int) ConnectorType.ValueProviderScriptableObject)] + public class ScriptableObjectProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs.meta new file mode 100644 index 0000000..6a915af --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/ScriptableObjectProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1e0a9d1bf040496a8dad552d5c1059fe +timeCreated: 1569948419 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs b/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs new file mode 100644 index 0000000..131c61a --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniRx; +using UnityEngine; +using UnityEngine.EventSystems; + +// ReSharper disable ConvertIfStatementToReturnStatement + +namespace UniFlow.Connector.ValueProvider +{ + public abstract class SelectorBase : ConnectorBase, + IMessageCollectable, + IMessageComposable + where TKeyCollector : ValueCollectorBase, new() + { + [SerializeField] private List keys = new List(); + [SerializeField] private List values = new List(); + + protected IList Keys => keys != default && keys.Any() ? keys : keys = GetKeys().ToList(); + protected IEnumerable Values => values != default && values.Any() ? values : values = GetValues().ToList(); + + private TKey Key { get; set; } + + [SerializeField] private TKeyCollector keyCollector = new TKeyCollector(); + private TKeyCollector KeyCollector => keyCollector; + + public override IObservable OnConnectAsObservable() + { + return Observable.Return(this.CreateMessage()); + } + + protected virtual IEnumerable GetKeys() + { + return keys; + } + + protected virtual IEnumerable GetValues() + { + return values; + } + + protected virtual TValue FindValue(TKey key) + { + return Keys.Contains(key) && Values.Count() > Keys.IndexOf(key) ? Values.ElementAt(Keys.IndexOf(key)) : default; + } + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(KeyCollector, x => Key = x, nameof(Key)), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => FindValue(Key)), + }; + } + + public abstract class ListSelectorBase : SelectorBase + { + protected override IEnumerable GetKeys() + { + return Enumerable.Range(0, Values.Count()); + } + } + + public abstract class GameObjectSelectorBase : SelectorBase where TKeyCollector : ValueCollectorBase, new() + { + } + + public abstract class MonoBehaviourSelectorBase : SelectorBase where TKeyCollector : ValueCollectorBase, new() + { + } + + public abstract class UIBehaviourSelectorBase : SelectorBase where TKeyCollector : ValueCollectorBase, new() + { + } + + public abstract class EnumSelectorBase : SelectorBase + where TEnum : Enum + where TKeyCollector : ValueCollectorBase, new() + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs.meta b/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs.meta new file mode 100644 index 0000000..a9cf42d --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/SelectorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 28f9c1010f764ba3944edd2b6d342b82 +timeCreated: 1569303461 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/StringProvider.cs b/Assets/Scripts/Connector/ValueProvider/StringProvider.cs new file mode 100644 index 0000000..4306dd4 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/StringProvider.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/StringProvider", (int) ConnectorType.ValueProviderString)] + public class StringProvider : ProviderBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/StringProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/StringProvider.cs.meta new file mode 100644 index 0000000..d258b71 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/StringProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1856ef2ce1ab49259056493a0ffa28d7 +timeCreated: 1569827955 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs b/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs new file mode 100644 index 0000000..72da8bf --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Vector2IntProvider", (int) ConnectorType.ValueProviderVector2Int)] + public class Vector2IntProvider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private IntCollector xCollector = new IntCollector(); + [SerializeField] private IntCollector yCollector = new IntCollector(); + + private IntCollector XCollector => xCollector; + private IntCollector YCollector => yCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Vector2Int(v, Value.y), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Vector2Int(Value.x, v), "Y"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs.meta new file mode 100644 index 0000000..475f1c4 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector2IntProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 73b7633e5fb241d09505f87c560d2117 +timeCreated: 1569828365 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs b/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs new file mode 100644 index 0000000..89cd2f1 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Vector2Provider", (int) ConnectorType.ValueProviderVector2)] + public class Vector2Provider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private FloatCollector xCollector = new FloatCollector(); + [SerializeField] private FloatCollector yCollector = new FloatCollector(); + + private FloatCollector XCollector => xCollector; + private FloatCollector YCollector => yCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Vector2(v, Value.y), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Vector2(Value.x, v), "Y"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs.meta new file mode 100644 index 0000000..92aac38 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector2Provider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3cdec89c4b7845deb0657984ca4038e7 +timeCreated: 1569828093 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs b/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs new file mode 100644 index 0000000..0690bf6 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Vector3IntProvider", (int) ConnectorType.ValueProviderVector3Int)] + public class Vector3IntProvider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private IntCollector xCollector = new IntCollector(); + [SerializeField] private IntCollector yCollector = new IntCollector(); + [SerializeField] private IntCollector zCollector = new IntCollector(); + + private IntCollector XCollector => xCollector; + private IntCollector YCollector => yCollector; + private IntCollector ZCollector => zCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Vector3Int(v, Value.y, Value.z), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Vector3Int(Value.x, v, Value.z), "Y"), + CollectableMessageAnnotationFactory.Create(ZCollector, v => Value = new Vector3Int(Value.x, Value.y, v), "Z"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs.meta new file mode 100644 index 0000000..090d1df --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector3IntProvider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: af13c05aadb54ce3932cb8f0622b6ecf +timeCreated: 1569828386 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs b/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs new file mode 100644 index 0000000..5d36dd7 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Vector3Provider", (int) ConnectorType.ValueProviderVector3)] + public class Vector3Provider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private FloatCollector xCollector = new FloatCollector(); + [SerializeField] private FloatCollector yCollector = new FloatCollector(); + [SerializeField] private FloatCollector zCollector = new FloatCollector(); + + private FloatCollector XCollector => xCollector; + private FloatCollector YCollector => yCollector; + private FloatCollector ZCollector => zCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Vector3(v, Value.y, Value.z), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Vector3(Value.x, v, Value.z), "Y"), + CollectableMessageAnnotationFactory.Create(ZCollector, v => Value = new Vector3(Value.x, Value.y, v), "Z"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs.meta new file mode 100644 index 0000000..a406fc6 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector3Provider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 869351b3bbde4d79b360931737e3c6cb +timeCreated: 1569828247 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs b/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs new file mode 100644 index 0000000..9a49144 --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace UniFlow.Connector.ValueProvider +{ + [AddComponentMenu("UniFlow/ValueProvider/Vector4Provider", (int) ConnectorType.ValueProviderVector4)] + public class Vector4Provider : ProviderBase, IMessageCollectable, IMessageComposable + { + [SerializeField] private FloatCollector xCollector = new FloatCollector(); + [SerializeField] private FloatCollector yCollector = new FloatCollector(); + [SerializeField] private FloatCollector zCollector = new FloatCollector(); + [SerializeField] private FloatCollector wCollector = new FloatCollector(); + + private FloatCollector XCollector => xCollector; + private FloatCollector YCollector => yCollector; + private FloatCollector ZCollector => zCollector; + private FloatCollector WCollector => wCollector; + + IEnumerable IMessageCollectable.GetMessageCollectableAnnotations() => + new[] + { + CollectableMessageAnnotationFactory.Create(XCollector, v => Value = new Vector4(v, Value.y, Value.z, Value.w), "X"), + CollectableMessageAnnotationFactory.Create(YCollector, v => Value = new Vector4(Value.x, v, Value.z, Value.w), "Y"), + CollectableMessageAnnotationFactory.Create(ZCollector, v => Value = new Vector4(Value.x, Value.y, v, Value.w), "Z"), + CollectableMessageAnnotationFactory.Create(WCollector, v => Value = new Vector4(Value.x, Value.y, Value.z, v), "W"), + }; + + IEnumerable IMessageComposable.GetMessageComposableAnnotations() => + new[] + { + ComposableMessageAnnotationFactory.Create(() => Value), + }; + } +} diff --git a/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs.meta b/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs.meta new file mode 100644 index 0000000..515ba9f --- /dev/null +++ b/Assets/Scripts/Connector/ValueProvider/Vector4Provider.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7e2b547557774f59acd6942e843c1680 +timeCreated: 1569828269 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector.meta b/Assets/Scripts/Connector/ValueSelector.meta new file mode 100644 index 0000000..a1d48ef --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 075440a1209748028e6127c67da50329 +timeCreated: 1571370796 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs b/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs new file mode 100644 index 0000000..2908778 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/AnimationClipListSelector", (int) ConnectorType.AnimationClipListSelector)] + public class AnimationClipListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs.meta new file mode 100644 index 0000000..6825690 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/AnimationClipListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 86be1ea93f254b878178e0d36c802c59 +timeCreated: 1571371160 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs b/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs new file mode 100644 index 0000000..fed4061 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/AudioClipListSelector", (int) ConnectorType.AudioClipListSelector)] + public class AudioClipListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs.meta new file mode 100644 index 0000000..50e71f2 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/AudioClipListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f4e1612d8c0647d2ab9ec211437e9ee1 +timeCreated: 1571370796 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs b/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs new file mode 100644 index 0000000..b0e40b4 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/ComponentListSelector", (int) ConnectorType.ComponentListSelector)] + public class ComponentListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs.meta new file mode 100644 index 0000000..03873dc --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/ComponentListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 95ec483b390d43b6b93082a90e9ebe31 +timeCreated: 1571371149 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs b/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs new file mode 100644 index 0000000..bf0640b --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/GameObjectListSelector", (int) ConnectorType.GameObjectListSelector)] + public class GameObjectListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs.meta new file mode 100644 index 0000000..b7b2c9f --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/GameObjectListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 7838fd9fc98843a1aac1da6fbccc5686 +timeCreated: 1571371032 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs b/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs new file mode 100644 index 0000000..e0f899e --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/ObjectListSelector", (int) ConnectorType.ObjectListSelector)] + public class ObjectListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs.meta new file mode 100644 index 0000000..ac7fa7a --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/ObjectListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b8d79e8b99aa43068a201c3b115fd8f6 +timeCreated: 1571371025 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs b/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs new file mode 100644 index 0000000..9cd1480 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs @@ -0,0 +1,11 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; +using UnityEngine.Timeline; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/TimelineAssetListSelector", (int) ConnectorType.TimelineAssetListSelector)] + public class TimelineAssetListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs.meta new file mode 100644 index 0000000..26bd6ec --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/TimelineAssetListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4aea60b243fc4a47873982fd96c4c434 +timeCreated: 1571371172 \ No newline at end of file diff --git a/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs b/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs new file mode 100644 index 0000000..7b91b0a --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs @@ -0,0 +1,10 @@ +using UniFlow.Connector.ValueProvider; +using UnityEngine; + +namespace UniFlow.Connector.ValueSelector +{ + [AddComponentMenu("UniFlow/ValueSelector/TransformListSelector", (int) ConnectorType.TransformListSelector)] + public class TransformListSelector : ListSelectorBase + { + } +} diff --git a/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs.meta b/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs.meta new file mode 100644 index 0000000..e0a2840 --- /dev/null +++ b/Assets/Scripts/Connector/ValueSelector/TransformListSelector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f3ce38b88a8744bd8e46b7855ab7aa8a +timeCreated: 1571371037 \ No newline at end of file diff --git a/Assets/Scripts/ConnectorBase.cs b/Assets/Scripts/ConnectorBase.cs new file mode 100644 index 0000000..534a245 --- /dev/null +++ b/Assets/Scripts/ConnectorBase.cs @@ -0,0 +1,150 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using JetBrains.Annotations; +using UniFlow.Utility; +using UniRx; +using UnityEngine; +using Zenject; + +namespace UniFlow +{ + public abstract class ConnectorBase : MonoBehaviour, IConnector + { + [SerializeField] [Tooltip("Specify instances of IConnector directly")] + private List targetComponents = new List(); + + [SerializeField] [Tooltip("Specify identifiers of IConnector that resolve from Zenject.DiContainer")] + private List targetIds = new List(); + + [SerializeField] [Tooltip("Set true to allow to act as the entry point of events")] + protected bool actAsTrigger = false; + + protected virtual IEnumerable TargetConnectors => + new List() + .Concat(targetComponents ?? new List()) + .Concat((targetIds ?? new List()).SelectMany(x => Container?.ResolveIdAll(x))) + .Where(x => !ReferenceEquals(x, this)) + .ToArray(); + +#if UNITY_EDITOR + [UsedImplicitly] + public IEnumerable TargetComponents + { + get => targetComponents; + set => targetComponents = value.ToList(); + } + + [UsedImplicitly] + public IEnumerable TargetIds + { + get => targetIds; + set => targetIds = value.ToList(); + } + + [SerializeField] [HideInInspector] private Vector2 flowGraphNodePosition = default; + public Vector2 FlowGraphNodePosition + { + get => flowGraphNodePosition; + set => flowGraphNodePosition = value; + } + + public ISubject OnConnectSubject { get; } = new Subject(); +#endif + + [UsedImplicitly] public virtual bool ActAsTrigger + { + get => actAsTrigger; + set => actAsTrigger = value; + } + + [Inject] private DiContainer Container { get; } + + public IList StreamedMessages { get; private set; } = new List(); + + protected virtual void Start() + { + if (ActAsTrigger) + { + ((IConnector) this).Connect(ObservableFactory.ReturnMessage(this)); + } + } + + protected virtual IEnumerable MergeMessageCollectableAnnotations() => + new ICollectableMessageAnnotation[0]; + + protected virtual IEnumerable MergeMessageComposableAnnotations() => + new IComposableMessageAnnotation[0]; + + protected ISubject CancellationSubject { get; } = new Subject(); + + void IConnector.Connect(IObservable source) + { +#if UNITY_EDITOR + if (Logger.IsEnabled) + { + OnConnectSubject.Subscribe(_ => Logger.Log(this)).AddTo(this); + } +#endif + + var observable = source + .SelectMany( + message => + { + StreamedMessages = message.StreamedMessages.ToList(); + + CancellationSubject.OnNext(Unit.Default); + + if (this is IMessageCollectable messageCollectable) + { + messageCollectable.GetMessageCollectableAnnotations().ToList().ForEach(x => x.Collect()); + } + + return (this as IConnector) + .OnConnectAsObservable() + .TakeUntil(CancellationSubject) + .Select(x => this is IMessageComposable messageComposable ? messageComposable.ComposeAll(x) : x) + .Do(x => x.StreamedMessages?.Add(x)) +#if UNITY_EDITOR + .Do(OnConnectSubject.OnNext) +#endif + ; + } + ); + + if (TargetConnectors.Count() > 1) + { + observable = observable.Replay().RefCount(); + } + +#if UNITY_EDITOR + TargetConnectors + .Select((connector, index) => (connector, index)) + .Where(x => x.connector == default) + .ToList() + .ForEach(x => Debug.LogWarning($"{gameObject.name}.{GetType().Name} contains empty target connector at index: {x.index}")); +#endif + TargetConnectors + .Where(x => x != default) + .ToList() + .ForEach(x => x.Connect(observable)); + + if (!TargetConnectors.Any()) + { + observable.Subscribe().AddTo(this); + } + } + + public abstract IObservable OnConnectAsObservable(); + + [PublicAPI] + public void AddConnector(ConnectorBase connectable) + { + if (targetComponents == default) + { + targetComponents = new List(); + } + targetComponents.Add(connectable); + } + } +} diff --git a/Assets/Scripts/EventPublisher.cs.meta b/Assets/Scripts/ConnectorBase.cs.meta similarity index 100% rename from Assets/Scripts/EventPublisher.cs.meta rename to Assets/Scripts/ConnectorBase.cs.meta diff --git a/Assets/Scripts/ConnectorType.cs b/Assets/Scripts/ConnectorType.cs new file mode 100644 index 0000000..e930ee1 --- /dev/null +++ b/Assets/Scripts/ConnectorType.cs @@ -0,0 +1,161 @@ +namespace UniFlow +{ + // ReSharper disable InconsistentNaming + // ReSharper disable UnusedMember.Global + public enum ConnectorType + { + LifecycleEvent = 100, + UIBehaviourEventTrigger, + TransformEvent, + RectTransformEvent, + CameraEvent, + ParticleEvent, + MouseEvent, + KeyEvent, + + PhysicsCollisionEvent = 200, + PhysicsCollision2DEvent, + PhysicsTriggerEvent, + PhysicsTrigger2DEvent, + + ActivationController = 300, + InstantiateGameObject, + DestroyInstance, + SimpleAnimationController, + SimpleAnimationEvent, + AnimatorTrigger, + AnimationEvent, + AudioController, + AudioEvent, + PlayableController, + TimelineEvent, + TimelineSignal, + KeyInputController, + RaycasterController, + RaycastTargetController, + TransformSiblingController, + MoveParentTransform, + DontDestroyOnLoad, + EventHandlingController, + + LoadScene = 400, + LoadScene_Enum, + LoadSceneEvent, + UnloadScene, + UnloadScene_Enum, + UnloadSceneEvent, + + ValueProviderBool = 1000, + ValueProviderByte, + ValueProviderInt, + ValueProviderFloat, + ValueProviderString, + ValueProviderEnum, + ValueProviderObject, + ValueProviderGameObject, + ValueProviderScriptableObject, + ValueProviderTransform, + ValueProviderRectTransform, + ValueProviderVector2, + ValueProviderVector3, + ValueProviderVector4, + ValueProviderQuaternion, + ValueProviderVector2Int, + ValueProviderVector3Int, + ValueProviderColor, + ValueProviderColor32, + ValueProviderCurrentRuntimePlatform, + CustomValueProvider, + + ObjectListSelector = 1500, + GameObjectListSelector, + ComponentListSelector, + TransformListSelector, + AudioClipListSelector, + AnimationClipListSelector, + TimelineAssetListSelector, + CustomValueSelector, + + ValueComparerBool = 2000, + ValueComparerByte, + ValueComparerInt, + ValueComparerFloat, + ValueComparerString, + ValueComparerEnum, + ValueComparerObject, + ValueComparerGameObject, + ValueComparerScriptableObject, + ValueComparerTransform, + ValueComparerRectTransform, + ValueComparerVector2, + ValueComparerVector3, + ValueComparerVector4, + ValueComparerQuaternion, + ValueComparerVector2Int, + ValueComparerVector3Int, + ValueComparerColor, + ValueComparerColor32, + ValueComparerRuntimePlatform, + CustomValueComparer, + + ValueInjectorTransform = 3000, + ValueInjectorRectTransform, + ValueInjectorImage, + ValueInjectorRawImage, + ValueInjectorTimelineControlTrack, + ValueInjectorTimelineAudioTrack, + ValueInjectorTimelineAnimationTrack, + + MusicPlayer = 4000, + MusicDuckingController, + MusicPitchController, + NumberImageRenderer, + GaugeImageRenderer, + ProgressiveTimer, + + SignalPublisher = 6000, + StringSignalPublisher, + ScriptableObjectSignalPublisher, + HandleEventSignalPublisher, + MusicControlSignalPublisher, + MusicDuckingSignalPublisher, + MusicPitchSignalPublisher, + + SignalReceiver = 6500, + StringSignalReceiver, + ScriptableObjectSignalReceiver, + HandleEventSignalReceiver, + MusicControlSignalReceiver, + MusicDuckingSignalReceiver, + MusicPitchSignalReceiver, + + And = 8000, + Or, + Xor, + Not, + + BoolCalculator = 8500, + IntCalculator, + FloatCalculator, + StringCalculator, + + Timer = 9000, + TimerFrame, + Interval, + IntervalFrame, + TimeScaleController, + RandomInt, + RandomFloat, + Counter, + Empty, + + Toss = 9100, + Receive = 9101, + + Preset = 10000, + + Receiver = 20000, + + Custom = -1, + } +} diff --git a/Assets/Scripts/EventType.cs.meta b/Assets/Scripts/ConnectorType.cs.meta similarity index 100% rename from Assets/Scripts/EventType.cs.meta rename to Assets/Scripts/ConnectorType.cs.meta diff --git a/Assets/Scripts/EmptyEventReceiver.cs b/Assets/Scripts/EmptyEventReceiver.cs deleted file mode 100644 index 403eaad..0000000 --- a/Assets/Scripts/EmptyEventReceiver.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace EventConnector -{ - public class EmptyEventReceiver : EventReceiver - { - public override void OnReceive(EventMessages eventMessages) - { - // Do nothing. - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/EventConnectable.cs b/Assets/Scripts/EventConnectable.cs deleted file mode 100644 index 36f5611..0000000 --- a/Assets/Scripts/EventConnectable.cs +++ /dev/null @@ -1,8 +0,0 @@ -using UnityEngine; - -namespace EventConnector -{ - public abstract class EventConnectable : MonoBehaviour, IEventConnectable - { - } -} \ No newline at end of file diff --git a/Assets/Scripts/EventConnectable.cs.meta b/Assets/Scripts/EventConnectable.cs.meta deleted file mode 100644 index dae6374..0000000 --- a/Assets/Scripts/EventConnectable.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: b8307bb9bce142c4a70c4db7e0e4c45b -timeCreated: 1562767619 \ No newline at end of file diff --git a/Assets/Scripts/EventMessages.cs b/Assets/Scripts/EventMessages.cs deleted file mode 100644 index 47ff01e..0000000 --- a/Assets/Scripts/EventMessages.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System.Collections.Generic; -using JetBrains.Annotations; - -namespace EventConnector -{ - [PublicAPI] - public class EventMessages : List - { - private EventMessages() - { - } - - public EventMessages Append(EventMessage eventMessage) - { - Add(eventMessage); - return this; - } - - public EventMessages AppendRange(IEnumerable eventMessages) - { - AddRange(eventMessages); - return this; - } - - public static EventMessages Create() - { - return new EventMessages(); - } - } - - [PublicAPI] - public struct EventMessage - { - private EventMessage(EventType eventType, object sender, object eventData) - { - EventType = eventType; - Sender = sender; - EventData = eventData; - } - - public EventType EventType { get; } - public object Sender { get; } - public object EventData { get; } - - public static EventMessage Create(EventType eventType, object sender, object eventData = default) - { - return new EventMessage(eventType, sender, eventData); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/EventMessages.cs.meta b/Assets/Scripts/EventMessages.cs.meta deleted file mode 100644 index 122d7b6..0000000 --- a/Assets/Scripts/EventMessages.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4599e3138d254e8aa3fb6089a2256c53 -timeCreated: 1562764539 \ No newline at end of file diff --git a/Assets/Scripts/EventPublisher.cs b/Assets/Scripts/EventPublisher.cs deleted file mode 100644 index 8a06daf..0000000 --- a/Assets/Scripts/EventPublisher.cs +++ /dev/null @@ -1,68 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using UniRx; -using UnityEngine; -using Zenject; - -namespace EventConnector -{ - public abstract class EventPublisher : EventConnectable, IEventPublisher - { - [SerializeField] [Tooltip("Specify instances of IEventConnectable directly")] - private List targetConnectorInstances = default; - - [SerializeField] [Tooltip("Specify identifiers of IEventConnectable that resolve from Zenject.DiContainer")] - private List targetConnectorIds = default; - - [SerializeField] [Tooltip("Set true to allow to act as the entry point of events")] - private bool actAsTrigger = false; - - [SerializeField] [Tooltip("Set true to allow to act as the receiver")] - private bool actAsReceiver = false; - - private IEnumerable TargetConnectors => - new List() - .Concat(targetConnectorInstances ?? new List()) - .Concat((targetConnectorIds ?? new List()).SelectMany(Container.ResolveIdAll)) - .Where(x => !ReferenceEquals(x, this)) - .ToArray(); - - private bool ActAsTrigger => actAsTrigger; - private bool ActAsReceiver => actAsReceiver; - [Inject] private DiContainer Container { get; } - - protected virtual void Start() - { - if (ActAsTrigger) - { - ((IEventPublisher) this).Connect(Observable.Return(default)); - } - } - - void IEventPublisher.Connect(IObservable source) - { - var observable = source - .SelectMany( - eventMessages => (this as IEventPublisher) - .OnPublishAsObservable() - .Select(x => (eventMessages ?? EventMessages.Create()).Append(x)) - ); - TargetConnectors - .OfType() - .ToList() - .ForEach(x => x.Connect(observable)); - TargetConnectors - .OfType() - .ToList() - .ForEach(x => observable.Subscribe(x.OnReceive)); - - if (ActAsReceiver) - { - observable.Subscribe(); - } - } - - public abstract IObservable OnPublishAsObservable(); - } -} \ No newline at end of file diff --git a/Assets/Scripts/EventReceiver.cs b/Assets/Scripts/EventReceiver.cs deleted file mode 100644 index 0ef480c..0000000 --- a/Assets/Scripts/EventReceiver.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EventConnector -{ - public abstract class EventReceiver : EventConnectable, IEventReceiver - { - public abstract void OnReceive(EventMessages eventMessages); - } -} \ No newline at end of file diff --git a/Assets/Scripts/EventType.cs b/Assets/Scripts/EventType.cs deleted file mode 100644 index df1f5ff..0000000 --- a/Assets/Scripts/EventType.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace EventConnector -{ - public enum EventType - { - LifecycleEvent = 1, - UIBehaviourEventTrigger, - TransformEvent, - RectTransformEvent, - CameraEvent, - ParticleEvent, - MouseEvent, - - PhysicsCollisionEvent, - PhysicsCollision2DEvent, - PhysicsTriggerEvent, - PhysicsTrigger2DEvent, - - AnimatorTrigger, - AnimationEvent, - AudioController, - AudioEvent, - PlayableController, - TimelineSignal, - - Timer, - Interval, - Empty, - } -} \ No newline at end of file diff --git a/Assets/Scripts/Extensions.cs b/Assets/Scripts/Extensions.cs new file mode 100644 index 0000000..7d4d4a4 --- /dev/null +++ b/Assets/Scripts/Extensions.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using UniFlow.Utility; +using UniRx; +using UnityEngine; +using Zenject; + +namespace UniFlow +{ + public interface IBaseGameObjectSpecifyable + { + GameObject BaseGameObject { get; } + string TransformPath { get; } + } + + public static class Extensions + { + public static TComponent GetOrAddComponent(this GameObject gameObject) where TComponent : Component + { + return gameObject.GetComponent() != default + ? gameObject.GetComponent() + : gameObject.AddComponent(); + } + + public static Transform DeterminateTransform(this IBaseGameObjectSpecifyable baseGameObjectSpecifyable) + { + return string.IsNullOrEmpty(baseGameObjectSpecifyable.TransformPath) + ? baseGameObjectSpecifyable.BaseGameObject.transform + : baseGameObjectSpecifyable.BaseGameObject.transform.Find(baseGameObjectSpecifyable.TransformPath); + } + + public static TComponent GetComponent(this IBaseGameObjectSpecifyable baseGameObjectSpecifyable) where TComponent : Component + { + return baseGameObjectSpecifyable.DeterminateTransform().gameObject.GetComponent(); + } + + public static TComponent GetOrAddComponent(this IBaseGameObjectSpecifyable baseGameObjectSpecifyable) where TComponent : Component + { + return baseGameObjectSpecifyable.DeterminateTransform().gameObject.GetOrAddComponent(); + } + + public static IObservable AsMessageObservable(this IObservable observable, IConnector connector) + { + return observable.Select(connector.CreateMessage); + } + + public static IObservable AsMessageObservable(this IObservable observable, IConnector connector) + { + return observable.Select(connector.CreateMessage); + } + + public static IObservable AsMessageObservable(this IObservable observable, IConnector connector, string key) + { + return observable.Select(x => connector.CreateMessage(x, key)); + } + + public static Message CreateMessage(this IConnector connector) + { + var message = Message.Create(connector); + message.StreamedMessages = connector.StreamedMessages; + return message; + } + + public static Message CreateMessage(this IConnector connector, Unit _) + { + var message = Message.Create(connector); + message.StreamedMessages = connector.StreamedMessages; + return message; + } + + public static Message CreateMessage(this IConnector connector, T parameter) + { + var message = Message.Create(connector, parameter); + message.StreamedMessages = connector.StreamedMessages; + return message; + } + + public static Message CreateMessage(this IConnector connector, T parameter, string key) + { + var message = Message.Create(connector, parameter, key); + message.StreamedMessages = connector.StreamedMessages; + return message; + } + + public static bool HasMessage(this IEnumerable messages, IConnector connector) + { + return messages.Any(x => x.Connector == connector); + } + + public static Message GetMessage(this IEnumerable messages, IConnector connector) + { + return connector == default ? default : messages.Last(x => x.Connector == connector); + } + } + + public static class ZenjectExtensions + { + public static DeclareSignalAsyncTickPriorityCopyBinder DeclareUniFlowSignal(this DiContainer container) + { + container.BindInterfacesTo>().AsCached(); + return container.DeclareSignal().OptionalSubscriber(); + } + } +} diff --git a/Assets/Scripts/Extensions.cs.meta b/Assets/Scripts/Extensions.cs.meta new file mode 100644 index 0000000..8128892 --- /dev/null +++ b/Assets/Scripts/Extensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4b38ba7b527b4b068ad32b3cd24aee9b +timeCreated: 1570878558 \ No newline at end of file diff --git a/Assets/Scripts/IConnector.cs b/Assets/Scripts/IConnector.cs new file mode 100644 index 0000000..f4cb8b2 --- /dev/null +++ b/Assets/Scripts/IConnector.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using UniRx; + +namespace UniFlow +{ + public interface IConnector + { + IObservable OnConnectAsObservable(); + void Connect(IObservable source); + IList StreamedMessages { get; } +#if UNITY_EDITOR + ISubject OnConnectSubject { get; } +#endif + } +} diff --git a/Assets/Scripts/IEventPublisher.cs.meta b/Assets/Scripts/IConnector.cs.meta similarity index 100% rename from Assets/Scripts/IEventPublisher.cs.meta rename to Assets/Scripts/IConnector.cs.meta diff --git a/Assets/Scripts/IEventConnectable.cs b/Assets/Scripts/IEventConnectable.cs deleted file mode 100644 index 7f17523..0000000 --- a/Assets/Scripts/IEventConnectable.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace EventConnector -{ - public interface IEventConnectable - { - } -} \ No newline at end of file diff --git a/Assets/Scripts/IEventConnectable.cs.meta b/Assets/Scripts/IEventConnectable.cs.meta deleted file mode 100644 index 6f12486..0000000 --- a/Assets/Scripts/IEventConnectable.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 82691cf81f1b438d844cdeb82cd6d089 -timeCreated: 1562827163 \ No newline at end of file diff --git a/Assets/Scripts/IEventPublisher.cs b/Assets/Scripts/IEventPublisher.cs deleted file mode 100644 index 745d360..0000000 --- a/Assets/Scripts/IEventPublisher.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace EventConnector -{ - public interface IEventPublisher : IEventConnectable - { - IObservable OnPublishAsObservable(); - void Connect(IObservable source); - } -} \ No newline at end of file diff --git a/Assets/Scripts/IEventReceiver.cs b/Assets/Scripts/IEventReceiver.cs deleted file mode 100644 index fe23d9e..0000000 --- a/Assets/Scripts/IEventReceiver.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace EventConnector -{ - public interface IEventReceiver : IEventConnectable - { - void OnReceive(EventMessages eventMessages); - } -} \ No newline at end of file diff --git a/Assets/Scripts/IInjectable.cs b/Assets/Scripts/IInjectable.cs new file mode 100644 index 0000000..a9d106b --- /dev/null +++ b/Assets/Scripts/IInjectable.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.Linq; + +namespace UniFlow +{ + public interface IInjectable + { + void Inject(TValue value); + } + + public static class InjectableExtensions + { + public static void InjectAll(this IEnumerable> injectables, TValue value) + { + injectables.ToList().ForEach(x => x.Inject(value)); + } + } +} diff --git a/Assets/Scripts/IInjectable.cs.meta b/Assets/Scripts/IInjectable.cs.meta new file mode 100644 index 0000000..60483ce --- /dev/null +++ b/Assets/Scripts/IInjectable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2c7c0dde06634a2288ea5add7d04e430 +timeCreated: 1571237690 \ No newline at end of file diff --git a/Assets/Scripts/IMessageCollectable.cs b/Assets/Scripts/IMessageCollectable.cs new file mode 100644 index 0000000..32bc9ff --- /dev/null +++ b/Assets/Scripts/IMessageCollectable.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace UniFlow +{ + public interface IMessageCollectable + { + IEnumerable GetMessageCollectableAnnotations(); + } +} diff --git a/Assets/Scripts/IMessageCollectable.cs.meta b/Assets/Scripts/IMessageCollectable.cs.meta new file mode 100644 index 0000000..d76772b --- /dev/null +++ b/Assets/Scripts/IMessageCollectable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 50110082724742419a1b005d85d13dcb +timeCreated: 1571105816 \ No newline at end of file diff --git a/Assets/Scripts/IMessageComposable.cs b/Assets/Scripts/IMessageComposable.cs new file mode 100644 index 0000000..b2dc0ad --- /dev/null +++ b/Assets/Scripts/IMessageComposable.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; + +namespace UniFlow +{ + public interface IMessageComposable + { + IEnumerable GetMessageComposableAnnotations(); + } + + public static class MessageComposableExtensions + { + public static Message ComposeAll(this IMessageComposable messageComposable, Message message) + { + foreach (var messageComposableAnnotation in messageComposable.GetMessageComposableAnnotations()) + { + message = messageComposableAnnotation.Compose(message); + } + + return message; + } + } +} diff --git a/Assets/Scripts/IMessageComposable.cs.meta b/Assets/Scripts/IMessageComposable.cs.meta new file mode 100644 index 0000000..f4ffdd1 --- /dev/null +++ b/Assets/Scripts/IMessageComposable.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: cb16a7b2aea540a98fe2692aae401516 +timeCreated: 1571105788 \ No newline at end of file diff --git a/Assets/Scripts/IObservableReceiver.cs b/Assets/Scripts/IObservableReceiver.cs new file mode 100644 index 0000000..d756c1e --- /dev/null +++ b/Assets/Scripts/IObservableReceiver.cs @@ -0,0 +1,10 @@ +using System; +using UniRx; + +namespace UniFlow +{ + public interface IObservableReceiver : IReceiver + { + IObservable OnReceiveAsObservable(); + } +} diff --git a/Assets/Scripts/IObservableReceiver.cs.meta b/Assets/Scripts/IObservableReceiver.cs.meta new file mode 100644 index 0000000..56e5f6a --- /dev/null +++ b/Assets/Scripts/IObservableReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0caf9d28748d46c89a8d899f9681d870 +timeCreated: 1567268582 \ No newline at end of file diff --git a/Assets/Scripts/IReceiver.cs b/Assets/Scripts/IReceiver.cs new file mode 100644 index 0000000..14d3522 --- /dev/null +++ b/Assets/Scripts/IReceiver.cs @@ -0,0 +1,7 @@ +namespace UniFlow +{ + public interface IReceiver : IConnector + { + void OnReceive(); + } +} diff --git a/Assets/Scripts/IEventReceiver.cs.meta b/Assets/Scripts/IReceiver.cs.meta similarity index 100% rename from Assets/Scripts/IEventReceiver.cs.meta rename to Assets/Scripts/IReceiver.cs.meta diff --git a/Assets/Scripts/ISignal.cs b/Assets/Scripts/ISignal.cs new file mode 100644 index 0000000..874c4bf --- /dev/null +++ b/Assets/Scripts/ISignal.cs @@ -0,0 +1,12 @@ +using System; + +namespace UniFlow +{ + public interface ISignal + { + } + + public interface ISignal : ISignal, IEquatable + { + } +} diff --git a/Assets/Scripts/ISignal.cs.meta b/Assets/Scripts/ISignal.cs.meta new file mode 100644 index 0000000..2e89705 --- /dev/null +++ b/Assets/Scripts/ISignal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 15a0e408eae1d4aaf8a42d004565cdc0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/IValueCollector.cs b/Assets/Scripts/IValueCollector.cs new file mode 100644 index 0000000..3c3bd04 --- /dev/null +++ b/Assets/Scripts/IValueCollector.cs @@ -0,0 +1,17 @@ +namespace UniFlow +{ + public interface IValueCollector + { + IConnector SourceConnector { get; set; } + IConnector TargetConnector { get; set; } + string TypeString { get; set; } + string ComposerKey { get; set; } + string CollectorKey { get; set; } + } + + public interface IValueCollector : IValueCollector + { + TValue Collect(); + bool CanCollect(); + } +} diff --git a/Assets/Scripts/IValueCollector.cs.meta b/Assets/Scripts/IValueCollector.cs.meta new file mode 100644 index 0000000..d9cb94e --- /dev/null +++ b/Assets/Scripts/IValueCollector.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: faab41cb299b476f9202ec2030e92562 +timeCreated: 1571122145 \ No newline at end of file diff --git a/Assets/Scripts/InjectId.cs b/Assets/Scripts/InjectId.cs new file mode 100644 index 0000000..429d45a --- /dev/null +++ b/Assets/Scripts/InjectId.cs @@ -0,0 +1,7 @@ +namespace UniFlow +{ + public static class InjectId + { + public const string SceneNamePrefix = "SceneNamePrefix"; + } +} \ No newline at end of file diff --git a/Assets/Scripts/InjectId.cs.meta b/Assets/Scripts/InjectId.cs.meta new file mode 100644 index 0000000..7801e23 --- /dev/null +++ b/Assets/Scripts/InjectId.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 786da2bc699a4d349c8dd2a7d6362145 +timeCreated: 1566377588 \ No newline at end of file diff --git a/Assets/Scripts/Installer.meta b/Assets/Scripts/Installer.meta new file mode 100644 index 0000000..160c0b6 --- /dev/null +++ b/Assets/Scripts/Installer.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6faa808c7797452186ee5f3ee2eddf8a +timeCreated: 1566377768 \ No newline at end of file diff --git a/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs b/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs new file mode 100644 index 0000000..4d8ffd4 --- /dev/null +++ b/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using Zenject; + +namespace UniFlow.Installer +{ + public class SceneNamePrefixInstaller : MonoInstaller + { + [SerializeField] private string sceneNamePrefix = default; + private string SceneNamePrefix => sceneNamePrefix; + + public override void InstallBindings() + { + Container.BindInstance(SceneNamePrefix).WithId(InjectId.SceneNamePrefix).AsCached(); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs.meta b/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs.meta new file mode 100644 index 0000000..bf960ba --- /dev/null +++ b/Assets/Scripts/Installer/SceneNamePrefixInstaller.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e9e46a5f65894e82a0d111a62ba9bee3 +timeCreated: 1566377673 \ No newline at end of file diff --git a/Assets/Scripts/Installer/UniFlowInstaller.cs b/Assets/Scripts/Installer/UniFlowInstaller.cs new file mode 100644 index 0000000..f981567 --- /dev/null +++ b/Assets/Scripts/Installer/UniFlowInstaller.cs @@ -0,0 +1,33 @@ +using System.Diagnostics.CodeAnalysis; +using JetBrains.Annotations; +using UniFlow.Signal; +using UniFlow.Utility; +using UnityEngine; +using Zenject; + +namespace UniFlow.Installer +{ + [CreateAssetMenu(menuName = "Installers/UniFlowInstaller", fileName = "UniFlowInstaller")] + public class UniFlowInstaller : ScriptableObjectInstaller + { + public override void InstallBindings() + { + Container.DeclareUniFlowSignal(); + Container.DeclareUniFlowSignal(); + Container.DeclareUniFlowSignal(); + Container.DeclareUniFlowSignal(); + Container.DeclareUniFlowSignal(); + } + + [UsedImplicitly] + [SuppressMessage("ReSharper", "ObjectCreationAsStatement")] + private void AOTWorkaround() + { + new SignalHandler(); + new SignalHandler(); + new SignalHandler(); + new SignalHandler(); + new SignalHandler(); + } + } +} diff --git a/Assets/Scripts/Installer/UniFlowInstaller.cs.meta b/Assets/Scripts/Installer/UniFlowInstaller.cs.meta new file mode 100644 index 0000000..376d9a0 --- /dev/null +++ b/Assets/Scripts/Installer/UniFlowInstaller.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3785a4ba4e2b4fcc81b428da2930f35d +timeCreated: 1571582936 \ No newline at end of file diff --git a/Assets/Scripts/Logger.cs b/Assets/Scripts/Logger.cs new file mode 100644 index 0000000..cde16ca --- /dev/null +++ b/Assets/Scripts/Logger.cs @@ -0,0 +1,32 @@ +using System; +using UniRx; + +namespace UniFlow +{ + public static class Logger + { + public static bool IsEnabled { get; private set; } + + private static ISubject ConnectorSubject { get; } = new Subject(); + + public static void Activate() + { + IsEnabled = true; + } + + public static void Deactivate() + { + IsEnabled = false; + } + + public static void Log(IConnector connector) + { + ConnectorSubject.OnNext(connector); + } + + public static IObservable OnMessageAsObservable() + { + return ConnectorSubject; + } + } +} diff --git a/Assets/Scripts/Logger.cs.meta b/Assets/Scripts/Logger.cs.meta new file mode 100644 index 0000000..f6bb3eb --- /dev/null +++ b/Assets/Scripts/Logger.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: dc86192205524a3a9e6a7bea68f3ebb6 +timeCreated: 1569900372 \ No newline at end of file diff --git a/Assets/Scripts/Message.cs b/Assets/Scripts/Message.cs new file mode 100644 index 0000000..35e3697 --- /dev/null +++ b/Assets/Scripts/Message.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow +{ + [PublicAPI] + public struct Message + { + public Message(IConnector connector, IDictionary> parameters = default) + { + this.connector = connector; + this.parameters = parameters; + streamedMessages = default; + } + + private IConnector connector; + private IDictionary> parameters; + private IList streamedMessages; + + private IDictionary> Parameters => parameters ?? (parameters = new Dictionary>()); + + public IConnector Connector => connector; + public IList StreamedMessages + { + get => streamedMessages ?? (streamedMessages = new List()); + set => streamedMessages = value; + } + + public static Message Create(IConnector connector) + { + return new Message(connector); + } + + public static Message Create(IConnector connector, T value) + { + return new Message(connector).AddParameter(value); + } + + public static Message Create(IConnector connector, T value, string key) + { + return new Message(connector).AddParameter(value, key); + } + + public Message AddParameter(T value) + { + SetValue(string.Empty, value); + return this; + } + + public Message AddParameter(T value, string key) + { + SetValue(key, value); + return this; + } + + public bool HasParameter() + { + return HasValue(string.Empty); + } + + public bool HasParameter(string key) + { + return HasValue(key); + } + + public T GetParameter() + { + return GetValue(string.Empty); + } + + public T GetParameter(string key) + { + return GetValue(key); + } + + private bool HasValue(string key) + { + var type = DeterminateType(); + return Parameters.ContainsKey(type) && Parameters[type].ContainsKey(key); + } + + private T GetValue(string key) + { + var type = DeterminateType(); + + if (!Parameters.ContainsKey(type)) + { + Parameters.Add(type, new Dictionary()); + } + + if (!Parameters[type].ContainsKey(key)) + { + return default; + } + + return (T) Parameters[type][key]; + } + + private void SetValue(string key, T value) + { + var type = DeterminateType(); + + if (!Parameters.ContainsKey(type)) + { + Parameters.Add(type, new Dictionary()); + } + + Parameters[type][key] = value; + } + + private static Type DeterminateType() + { + if (typeof(ScriptableObject).IsAssignableFrom(typeof(T))) + { + return typeof(ScriptableObject); + } + + if (typeof(T).IsEnum) + { + return typeof(int); + } + + return typeof(T); + } + } +} diff --git a/Assets/Scripts/Message.cs.meta b/Assets/Scripts/Message.cs.meta new file mode 100644 index 0000000..38d210e --- /dev/null +++ b/Assets/Scripts/Message.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: be0e7af328f04a199122fce750711034 +timeCreated: 1570879955 \ No newline at end of file diff --git a/Assets/Scripts/Message.meta b/Assets/Scripts/Message.meta deleted file mode 100644 index 58785e8..0000000 --- a/Assets/Scripts/Message.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: ad2c669cffa84928b8249bc156935388 -timeCreated: 1562831729 \ No newline at end of file diff --git a/Assets/Scripts/Message/AnimatorTriggerEventData.cs b/Assets/Scripts/Message/AnimatorTriggerEventData.cs deleted file mode 100644 index 05b19f6..0000000 --- a/Assets/Scripts/Message/AnimatorTriggerEventData.cs +++ /dev/null @@ -1,24 +0,0 @@ -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class AnimatorTriggerEventData - { - private AnimatorTriggerEventData(int triggerId, string triggerName) - { - TriggerId = triggerId; - TriggerName = triggerName; - } - - public int TriggerId { get; } - public string TriggerName { get; } - - public static AnimatorTriggerEventData Create(int triggerId, string triggerName) => - new AnimatorTriggerEventData(triggerId, triggerName); - - public static AnimatorTriggerEventData Create(string triggerName) => - new AnimatorTriggerEventData(Animator.StringToHash(triggerName), triggerName); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/AnimatorTriggerEventData.cs.meta b/Assets/Scripts/Message/AnimatorTriggerEventData.cs.meta deleted file mode 100644 index 72f475b..0000000 --- a/Assets/Scripts/Message/AnimatorTriggerEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 46d1f2ee10d2498e82eb1ca1c7e496fe -timeCreated: 1562839912 \ No newline at end of file diff --git a/Assets/Scripts/Message/AudioControllerEventData.cs b/Assets/Scripts/Message/AudioControllerEventData.cs deleted file mode 100644 index b5f58c5..0000000 --- a/Assets/Scripts/Message/AudioControllerEventData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using EventConnector.Connector; - -namespace EventConnector.Message -{ - public struct AudioControllerEventData - { - private AudioControllerEventData(AudioControlMethod audioControlMethod) - { - AudioControlMethod = audioControlMethod; - } - - public AudioControlMethod AudioControlMethod { get; } - - public static AudioControllerEventData Create(AudioControlMethod audioControlMethod) => - new AudioControllerEventData(audioControlMethod); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/AudioControllerEventData.cs.meta b/Assets/Scripts/Message/AudioControllerEventData.cs.meta deleted file mode 100644 index 07387e4..0000000 --- a/Assets/Scripts/Message/AudioControllerEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4ee25aed1d3b43a59a9150fda0beac50 -timeCreated: 1565094847 \ No newline at end of file diff --git a/Assets/Scripts/Message/AudioEventData.cs b/Assets/Scripts/Message/AudioEventData.cs deleted file mode 100644 index 421639d..0000000 --- a/Assets/Scripts/Message/AudioEventData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using EventConnector.Connector; - -namespace EventConnector.Message -{ - public struct AudioEventData - { - private AudioEventData(AudioEventType audioEventType) - { - EventType = audioEventType; - } - - public AudioEventType EventType { get; } - - public static AudioEventData Create(AudioEventType audioEventType) => - new AudioEventData(audioEventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/AudioEventData.cs.meta b/Assets/Scripts/Message/AudioEventData.cs.meta deleted file mode 100644 index 2bf9d97..0000000 --- a/Assets/Scripts/Message/AudioEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 69da189c99e54ca1afad81fac77e9cc5 -timeCreated: 1565086657 \ No newline at end of file diff --git a/Assets/Scripts/Message/CameraEventData.cs b/Assets/Scripts/Message/CameraEventData.cs deleted file mode 100644 index 2d178e1..0000000 --- a/Assets/Scripts/Message/CameraEventData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using EventConnector.Connector; - -namespace EventConnector.Message -{ - public class CameraEventData - { - private CameraEventData(CameraEventType eventType) - { - EventType = eventType; - } - - public CameraEventType EventType { get; } - - public static CameraEventData Create(CameraEventType eventType) => - new CameraEventData(eventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/CameraEventData.cs.meta b/Assets/Scripts/Message/CameraEventData.cs.meta deleted file mode 100644 index f995a33..0000000 --- a/Assets/Scripts/Message/CameraEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 81d19bc1e99049c698def60aba9f297a -timeCreated: 1563243897 \ No newline at end of file diff --git a/Assets/Scripts/Message/LifecycleEventData.cs b/Assets/Scripts/Message/LifecycleEventData.cs deleted file mode 100644 index 6fc7196..0000000 --- a/Assets/Scripts/Message/LifecycleEventData.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using EventConnector.Connector; -using JetBrains.Annotations; - -namespace EventConnector.Message -{ - [Serializable][PublicAPI] - public class LifecycleEventData - { - private LifecycleEventData(LifecycleEventType eventType) - { - EventType = eventType; - } - - public LifecycleEventType EventType { get; } - - public static LifecycleEventData Create(LifecycleEventType lifecycleEventType) => - new LifecycleEventData(lifecycleEventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/LifecycleEventData.cs.meta b/Assets/Scripts/Message/LifecycleEventData.cs.meta deleted file mode 100644 index d7d6c70..0000000 --- a/Assets/Scripts/Message/LifecycleEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 3bdde5cf4d3f405aa48422a067da4551 -timeCreated: 1562934668 \ No newline at end of file diff --git a/Assets/Scripts/Message/MouseEventData.cs b/Assets/Scripts/Message/MouseEventData.cs deleted file mode 100644 index 2da6009..0000000 --- a/Assets/Scripts/Message/MouseEventData.cs +++ /dev/null @@ -1,17 +0,0 @@ -using EventConnector.Connector; - -namespace EventConnector.Message -{ - public class MouseEventData - { - private MouseEventData(MouseEventType eventType) - { - EventType = eventType; - } - - public MouseEventType EventType { get; } - - public static MouseEventData Create(MouseEventType eventType) => - new MouseEventData(eventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/MouseEventData.cs.meta b/Assets/Scripts/Message/MouseEventData.cs.meta deleted file mode 100644 index 1fd9506..0000000 --- a/Assets/Scripts/Message/MouseEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: bfec1eabb47b4446bbaaea32df253a8f -timeCreated: 1563256095 \ No newline at end of file diff --git a/Assets/Scripts/Message/ParticleEventData.cs b/Assets/Scripts/Message/ParticleEventData.cs deleted file mode 100644 index 4abb1bb..0000000 --- a/Assets/Scripts/Message/ParticleEventData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class ParticleEventData - { - private ParticleEventData(ParticleEventType eventType, GameObject gameObject) - { - EventType = eventType; - GameObject = gameObject; - } - - public ParticleEventType EventType { get; } - public GameObject GameObject { get; } - - public static ParticleEventData Create(ParticleEventType eventType, GameObject gameObject) => - new ParticleEventData(eventType, gameObject); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/ParticleEventData.cs.meta b/Assets/Scripts/Message/ParticleEventData.cs.meta deleted file mode 100644 index 61f1671..0000000 --- a/Assets/Scripts/Message/ParticleEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 5ebdda4e42744f339a218d8d8b81161e -timeCreated: 1563260816 \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsCollision2DEventData.cs b/Assets/Scripts/Message/PhysicsCollision2DEventData.cs deleted file mode 100644 index d899ce1..0000000 --- a/Assets/Scripts/Message/PhysicsCollision2DEventData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class PhysicsCollision2DEventData - { - private PhysicsCollision2DEventData(PhysicsCollision2DEventType eventType, Collision2D collision2D) - { - EventType = eventType; - Collision2D = collision2D; - } - - public PhysicsCollision2DEventType EventType { get; } - public Collision2D Collision2D { get; } - - public static PhysicsCollision2DEventData Create(PhysicsCollision2DEventType eventType, Collision2D collision2D) => - new PhysicsCollision2DEventData(eventType, collision2D); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsCollision2DEventData.cs.meta b/Assets/Scripts/Message/PhysicsCollision2DEventData.cs.meta deleted file mode 100644 index fbdf435..0000000 --- a/Assets/Scripts/Message/PhysicsCollision2DEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1faf6f0253ec44968d97185134bf26db -timeCreated: 1563255207 \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsCollisionEventData.cs b/Assets/Scripts/Message/PhysicsCollisionEventData.cs deleted file mode 100644 index 9579de8..0000000 --- a/Assets/Scripts/Message/PhysicsCollisionEventData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class PhysicsCollisionEventData - { - private PhysicsCollisionEventData(PhysicsCollisionEventType eventType, Collision collision) - { - EventType = eventType; - Collision = collision; - } - - public PhysicsCollisionEventType EventType { get; } - public Collision Collision { get; } - - public static PhysicsCollisionEventData Create(PhysicsCollisionEventType eventType, Collision collision) => - new PhysicsCollisionEventData(eventType, collision); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsCollisionEventData.cs.meta b/Assets/Scripts/Message/PhysicsCollisionEventData.cs.meta deleted file mode 100644 index 824cb48..0000000 --- a/Assets/Scripts/Message/PhysicsCollisionEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: c302f45d90064f4bb537fd7fc412e55e -timeCreated: 1563245854 \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs b/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs deleted file mode 100644 index 6c39e0e..0000000 --- a/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class PhysicsTrigger2DEventData - { - private PhysicsTrigger2DEventData(PhysicsTrigger2DEventType eventType, Collider2D collider2D) - { - EventType = eventType; - Collider2D = collider2D; - } - - public PhysicsTrigger2DEventType EventType { get; } - public Collider2D Collider2D { get; } - - public static PhysicsTrigger2DEventData Create(PhysicsTrigger2DEventType eventType, Collider2D collider2D) => - new PhysicsTrigger2DEventData(eventType, collider2D); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs.meta b/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs.meta deleted file mode 100644 index 491e0c4..0000000 --- a/Assets/Scripts/Message/PhysicsTrigger2DEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 4136daf408aa4aa78f72c328c9b8f93f -timeCreated: 1563255198 \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsTriggerEventData.cs b/Assets/Scripts/Message/PhysicsTriggerEventData.cs deleted file mode 100644 index 80e2f16..0000000 --- a/Assets/Scripts/Message/PhysicsTriggerEventData.cs +++ /dev/null @@ -1,22 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; -using UnityEngine; - -namespace EventConnector.Message -{ - [PublicAPI] - public class PhysicsTriggerEventData - { - private PhysicsTriggerEventData(PhysicsTriggerEventType eventType, Collider collider) - { - EventType = eventType; - Collider = collider; - } - - public PhysicsTriggerEventType EventType { get; } - public Collider Collider { get; } - - public static PhysicsTriggerEventData Create(PhysicsTriggerEventType eventType, Collider collider) => - new PhysicsTriggerEventData(eventType, collider); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/PhysicsTriggerEventData.cs.meta b/Assets/Scripts/Message/PhysicsTriggerEventData.cs.meta deleted file mode 100644 index 17ac283..0000000 --- a/Assets/Scripts/Message/PhysicsTriggerEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1f78155e10194efa95b4aaf648c9e5ea -timeCreated: 1563255185 \ No newline at end of file diff --git a/Assets/Scripts/Message/PlayableControllerEventData.cs b/Assets/Scripts/Message/PlayableControllerEventData.cs deleted file mode 100644 index abc125e..0000000 --- a/Assets/Scripts/Message/PlayableControllerEventData.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace EventConnector.Message -{ - public class PlayableControllerEventData - { - public static PlayableControllerEventData Create() => - new PlayableControllerEventData(); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/PlayableControllerEventData.cs.meta b/Assets/Scripts/Message/PlayableControllerEventData.cs.meta deleted file mode 100644 index ed106eb..0000000 --- a/Assets/Scripts/Message/PlayableControllerEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 049e9e77cf6f4b74b7b85b48b39e5712 -timeCreated: 1562857068 \ No newline at end of file diff --git a/Assets/Scripts/Message/RectTransformEventData.cs b/Assets/Scripts/Message/RectTransformEventData.cs deleted file mode 100644 index 9d87576..0000000 --- a/Assets/Scripts/Message/RectTransformEventData.cs +++ /dev/null @@ -1,19 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; - -namespace EventConnector.Message -{ - [PublicAPI] - public class RectTransformEventData - { - private RectTransformEventData(RectTransformEventType eventType) - { - EventType = eventType; - } - - public RectTransformEventType EventType { get; } - - public static RectTransformEventData Create(RectTransformEventType eventType) => - new RectTransformEventData(eventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/RectTransformEventData.cs.meta b/Assets/Scripts/Message/RectTransformEventData.cs.meta deleted file mode 100644 index dd33e71..0000000 --- a/Assets/Scripts/Message/RectTransformEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 1af088cd06584b21a0ec9f4e6bfa49e2 -timeCreated: 1563262890 \ No newline at end of file diff --git a/Assets/Scripts/Message/TimelineEventData.cs b/Assets/Scripts/Message/TimelineEventData.cs deleted file mode 100644 index ff335ca..0000000 --- a/Assets/Scripts/Message/TimelineEventData.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using JetBrains.Annotations; -using UnityEngine; -using Object = UnityEngine.Object; - -namespace EventConnector.Message -{ - [Serializable][PublicAPI] - public class TimelineEventData - { - [SerializeField] private int intParameter = default; - [SerializeField] private float floatParameter = default; - [SerializeField] private string stringParameter = default; - [SerializeField] private Object objectReferenceParameter = default; - public int IntParameter => intParameter; - public float FloatParameter => floatParameter; - public string StringParameter => stringParameter; - public Object ObjectReferenceParameter => objectReferenceParameter; - - public TimelineEventData(float floatValue) : this(default, floatValue) - { - } - - public TimelineEventData(string stringValue) : this(default, default, stringValue) - { - } - - public TimelineEventData(Object objectValue) : this(default, default, default, objectValue) - { - } - - public TimelineEventData(int intParameter = default, float floatParameter = default, string stringParameter = default, Object objectReferenceParameter = default) - { - this.intParameter = intParameter; - this.floatParameter = floatParameter; - this.stringParameter = stringParameter; - this.objectReferenceParameter = objectReferenceParameter; - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/TimelineEventData.cs.meta b/Assets/Scripts/Message/TimelineEventData.cs.meta deleted file mode 100644 index 1dced08..0000000 --- a/Assets/Scripts/Message/TimelineEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 20501c40f9894284b01b4f118fb62184 -timeCreated: 1562831729 \ No newline at end of file diff --git a/Assets/Scripts/Message/TransformEventData.cs b/Assets/Scripts/Message/TransformEventData.cs deleted file mode 100644 index 271ae3b..0000000 --- a/Assets/Scripts/Message/TransformEventData.cs +++ /dev/null @@ -1,19 +0,0 @@ -using EventConnector.Connector; -using JetBrains.Annotations; - -namespace EventConnector.Message -{ - [PublicAPI] - public class TransformEventData - { - private TransformEventData(TransformEventType eventType) - { - EventType = eventType; - } - - public TransformEventType EventType { get; } - - public static TransformEventData Create(TransformEventType eventType) => - new TransformEventData(eventType); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Message/TransformEventData.cs.meta b/Assets/Scripts/Message/TransformEventData.cs.meta deleted file mode 100644 index ecb6cea..0000000 --- a/Assets/Scripts/Message/TransformEventData.cs.meta +++ /dev/null @@ -1,3 +0,0 @@ -fileFormatVersion: 2 -guid: 2cb9662b293f4e6b8d53957073d8c712 -timeCreated: 1563262873 \ No newline at end of file diff --git a/Assets/Scripts/MessageAnnotation.cs b/Assets/Scripts/MessageAnnotation.cs new file mode 100644 index 0000000..9223c8f --- /dev/null +++ b/Assets/Scripts/MessageAnnotation.cs @@ -0,0 +1,121 @@ +using System; +using UnityEngine; + +namespace UniFlow +{ + public interface IComposableMessageAnnotation + { + Type Type { get; } + string Key { get; } + Message Compose(Message message); + } + + public class ComposableMessageAnnotation : IComposableMessageAnnotation + { + internal ComposableMessageAnnotation(Func callback, string key) + { + Type = typeof(TValue); + Callback = callback; + Key = key; + } + + public Type Type { get; } + public string Key { get; } + private Func Callback { get; } + + Message IComposableMessageAnnotation.Compose(Message message) + { + if (Callback != default) + { + message = message.AddParameter(Callback(), Key); + } + + return message; + } + } + + public interface ICollectableMessageAnnotation + { + Type Type { get; } + IValueCollector ValueCollector { get; } + string Key { get; } + void Collect(); + void Inject(GameObject gameObject); + } + + public class CollectableMessageAnnotation : ICollectableMessageAnnotation + { + internal CollectableMessageAnnotation(IValueCollector valueCollector, Action callback, string key) + { + Type = typeof(TValue); + ValueCollector = valueCollector; + Callback = callback; + Key = key; + } + + public Type Type { get; } + public IValueCollector ValueCollector { get; } + public string Key { get; } + private Action Callback { get; } + + void ICollectableMessageAnnotation.Collect() + { + if (ValueCollector?.TargetConnector != default && ValueCollector?.SourceConnector != default) + { + Callback?.Invoke(GetValue()); + } + } + + void ICollectableMessageAnnotation.Inject(GameObject gameObject) + { + gameObject.GetComponentsInChildren>().InjectAll(GetValue()); + } + + private TValue GetValue() + { + var result = default(TValue); + if (ValueCollector is IValueCollector valueCollector && valueCollector.CanCollect()) + { + result = valueCollector.Collect(); + } + + return result; + } + } + + public static class ComposableMessageAnnotationFactory + { + public static IComposableMessageAnnotation Create() + { + return Create(null, typeof(TValue).Name); + } + + public static IComposableMessageAnnotation Create(string key) + { + return Create(null, key); + } + + public static IComposableMessageAnnotation Create(Func callback) + { + return Create(callback, typeof(TValue).Name); + } + + public static IComposableMessageAnnotation Create(Func callback, string key) + { + return new ComposableMessageAnnotation(callback, key); + } + } + + public static class CollectableMessageAnnotationFactory + { + public static ICollectableMessageAnnotation Create(IValueCollector valueCollector, Action callback) + { + return Create(valueCollector, callback, typeof(TValue).Name); + } + + public static ICollectableMessageAnnotation Create(IValueCollector valueCollector, Action callback, string key) + { + return new CollectableMessageAnnotation(valueCollector, callback, key); + } + } +} diff --git a/Assets/Scripts/MessageAnnotation.cs.meta b/Assets/Scripts/MessageAnnotation.cs.meta new file mode 100644 index 0000000..950407d --- /dev/null +++ b/Assets/Scripts/MessageAnnotation.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f5775525bf1d46a2a3ed82a1d3fde801 +timeCreated: 1571107856 \ No newline at end of file diff --git a/Assets/Scripts/Receiver.meta b/Assets/Scripts/Receiver.meta new file mode 100644 index 0000000..85f919c --- /dev/null +++ b/Assets/Scripts/Receiver.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 81b04987def84653bd09df060b83bb0b +timeCreated: 1565329110 \ No newline at end of file diff --git a/Assets/Scripts/Receiver/EmptyReceiver.cs b/Assets/Scripts/Receiver/EmptyReceiver.cs new file mode 100644 index 0000000..3066d3d --- /dev/null +++ b/Assets/Scripts/Receiver/EmptyReceiver.cs @@ -0,0 +1,13 @@ +using UnityEngine; + +namespace UniFlow.Receiver +{ + [AddComponentMenu("UniFlow/Receiver/EmptyReceiver", (int) ConnectorType.Receiver)] + public class EmptyReceiver : ReceiverBase + { + public override void OnReceive() + { + // Do nothing. + } + } +} diff --git a/Assets/Scripts/EmptyEventReceiver.cs.meta b/Assets/Scripts/Receiver/EmptyReceiver.cs.meta similarity index 100% rename from Assets/Scripts/EmptyEventReceiver.cs.meta rename to Assets/Scripts/Receiver/EmptyReceiver.cs.meta diff --git a/Assets/Scripts/Receiver/LoggerReceiver.cs b/Assets/Scripts/Receiver/LoggerReceiver.cs new file mode 100644 index 0000000..302265c --- /dev/null +++ b/Assets/Scripts/Receiver/LoggerReceiver.cs @@ -0,0 +1,31 @@ +using System.Collections.Generic; +using System.Text; +using UniRx; +using UnityEngine; + +namespace UniFlow.Receiver +{ + [AddComponentMenu("UniFlow/Receiver/LoggerReceiver", (int) ConnectorType.Receiver)] + public class LoggerReceiver : ReceiverBase + { + private IList Connectors { get; } = new List(); + + private void Awake() + { + Logger.Activate(); + Logger.OnMessageAsObservable().Subscribe(Connectors.Add); + } + + public override void OnReceive() + { + var sb = new StringBuilder(); + sb.AppendLine($"Count: {Connectors.Count}"); + sb.AppendLine("Connectors:"); + foreach (var connector in Connectors) + { + sb.AppendLine($" {connector.GetType().Name}"); + } + Debug.Log(sb.ToString()); + } + } +} diff --git a/Assets/Scripts/Receiver/LoggerReceiver.cs.meta b/Assets/Scripts/Receiver/LoggerReceiver.cs.meta new file mode 100644 index 0000000..d2525af --- /dev/null +++ b/Assets/Scripts/Receiver/LoggerReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b50bafffc2a14308b4639d318d8ba1e8 +timeCreated: 1565418430 \ No newline at end of file diff --git a/Assets/Scripts/Receiver/ObservableReceiver.cs b/Assets/Scripts/Receiver/ObservableReceiver.cs new file mode 100644 index 0000000..1d5fc59 --- /dev/null +++ b/Assets/Scripts/Receiver/ObservableReceiver.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace UniFlow.Receiver +{ + [AddComponentMenu("UniFlow/Receiver/ObservableReceiver", (int) ConnectorType.Receiver)] + public class ObservableReceiver : ObservableReceiverBase + { + } +} diff --git a/Assets/Scripts/Receiver/ObservableReceiver.cs.meta b/Assets/Scripts/Receiver/ObservableReceiver.cs.meta new file mode 100644 index 0000000..c64239f --- /dev/null +++ b/Assets/Scripts/Receiver/ObservableReceiver.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: feb3f126ca1a492d8b187534467def01 +timeCreated: 1570121105 \ No newline at end of file diff --git a/Assets/Scripts/Receiver/ObservableReceiverBase.cs b/Assets/Scripts/Receiver/ObservableReceiverBase.cs new file mode 100644 index 0000000..f5dfa29 --- /dev/null +++ b/Assets/Scripts/Receiver/ObservableReceiverBase.cs @@ -0,0 +1,20 @@ +using System; +using UniRx; + +namespace UniFlow.Receiver +{ + public abstract class ObservableReceiverBase : ReceiverBase, IObservableReceiver + { + private ISubject OnReceiveSubject { get; } = new Subject(); + + IObservable IObservableReceiver.OnReceiveAsObservable() + { + return OnReceiveSubject; + } + + public override void OnReceive() + { + OnReceiveSubject.OnNext(Unit.Default); + } + } +} diff --git a/Assets/Scripts/Receiver/ObservableReceiverBase.cs.meta b/Assets/Scripts/Receiver/ObservableReceiverBase.cs.meta new file mode 100644 index 0000000..7e6ebc7 --- /dev/null +++ b/Assets/Scripts/Receiver/ObservableReceiverBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: be0ec6c605f14b139257077975e4230a +timeCreated: 1565873932 \ No newline at end of file diff --git a/Assets/Scripts/ReceiverBase.cs b/Assets/Scripts/ReceiverBase.cs new file mode 100644 index 0000000..24fc714 --- /dev/null +++ b/Assets/Scripts/ReceiverBase.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using UniFlow.Utility; + +namespace UniFlow +{ + public abstract class ReceiverBase : ConnectorBase, IReceiver + { + protected override IEnumerable TargetConnectors { get; } = new List(); + + public override IObservable OnConnectAsObservable() + { + OnReceive(); + return ObservableFactory.ReturnMessage(this); + } + + public abstract void OnReceive(); + } +} diff --git a/Assets/Scripts/EventReceiver.cs.meta b/Assets/Scripts/ReceiverBase.cs.meta similarity index 100% rename from Assets/Scripts/EventReceiver.cs.meta rename to Assets/Scripts/ReceiverBase.cs.meta diff --git a/Assets/Scripts/Signal.meta b/Assets/Scripts/Signal.meta new file mode 100644 index 0000000..492a118 --- /dev/null +++ b/Assets/Scripts/Signal.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6c2a9246861748068a2009a0126467bd +timeCreated: 1570615221 \ No newline at end of file diff --git a/Assets/Scripts/Signal/EnumSignalBase.cs b/Assets/Scripts/Signal/EnumSignalBase.cs new file mode 100644 index 0000000..fa5e9d5 --- /dev/null +++ b/Assets/Scripts/Signal/EnumSignalBase.cs @@ -0,0 +1,72 @@ +using System; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow.Signal +{ + [Serializable] + [PublicAPI] + public abstract class EnumSignalBase : SignalBase + where TSignal : EnumSignalBase, new() + where TEnum : Enum + { + [SerializeField] private TEnum enumValue = default; + + public override TEnum ComparableValue + { + get => enumValue; + set => enumValue = value; + } + } + + [PublicAPI] + public abstract class EnumScriptableObjectSignalBase : ScriptableObject, ISignal> + where TSignal : EnumScriptableObjectSignalBase + where TEnum : Enum + { + [SerializeField] private TEnum enumValue = default; + + public TEnum EnumValue + { + get => enumValue; + set => enumValue = value; + } + + public override bool Equals(object obj) + { + if (!(obj is EnumScriptableObjectSignalBase enumScriptableObjectSignal)) + { + return false; + } + + return Equals(EnumValue, enumScriptableObjectSignal.EnumValue); + } + + public override int GetHashCode() + { + return EnumValue.GetHashCode(); + } + + bool IEquatable>.Equals(EnumScriptableObjectSignalBase other) + { + return Equals(other); + } + + public static bool operator ==(EnumScriptableObjectSignalBase left, EnumScriptableObjectSignalBase right) + { + return Equals(left, right); + } + + public static bool operator !=(EnumScriptableObjectSignalBase left, EnumScriptableObjectSignalBase right) + { + return !Equals(left, right); + } + + public static TSignal Create(TEnum enumValue) + { + var signal = CreateInstance(); + signal.EnumValue = enumValue; + return signal; + } + } +} diff --git a/Assets/Scripts/Signal/EnumSignalBase.cs.meta b/Assets/Scripts/Signal/EnumSignalBase.cs.meta new file mode 100644 index 0000000..1cda3a2 --- /dev/null +++ b/Assets/Scripts/Signal/EnumSignalBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f868dacfe54a4feea1e01e26813b92b0 +timeCreated: 1571915970 \ No newline at end of file diff --git a/Assets/Scripts/Signal/HandleEventSignal.cs b/Assets/Scripts/Signal/HandleEventSignal.cs new file mode 100644 index 0000000..e5b48b7 --- /dev/null +++ b/Assets/Scripts/Signal/HandleEventSignal.cs @@ -0,0 +1,29 @@ +using System; +using JetBrains.Annotations; + +namespace UniFlow.Signal +{ + [PublicAPI] + public class HandleEventSignal : SignalBase + { + public HandleEventType HandleEventType { get; private set; } + + public override HandleEventType ComparableValue + { + get => HandleEventType; + set => HandleEventType = value; + } + } + + [PublicAPI] + public enum HandleEventType + { + Activate, + Deactivate, + } + + [Serializable] + public class HandleEventTypeCollector : ValueCollectorBase + { + } +} diff --git a/Assets/Scripts/Signal/HandleEventSignal.cs.meta b/Assets/Scripts/Signal/HandleEventSignal.cs.meta new file mode 100644 index 0000000..567da75 --- /dev/null +++ b/Assets/Scripts/Signal/HandleEventSignal.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dd8d05fecd0144910a4f88eca574cc51 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Signal/MusicControlSignal.cs b/Assets/Scripts/Signal/MusicControlSignal.cs new file mode 100644 index 0000000..760bf21 --- /dev/null +++ b/Assets/Scripts/Signal/MusicControlSignal.cs @@ -0,0 +1,24 @@ +using UniFlow.Connector.Controller; +using UnityEngine; + +namespace UniFlow.Signal +{ + public class MusicControlSignal : SignalBase + { + public AudioControlMethod AudioControlMethod { get; private set; } + public AudioClip AudioClip { get; private set; } + public bool Loop { get; private set; } = true; + public bool RewindSameClip { get; private set; } = false; + + public static MusicControlSignal Create(AudioControlMethod musicControlType, AudioClip audioClip, bool loop = true, bool rewindSameClip = false) + { + return new MusicControlSignal + { + AudioControlMethod = musicControlType, + AudioClip = audioClip, + Loop = loop, + RewindSameClip = rewindSameClip, + }; + } + } +} diff --git a/Assets/Scripts/Signal/MusicControlSignal.cs.meta b/Assets/Scripts/Signal/MusicControlSignal.cs.meta new file mode 100644 index 0000000..cbdb811 --- /dev/null +++ b/Assets/Scripts/Signal/MusicControlSignal.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e771178b3cc7477a880cd769d0411f8a +timeCreated: 1572429841 \ No newline at end of file diff --git a/Assets/Scripts/Signal/MusicDuckingSignal.cs b/Assets/Scripts/Signal/MusicDuckingSignal.cs new file mode 100644 index 0000000..cdbd449 --- /dev/null +++ b/Assets/Scripts/Signal/MusicDuckingSignal.cs @@ -0,0 +1,17 @@ +namespace UniFlow.Signal +{ + public class MusicDuckingSignal : SignalBase + { + public float Volume { get; private set; } + public float Duration { get; private set; } + + public static MusicDuckingSignal Create(float volume, float duration) + { + return new MusicDuckingSignal + { + Volume = volume, + Duration = duration, + }; + } + } +} diff --git a/Assets/Scripts/Signal/MusicDuckingSignal.cs.meta b/Assets/Scripts/Signal/MusicDuckingSignal.cs.meta new file mode 100644 index 0000000..d0ee0e5 --- /dev/null +++ b/Assets/Scripts/Signal/MusicDuckingSignal.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 24b1f23f31a64c96847d5a0a15f366e2 +timeCreated: 1572426096 \ No newline at end of file diff --git a/Assets/Scripts/Signal/MusicPitchSignal.cs b/Assets/Scripts/Signal/MusicPitchSignal.cs new file mode 100644 index 0000000..6f45440 --- /dev/null +++ b/Assets/Scripts/Signal/MusicPitchSignal.cs @@ -0,0 +1,17 @@ +namespace UniFlow.Signal +{ + public class MusicPitchSignal : SignalBase + { + public float Pitch { get; private set; } + public float Duration { get; private set; } + + public static MusicPitchSignal Create(float volume, float duration) + { + return new MusicPitchSignal + { + Pitch = volume, + Duration = duration, + }; + } + } +} diff --git a/Assets/Scripts/Signal/MusicPitchSignal.cs.meta b/Assets/Scripts/Signal/MusicPitchSignal.cs.meta new file mode 100644 index 0000000..09b502f --- /dev/null +++ b/Assets/Scripts/Signal/MusicPitchSignal.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 308f441149124b41ac5c2a7ee568e698 +timeCreated: 1572509130 \ No newline at end of file diff --git a/Assets/Scripts/Signal/ScriptableObjectSignal.cs b/Assets/Scripts/Signal/ScriptableObjectSignal.cs new file mode 100644 index 0000000..5dd0d37 --- /dev/null +++ b/Assets/Scripts/Signal/ScriptableObjectSignal.cs @@ -0,0 +1,85 @@ +using System; +using JetBrains.Annotations; +using UnityEngine; + +namespace UniFlow.Signal +{ + [PublicAPI] + public abstract class ScriptableObjectSignalBase : ScriptableObject, ISignal> + where TSignal : ScriptableObjectSignalBase + { + public override bool Equals(object obj) + { + return obj is TSignal; + } + + public override int GetHashCode() + { + return 0; + } + + bool IEquatable>.Equals(ScriptableObjectSignalBase other) + { + return Equals(other); + } + + public static TSignal Create() + { + return CreateInstance(); + } + + public static bool operator ==(ScriptableObjectSignalBase left, ScriptableObjectSignalBase right) + { + return Equals(left, right); + } + + public static bool operator !=(ScriptableObjectSignalBase left, ScriptableObjectSignalBase right) + { + return !Equals(left, right); + } + } + + [PublicAPI] + public abstract class ScriptableObjectSignalBase : ScriptableObject, ISignal> + where TSignal : ScriptableObjectSignalBase + { + protected abstract TComparableValue ComparableValue { get; set; } + + public override bool Equals(object obj) + { + if (!(obj is TSignal signal)) + { + return false; + } + + return Equals(ComparableValue, signal.ComparableValue); + } + + public override int GetHashCode() + { + return ComparableValue.GetHashCode(); + } + + bool IEquatable>.Equals(ScriptableObjectSignalBase other) + { + return Equals(other); + } + + public static TSignal Create(TComparableValue comparableValue) + { + var signal = CreateInstance(); + signal.ComparableValue = comparableValue; + return signal; + } + + public static bool operator ==(ScriptableObjectSignalBase left, ScriptableObjectSignalBase right) + { + return Equals(left, right); + } + + public static bool operator !=(ScriptableObjectSignalBase left, ScriptableObjectSignalBase right) + { + return !Equals(left, right); + } + } +} diff --git a/Assets/Scripts/Signal/ScriptableObjectSignal.cs.meta b/Assets/Scripts/Signal/ScriptableObjectSignal.cs.meta new file mode 100644 index 0000000..fb0baae --- /dev/null +++ b/Assets/Scripts/Signal/ScriptableObjectSignal.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e3ce82478d9c41ccbab0985350d89b33 +timeCreated: 1570622491 \ No newline at end of file diff --git a/Assets/Scripts/Signal/SignalBase.cs b/Assets/Scripts/Signal/SignalBase.cs new file mode 100644 index 0000000..05ab498 --- /dev/null +++ b/Assets/Scripts/Signal/SignalBase.cs @@ -0,0 +1,86 @@ +using System; +using JetBrains.Annotations; + +namespace UniFlow.Signal +{ + [PublicAPI] + public abstract class SignalBase : ISignal + where TSignal : SignalBase, new() + { + public override bool Equals(object obj) + { + return obj is TSignal; + } + + public override int GetHashCode() + { + return 0; + } + + bool IEquatable.Equals(TSignal other) + { + return true; + } + + public static TSignal Create() + { + return new TSignal(); + } + + public static bool operator ==(SignalBase first, SignalBase second) + { + return Equals(first, second); + } + + public static bool operator !=(SignalBase first, SignalBase second) + { + return !Equals(first, second); + } + } + + [Serializable] + [PublicAPI] + public abstract class SignalBase : ISignal + where TSignal : SignalBase, new() + { + public abstract TParameter ComparableValue { get; set; } + + public override bool Equals(object obj) + { + if (!(obj is TSignal signal)) + { + return false; + } + + return Equals(ComparableValue, signal.ComparableValue); + } + + public override int GetHashCode() + { + return ComparableValue.GetHashCode(); + } + + bool IEquatable.Equals(TSignal other) + { + return Equals(other); + } + + public static TSignal Create(TParameter comparableValue) + { + return new TSignal + { + ComparableValue = comparableValue, + }; + } + + public static bool operator ==(SignalBase first, SignalBase second) + { + return Equals(first, second); + } + + public static bool operator !=(SignalBase first, SignalBase second) + { + return !Equals(first, second); + } + } +} diff --git a/Assets/Scripts/Signal/SignalBase.cs.meta b/Assets/Scripts/Signal/SignalBase.cs.meta new file mode 100644 index 0000000..9e72e3f --- /dev/null +++ b/Assets/Scripts/Signal/SignalBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: d4ee291d70c4431d91aa379a747c35ea +timeCreated: 1571583826 \ No newline at end of file diff --git a/Assets/Scripts/Signal/StringSignal.cs b/Assets/Scripts/Signal/StringSignal.cs new file mode 100644 index 0000000..f80ffe1 --- /dev/null +++ b/Assets/Scripts/Signal/StringSignal.cs @@ -0,0 +1,94 @@ +using System; +using JetBrains.Annotations; +using UnityEngine; +using Object = UnityEngine.Object; + +namespace UniFlow.Signal +{ + [Serializable] + [PublicAPI] + public sealed class StringSignal : SignalBase + { + [SerializeField] private string signalName; + [SerializeField] private SignalParameter parameter; + + public override string ComparableValue + { + get => signalName; + set => signalName = value; + } + + public SignalParameter Parameter + { + get => parameter; + set => parameter = value; + } + + public static StringSignal Create(string signalName, SignalParameter signalParameter = default) + { + return new StringSignal + { + signalName = signalName, + parameter = signalParameter, + }; + } + + [Serializable] + [PublicAPI] + public struct SignalParameter + { + public SignalParameter(bool boolValue, int intValue, float floatValue, string stringValue, Object objectValue, ScriptableObject scriptableObjectValue) + { + this.boolValue = boolValue; + this.intValue = intValue; + this.floatValue = floatValue; + this.stringValue = stringValue; + this.objectValue = objectValue; + this.scriptableObjectValue = scriptableObjectValue; + } + + [SerializeField] private bool boolValue; + [SerializeField] private int intValue; + [SerializeField] private float floatValue; + [SerializeField] private string stringValue; + [SerializeField] private Object objectValue; + [SerializeField] private ScriptableObject scriptableObjectValue; + + public bool BoolValue + { + get => boolValue; + set => boolValue = value; + } + public int IntValue + { + get => intValue; + set => intValue = value; + } + public float FloatValue + { + get => floatValue; + set => floatValue = value; + } + public string StringValue + { + get => stringValue; + set => stringValue = value; + } + public Object ObjectValue + { + get => objectValue; + set => objectValue = value; + } + public ScriptableObject ScriptableObjectValue + { + get => scriptableObjectValue; + set => scriptableObjectValue = value; + } + } + } + + [Serializable] + public sealed class StringSignalCollector : ValueCollectorBase + { + } +} diff --git a/Assets/Scripts/Signal/StringSignal.cs.meta b/Assets/Scripts/Signal/StringSignal.cs.meta new file mode 100644 index 0000000..34ed81e --- /dev/null +++ b/Assets/Scripts/Signal/StringSignal.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 4a8ea613e5e647a3bcc4189364cce388 +timeCreated: 1570615221 \ No newline at end of file diff --git a/Assets/Scripts/SystemTypeExtensions.cs b/Assets/Scripts/SystemTypeExtensions.cs new file mode 100644 index 0000000..d03512d --- /dev/null +++ b/Assets/Scripts/SystemTypeExtensions.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using JetBrains.Annotations; + +namespace UniFlow +{ + [PublicAPI] + public static class SystemTypeExtensions + { + public static FieldInfo GetFieldRecursive(this Type type, string name, BindingFlags bindingFlags) + { + return type.GetFieldsRecursive(bindingFlags).First(x => x.Name == name); + } + + public static IEnumerable GetFieldsRecursive(this Type type, BindingFlags bindingFlags) + { + var fields = type.GetFields(bindingFlags); + if (type.BaseType != default) + { + fields = fields.Concat(type.BaseType.GetFieldsRecursive(bindingFlags)).ToArray(); + } + + return fields; + } + + public static PropertyInfo GetPropertyRecursive(this Type type, string name, BindingFlags bindingFlags) + { + return type.GetPropertiesRecursive(bindingFlags).First(x => x.Name == name); + } + + public static IEnumerable GetPropertiesRecursive(this Type type, BindingFlags bindingFlags) + { + var properties = type.GetProperties(bindingFlags); + if (type.BaseType != default) + { + properties = properties.Concat(type.BaseType.GetPropertiesRecursive(bindingFlags)).ToArray(); + } + + return properties; + } + + public static MethodInfo GetMethodRecursive(this Type type, string name, BindingFlags bindingFlags) + { + return type.GetMethodsRecursive(bindingFlags).First(x => x.Name == name); + } + + public static IEnumerable GetMethodsRecursive(this Type type, BindingFlags bindingFlags) + { + var properties = type.GetMethods(bindingFlags); + if (type.BaseType != default) + { + properties = properties.Concat(type.BaseType.GetMethodsRecursive(bindingFlags)).ToArray(); + } + + return properties; + } + } +} diff --git a/Assets/Scripts/SystemTypeExtensions.cs.meta b/Assets/Scripts/SystemTypeExtensions.cs.meta new file mode 100644 index 0000000..d2c8b38 --- /dev/null +++ b/Assets/Scripts/SystemTypeExtensions.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 737ed94cc1b044638a4758a91f151407 +timeCreated: 1569836956 \ No newline at end of file diff --git a/Assets/Scripts/TimelineSignal.meta b/Assets/Scripts/TimelineSignal.meta new file mode 100644 index 0000000..2406e59 --- /dev/null +++ b/Assets/Scripts/TimelineSignal.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6272980ab42249b09c1c1bba93ef2509 +timeCreated: 1568471721 \ No newline at end of file diff --git a/Assets/Scripts/TimelineSignal/Begin.cs b/Assets/Scripts/TimelineSignal/Begin.cs new file mode 100644 index 0000000..4a6cf60 --- /dev/null +++ b/Assets/Scripts/TimelineSignal/Begin.cs @@ -0,0 +1,6 @@ +namespace UniFlow.TimelineSignal +{ + public class Begin : SignalAssetBase + { + } +} diff --git a/Assets/Scripts/TimelineSignal/Begin.cs.meta b/Assets/Scripts/TimelineSignal/Begin.cs.meta new file mode 100644 index 0000000..522071a --- /dev/null +++ b/Assets/Scripts/TimelineSignal/Begin.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 88a7a553740d46db95f038da46f1f15a +timeCreated: 1568471722 \ No newline at end of file diff --git a/Assets/Scripts/TimelineSignal/End.cs b/Assets/Scripts/TimelineSignal/End.cs new file mode 100644 index 0000000..13992cd --- /dev/null +++ b/Assets/Scripts/TimelineSignal/End.cs @@ -0,0 +1,6 @@ +namespace UniFlow.TimelineSignal +{ + public class End : SignalAssetBase + { + } +} \ No newline at end of file diff --git a/Assets/Scripts/TimelineSignal/End.cs.meta b/Assets/Scripts/TimelineSignal/End.cs.meta new file mode 100644 index 0000000..062cf5d --- /dev/null +++ b/Assets/Scripts/TimelineSignal/End.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 91f1f9f113e1414591950aad2e51469b +timeCreated: 1568471737 \ No newline at end of file diff --git a/Assets/Scripts/TimelineSignal/SignalAssetBase.cs b/Assets/Scripts/TimelineSignal/SignalAssetBase.cs new file mode 100644 index 0000000..d3761ea --- /dev/null +++ b/Assets/Scripts/TimelineSignal/SignalAssetBase.cs @@ -0,0 +1,9 @@ +using UnityEngine.Timeline; + +namespace UniFlow.TimelineSignal +{ + public class SignalAssetBase : SignalAsset + { + public bool IsTemporaryInstance { get; set; } + } +} diff --git a/Assets/Scripts/TimelineSignal/SignalAssetBase.cs.meta b/Assets/Scripts/TimelineSignal/SignalAssetBase.cs.meta new file mode 100644 index 0000000..d7f5297 --- /dev/null +++ b/Assets/Scripts/TimelineSignal/SignalAssetBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0dc41ef1fa1d4f8ca891bbab5329335f +timeCreated: 1568530218 \ No newline at end of file diff --git a/Assets/Scripts/Utility.meta b/Assets/Scripts/Utility.meta new file mode 100644 index 0000000..78416e2 --- /dev/null +++ b/Assets/Scripts/Utility.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f4786649281c490ca2f003e7955f1867 +timeCreated: 1570620920 \ No newline at end of file diff --git a/Assets/Scripts/Utility/ObservableFactory.cs b/Assets/Scripts/Utility/ObservableFactory.cs new file mode 100644 index 0000000..f7892f1 --- /dev/null +++ b/Assets/Scripts/Utility/ObservableFactory.cs @@ -0,0 +1,23 @@ +using System; +using UniRx; + +namespace UniFlow.Utility +{ + public static class ObservableFactory + { + public static IObservable ReturnMessage(IConnector connector) + { + return Observable.Return(connector.CreateMessage()); + } + + public static IObservable ReturnMessage(IConnector connector, string key, T parameter) + { + return Observable.Return(connector.CreateMessage(parameter, key)); + } + + public static IObservable EmptyMessage() + { + return Observable.Empty(); + } + } +} diff --git a/Assets/Scripts/Utility/ObservableFactory.cs.meta b/Assets/Scripts/Utility/ObservableFactory.cs.meta new file mode 100644 index 0000000..46a7715 --- /dev/null +++ b/Assets/Scripts/Utility/ObservableFactory.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 15de220706f24935a2e698029ed26043 +timeCreated: 1571026054 \ No newline at end of file diff --git a/Assets/Scripts/Utility/SignalHandler.cs b/Assets/Scripts/Utility/SignalHandler.cs new file mode 100644 index 0000000..b11b072 --- /dev/null +++ b/Assets/Scripts/Utility/SignalHandler.cs @@ -0,0 +1,51 @@ +using System; +using JetBrains.Annotations; +using UniRx; +using Zenject; + +namespace UniFlow.Utility +{ + public interface ISignalPublisher + { + void Publish(TSignal signal); + } + + public interface ISignalReceiver + { + IObservable OnReceiveAsObservable(); + } + + public interface ISignalHandler : ISignalPublisher, ISignalReceiver + { + } + + [PublicAPI] + public class SignalHandler : ISignalHandler + { + [Inject] private SignalBus SignalBus { get; } + + public void Publish(TSignal signal) + { + SignalBus.Fire(signal); + } + + public IObservable OnReceiveAsObservable() + { +#if ZEN_SIGNALS_ADD_UNIRX + return SignalBus.GetStream(); +#else + var subject = new Subject(); + SignalBus.Subscribe(subject.OnNext); + return subject; +#endif + } + } + + public static class SignalHandlerExtensions + { + public static IObservable OnReceiveAsObservable(this ISignalReceiver signalReceiver, TSignal signal) + { + return signalReceiver.OnReceiveAsObservable().Where(x => Equals(x, signal)); + } + } +} diff --git a/Assets/Scripts/Utility/SignalHandler.cs.meta b/Assets/Scripts/Utility/SignalHandler.cs.meta new file mode 100644 index 0000000..8ef7d8c --- /dev/null +++ b/Assets/Scripts/Utility/SignalHandler.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: b6ee557d0ae944b48d75e41ebfe2aaaf +timeCreated: 1570618810 \ No newline at end of file diff --git a/Assets/Scripts/ValueCollectorBase.cs b/Assets/Scripts/ValueCollectorBase.cs new file mode 100644 index 0000000..c058eeb --- /dev/null +++ b/Assets/Scripts/ValueCollectorBase.cs @@ -0,0 +1,59 @@ +using System; +using UnityEngine; + +namespace UniFlow +{ + [Serializable] + public abstract class ValueCollectorBase : IValueCollector + { + [SerializeField] private ConnectorBase sourceConnector = default; + [SerializeField] private ConnectorBase targetConnector = default; + [SerializeField] private string typeString = default; + [SerializeField] private string composerKey = default; + [SerializeField] private string collectorKey = default; + + public IConnector SourceConnector + { + get => sourceConnector; + set => sourceConnector = value as ConnectorBase; + } + + public IConnector TargetConnector + { + get => targetConnector; + set => targetConnector = value as ConnectorBase; + } + + public string TypeString + { + get => typeString; + set => typeString = value; + } + + public string ComposerKey + { + get => composerKey; + set => composerKey = value; + } + + public string CollectorKey + { + get => collectorKey; + set => collectorKey = value; + } + + public bool CanCollect() + { + return + SourceConnector != null + && TargetConnector?.StreamedMessages != null + && TargetConnector.StreamedMessages.HasMessage(SourceConnector) + && TargetConnector.StreamedMessages.GetMessage(SourceConnector).HasParameter(ComposerKey); + } + + public TValue Collect() + { + return TargetConnector.StreamedMessages.GetMessage(SourceConnector).GetParameter(ComposerKey); + } + } +} diff --git a/Assets/Scripts/ValueCollectorBase.cs.meta b/Assets/Scripts/ValueCollectorBase.cs.meta new file mode 100644 index 0000000..dca7e5c --- /dev/null +++ b/Assets/Scripts/ValueCollectorBase.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 2bad4834c1204e7485f4a3e4adbb7d25 +timeCreated: 1571122097 \ No newline at end of file diff --git a/Assets/Scripts/ValueCollectors.cs b/Assets/Scripts/ValueCollectors.cs new file mode 100644 index 0000000..f63a1a9 --- /dev/null +++ b/Assets/Scripts/ValueCollectors.cs @@ -0,0 +1,274 @@ +using System; +using UniRx; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.Playables; +using UnityEngine.Timeline; +using UnityEngine.UI; +using Object = UnityEngine.Object; + +namespace UniFlow +{ +#region primitives + + [Serializable] + public class BoolCollector : ValueCollectorBase + { + } + + [Serializable] + public class ByteCollector : ValueCollectorBase + { + } + + [Serializable] + public class IntCollector : ValueCollectorBase + { + } + + [Serializable] + public class FloatCollector : ValueCollectorBase + { + } + + [Serializable] + public class StringCollector : ValueCollectorBase + { + } + +#endregion + +#region UnityEngine.Object + + [Serializable] + public class ObjectCollector : ValueCollectorBase + { + } + + [Serializable] + public class GameObjectCollector : ValueCollectorBase + { + } + + [Serializable] + public class ScriptableObjectCollector : ValueCollectorBase + { + } + +#endregion + +#region assets + + [Serializable] + public class TextureCollector : ValueCollectorBase + { + } + + [Serializable] + public class Texture2DCollector : ValueCollectorBase + { + } + + [Serializable] + public class Texture3DCollector : ValueCollectorBase + { + } + + [Serializable] + public class SpriteCollector : ValueCollectorBase + { + } + + [Serializable] + public class AnimationClipCollector : ValueCollectorBase + { + } + + [Serializable] + public class AudioClipCollector : ValueCollectorBase + { + } + + [Serializable] + public class TimelineAssetCollector : ValueCollectorBase + { + } + +#endregion + +#region components + + [Serializable] + public class ComponentCollector : ValueCollectorBase + { + } + + [Serializable] + public class BehaviourCollector : ValueCollectorBase + { + } + + [Serializable] + public class MonoBehaviourCollector : ValueCollectorBase + { + } + + [Serializable] + public class UIBehaviourCollector : ValueCollectorBase + { + } + + [Serializable] + public class TransformCollector : ValueCollectorBase + { + } + + [Serializable] + public class RectTransformCollector : ValueCollectorBase + { + } + + [Serializable] + public class AnimatorCollector : ValueCollectorBase + { + } + + [Serializable] + public class SimpleAnimationCollector : ValueCollectorBase + { + } + + [Serializable] + public class AudioSourceCollector : ValueCollectorBase + { + } + + [Serializable] + public class PlayableDirectorCollector : ValueCollectorBase + { + } + + [Serializable] + public class ImageCollector : ValueCollectorBase + { + } + + [Serializable] + public class RawImageCollector : ValueCollectorBase + { + } + +#endregion + +#region structs + + [Serializable] + public class Vector2Collector : ValueCollectorBase + { + } + + [Serializable] + public class Vector3Collector : ValueCollectorBase + { + } + + [Serializable] + public class Vector4Collector : ValueCollectorBase + { + } + + [Serializable] + public class QuaternionCollector : ValueCollectorBase + { + } + + [Serializable] + public class Vector2IntCollector : ValueCollectorBase + { + } + + [Serializable] + public class Vector3IntCollector : ValueCollectorBase + { + } + + [Serializable] + public class ColorCollector : ValueCollectorBase + { + } + + [Serializable] + public class Color32Collector : ValueCollectorBase + { + } + +#endregion + +#region classes + + [Serializable] + public class AnimationEventCollector : ValueCollectorBase + { + } + +#endregion + +#region enums + + // If you can register a method that casts from int to enum, this region is unnecessary. + + [Serializable] + public class AnimatorCullingModeCollector : ValueCollectorBase + { + } + + [Serializable] + public class AnimatorUpdateModeCollector : ValueCollectorBase + { + } + + [Serializable] + public class ObservableTweenEaseTypeCollector : ValueCollectorBase + { + } + + [Serializable] + public class RuntimePlatformCollector : ValueCollectorBase + { + } + + [Serializable] + public class EaseTypeCollector : ValueCollectorBase + { + } + +#endregion + +#region EventData + + [Serializable] + public class PointerEventDataCollector : ValueCollectorBase + { + } + + [Serializable] + public class BaseEventDataCollector : ValueCollectorBase + { + } + +#endregion + +#region IObservable + + [Serializable] + public class IntObservableCollector : ValueCollectorBase> + { + } + + [Serializable] + public class FloatObservableCollector : ValueCollectorBase> + { + } + +#endregion +} diff --git a/Assets/Scripts/ValueCollectors.cs.meta b/Assets/Scripts/ValueCollectors.cs.meta new file mode 100644 index 0000000..dbe1a44 --- /dev/null +++ b/Assets/Scripts/ValueCollectors.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8810904243b34aacb59d4d05c075ba26 +timeCreated: 1571147303 \ No newline at end of file diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationController.meta b/Assets/Tests/Runtime/Animations/SimpleAnimationController.meta new file mode 100644 index 0000000..fbba3db --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationController.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88b8fc193da314090bf2138f19c68560 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim b/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim new file mode 100644 index 0000000..ec3d254 --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim @@ -0,0 +1,169 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Test + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 1 + value: {x: 1, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 1 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.x + path: + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.y + path: + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.z + path: + classID: 4 + script: {fileID: 0} + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 1 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim.meta b/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim.meta new file mode 100644 index 0000000..4560656 --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationController/Test.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef5cc875a54684b7abeeefd4f24107da +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationEvent.meta b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent.meta new file mode 100644 index 0000000..82ab633 --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ea8566f191ced47feae23d2217a2c7f5 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim new file mode 100644 index 0000000..ec3d254 --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim @@ -0,0 +1,169 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: Test + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: {x: 0, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + - serializedVersion: 3 + time: 1 + value: {x: 1, y: 0, z: 0} + inSlope: {x: 0, y: 0, z: 0} + outSlope: {x: 0, y: 0, z: 0} + tangentMode: 0 + weightedMode: 0 + inWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + outWeight: {x: 0.33333334, y: 0.33333334, z: 0.33333334} + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + path: + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - serializedVersion: 2 + path: 0 + attribute: 1 + script: {fileID: 0} + typeID: 4 + customType: 0 + isPPtrCurve: 0 + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 0 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.x + path: + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.y + path: + classID: 4 + script: {fileID: 0} + - curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 136 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attribute: m_LocalPosition.z + path: + classID: 4 + script: {fileID: 0} + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 1 + m_HasMotionFloatCurves: 0 + m_Events: [] diff --git a/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim.meta b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim.meta new file mode 100644 index 0000000..22a82f7 --- /dev/null +++ b/Assets/Tests/Runtime/Animations/SimpleAnimationEvent/Test.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d93891a464f724b6392131e974182905 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 7400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Scenes/Basic/All.unity b/Assets/Tests/Runtime/Scenes/Basic/All.unity index 9d34da5..0a4ebcb 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/All.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/All.unity @@ -310,10 +310,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c4c15fc42dc5482199932c4a3305f962, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 1100, y: 50} + targetComponents: - {fileID: 2024507135} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 + playableControlMethod: 0 + timelineAsset: {fileID: 0} playableDirector: {fileID: 2024507138} --- !u!4 &578503983 Transform: @@ -459,9 +462,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 986c65454dfa4cf6a69ff9328f793990, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 50, y: 50} + targetComponents: - {fileID: 1565437862} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 eventTriggerType: 2 uiBehaviour: {fileID: 0} @@ -631,9 +635,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 13ea2beab68d4b9695c5913d711525ca, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 400, y: 50} + targetComponents: - {fileID: 1729537389} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 animator: {fileID: 1729537390} triggerName: TestTrigger @@ -681,10 +686,16 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 79d730e2e15e4d688fab6e1a6d9f5e56, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 750, y: 50} + targetComponents: - {fileID: 578503981} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 + animationClip: {fileID: 0} + cullingMode: 0 + updateMode: 0 + animator: {fileID: 0} + simpleAnimation: {fileID: 0} --- !u!95 &1729537390 Animator: serializedVersion: 3 @@ -750,9 +761,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7897bf78af8d443e83a6786b2e4fdfda, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 1450, y: 50} + targetComponents: - {fileID: 2070612652} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &2024507136 MonoBehaviour: @@ -852,9 +864,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] - actAsTrigger: 0 + flowGraphNodePosition: {x: 1800, y: 50} --- !u!4 &2070612653 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Tests/Runtime/Scenes/Basic/AnimationEvent.unity b/Assets/Tests/Runtime/Scenes/Basic/AnimationEvent.unity index 34b686d..a9afa0f 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/AnimationEvent.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/AnimationEvent.unity @@ -312,9 +312,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 79d730e2e15e4d688fab6e1a6d9f5e56, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1565437861} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 --- !u!95 &1565437859 Animator: @@ -361,8 +361,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!1 &2126485662 GameObject: diff --git a/Assets/Tests/Runtime/Scenes/Basic/AnimatorTrigger.unity b/Assets/Tests/Runtime/Scenes/Basic/AnimatorTrigger.unity index 15caac7..78aa4cf 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/AnimatorTrigger.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/AnimatorTrigger.unity @@ -313,9 +313,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 79d730e2e15e4d688fab6e1a6d9f5e56, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1565437861} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 --- !u!95 &1565437859 Animator: @@ -362,8 +362,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &1565437862 MonoBehaviour: @@ -377,9 +377,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 13ea2beab68d4b9695c5913d711525ca, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1565437858} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 animator: {fileID: 0} triggerName: TestTrigger diff --git a/Assets/Tests/Runtime/Scenes/Basic/AudioController.unity b/Assets/Tests/Runtime/Scenes/Basic/AudioController.unity index 4bf70b7..2b545da 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/AudioController.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/AudioController.unity @@ -222,8 +222,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &237918682 MonoBehaviour: @@ -237,9 +237,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 306f3948478b4806bd3270ce91a0c068, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 237918681} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 audioControlMethod: 0 audioSource: {fileID: 0} @@ -365,9 +365,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 237918682} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 seconds: 1 --- !u!1 &451877066 @@ -493,8 +493,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &709479484 MonoBehaviour: @@ -508,9 +508,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 306f3948478b4806bd3270ce91a0c068, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 709479483} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 audioControlMethod: 3 audioSource: {fileID: 0} @@ -636,9 +636,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 709479484} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 seconds: 1 --- !u!1 &1379110442 @@ -673,8 +673,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &1379110444 MonoBehaviour: @@ -688,9 +688,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 306f3948478b4806bd3270ce91a0c068, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1379110443} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 audioControlMethod: 1 audioSource: {fileID: 0} @@ -816,9 +816,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1379110444} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 seconds: 1 --- !u!1 &1766242780 @@ -853,8 +853,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &1766242782 MonoBehaviour: @@ -868,9 +868,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 306f3948478b4806bd3270ce91a0c068, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1766242781} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 audioControlMethod: 2 audioSource: {fileID: 0} @@ -996,9 +996,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1766242782} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 seconds: 1 --- !u!1 &2126485662 diff --git a/Assets/Tests/Runtime/Scenes/Basic/AudioEvent.unity b/Assets/Tests/Runtime/Scenes/Basic/AudioEvent.unity index efafaa4..351c751 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/AudioEvent.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/AudioEvent.unity @@ -156,23 +156,15 @@ MonoBehaviour: OnPreInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPreResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null _parentNewObjectsUnderSceneContext: 0 _contractNames: [] _parentContractNames: [] @@ -221,9 +213,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 674} --- !u!114 &169312998 MonoBehaviour: m_ObjectHideFlags: 0 @@ -236,11 +229,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 169312997} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 1138} audioEventType: 4 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &169312999 AudioSource: @@ -383,9 +378,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} --- !u!114 &237918682 MonoBehaviour: m_ObjectHideFlags: 0 @@ -398,11 +394,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 237918681} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} audioEventType: 0 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &237918683 AudioSource: @@ -545,9 +543,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 986} --- !u!114 &424226963 MonoBehaviour: m_ObjectHideFlags: 0 @@ -560,11 +559,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 424226962} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 1682} audioEventType: 1 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &424226964 AudioSource: @@ -710,9 +711,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 1450, y: 50} --- !u!114 &444551915 MonoBehaviour: m_ObjectHideFlags: 0 @@ -725,11 +727,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 444551914} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 1100, y: 50} audioEventType: 1 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!114 &444551916 MonoBehaviour: @@ -743,11 +747,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 444551915} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 750, y: 50} audioEventType: 3 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!114 &444551917 MonoBehaviour: @@ -761,11 +767,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 444551916} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 1142} audioEventType: 2 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!114 &444551918 MonoBehaviour: @@ -779,11 +787,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 444551917} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 1954} audioEventType: 0 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &444551919 AudioSource: @@ -1017,9 +1027,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 518} --- !u!114 &709479484 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1032,11 +1043,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 709479483} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 866} audioEventType: 3 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &709479485 AudioSource: @@ -1179,9 +1192,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 830} --- !u!114 &1130731398 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1194,11 +1208,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1130731397} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 1410} audioEventType: 0 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &1130731399 AudioSource: @@ -1341,9 +1357,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 206} --- !u!114 &1379110444 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1356,11 +1373,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1379110443} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 322} audioEventType: 1 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &1379110445 AudioSource: @@ -1503,9 +1522,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 362} --- !u!114 &1766242782 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1518,11 +1538,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5123bd7d9f1949adbf43f3b8391a5ebd, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1766242781} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 594} audioEventType: 2 + audioClip: {fileID: 0} audioSource: {fileID: 0} --- !u!82 &1766242783 AudioSource: diff --git a/Assets/Tests/Runtime/Scenes/Basic/CameraEvent.unity b/Assets/Tests/Runtime/Scenes/Basic/CameraEvent.unity index 0bafa94..7b3aa93 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/CameraEvent.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/CameraEvent.unity @@ -156,23 +156,15 @@ MonoBehaviour: OnPreInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPreResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null _parentNewObjectsUnderSceneContext: 0 _contractNames: [] _parentContractNames: [] @@ -387,9 +379,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} --- !u!114 &923815578 MonoBehaviour: m_ObjectHideFlags: 0 @@ -402,10 +395,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2a133b3a9e6a4868ae2e11afff21cc6e, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 923815577} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} cameraEventType: 0 component: {fileID: 0} --- !u!1 &1761951864 @@ -441,9 +435,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 206} --- !u!114 &1761951866 MonoBehaviour: m_ObjectHideFlags: 0 @@ -456,10 +451,11 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2a133b3a9e6a4868ae2e11afff21cc6e, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1761951865} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 280} cameraEventType: 1 component: {fileID: 0} --- !u!65 &1761951868 diff --git a/Assets/Tests/Runtime/Scenes/Basic/Interval.unity b/Assets/Tests/Runtime/Scenes/Basic/Interval.unity index e1e013d..0f5978b 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/Interval.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/Interval.unity @@ -156,23 +156,15 @@ MonoBehaviour: OnPreInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostInstall: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPreResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null OnPostResolve: m_PersistentCalls: m_Calls: [] - m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, - Culture=neutral, PublicKeyToken=null _parentNewObjectsUnderSceneContext: 0 _contractNames: [] _parentContractNames: [] @@ -311,6 +303,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} --- !u!114 &1929524894 MonoBehaviour: m_ObjectHideFlags: 0 @@ -323,11 +319,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c75b5631c1dd457ca629666003c656b9, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1929524893} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} seconds: 1 + ignoreTimeScale: 0 --- !u!4 &1929524895 Transform: m_ObjectHideFlags: 0 diff --git a/Assets/Tests/Runtime/Scenes/Basic/LifecycleEvent.unity b/Assets/Tests/Runtime/Scenes/Basic/LifecycleEvent.unity index d78d292..1f8c62b 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/LifecycleEvent.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/LifecycleEvent.unity @@ -149,9 +149,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 3 component: {fileID: 0} @@ -268,9 +268,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 2 component: {fileID: 0} @@ -317,9 +317,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 5 component: {fileID: 0} @@ -366,9 +366,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 4 component: {fileID: 0} @@ -506,9 +506,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 6 component: {fileID: 0} @@ -555,9 +555,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 0 component: {fileID: 0} @@ -604,9 +604,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 85a0f26910644eac9392a5b944f82349, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 2041475155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 lifecycleEventType: 1 component: {fileID: 0} @@ -653,8 +653,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!4 &2041475156 Transform: diff --git a/Assets/Tests/Runtime/Scenes/Basic/PlayableController.unity b/Assets/Tests/Runtime/Scenes/Basic/PlayableController.unity index ba5a8a9..c7ccd35 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/PlayableController.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/PlayableController.unity @@ -315,9 +315,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7897bf78af8d443e83a6786b2e4fdfda, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 400, y: 50} + targetComponents: - {fileID: 951080161} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 0 --- !u!114 &951080156 MonoBehaviour: @@ -418,10 +419,13 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: c4c15fc42dc5482199932c4a3305f962, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + flowGraphNodePosition: {x: 50, y: 50} + targetComponents: - {fileID: 951080155} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 + playableControlMethod: 0 + timelineAsset: {fileID: 0} playableDirector: {fileID: 0} --- !u!114 &951080161 MonoBehaviour: @@ -435,9 +439,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] - actAsTrigger: 0 + flowGraphNodePosition: {x: 750, y: 50} --- !u!1 &2126485662 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity new file mode 100644 index 0000000..eb5d34d --- /dev/null +++ b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity @@ -0,0 +1,647 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &50763314 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 50763316} + - component: {fileID: 50763315} + m_Layer: 0 + m_Name: SceneContext + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &50763315 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50763314} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89715ad69b973a14899afa2c6730b30b, type: 3} + m_Name: + m_EditorClassIdentifier: + _scriptableObjectInstallers: [] + _monoInstallers: [] + _installerPrefabs: [] + _autoRun: 1 + OnPreInstall: + m_PersistentCalls: + m_Calls: [] + OnPostInstall: + m_PersistentCalls: + m_Calls: [] + OnPreResolve: + m_PersistentCalls: + m_Calls: [] + OnPostResolve: + m_PersistentCalls: + m_Calls: [] + _parentNewObjectsUnderSceneContext: 0 + _contractNames: [] + _parentContractNames: [] +--- !u!4 &50763316 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50763314} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &451877066 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 451877068} + - component: {fileID: 451877067} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &451877067 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 451877066} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &451877068 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 451877066} + m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0} +--- !u!1 &757789963 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 757789969} + - component: {fileID: 757789968} + - component: {fileID: 757789967} + - component: {fileID: 757789966} + - component: {fileID: 757789965} + - component: {fileID: 757789964} + m_Layer: 0 + m_Name: Stop + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &757789964 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e354102254874aecbac12539fc4505b3, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 757789967} + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 750, y: 50} + simpleAnimationControlMethod: 1 + animationClip: {fileID: 7400000, guid: ef5cc875a54684b7abeeefd4f24107da, type: 2} + cullingMode: 0 + updateMode: 0 + baseGameObject: {fileID: 0} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!114 &757789965 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 757789964} + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} + seconds: 0.5 + ignoreTimeScale: 0 +--- !u!212 &757789966 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &757789967 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 1100, y: 50} +--- !u!114 &757789968 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e354102254874aecbac12539fc4505b3, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 757789965} + targetIds: [] + actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} + simpleAnimationControlMethod: 0 + animationClip: {fileID: 7400000, guid: ef5cc875a54684b7abeeefd4f24107da, type: 2} + cullingMode: 0 + updateMode: 0 + baseGameObject: {fileID: 0} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!4 &757789969 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 757789963} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &984367005 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 984367009} + - component: {fileID: 984367008} + - component: {fileID: 984367007} + - component: {fileID: 984367006} + m_Layer: 0 + m_Name: Play + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!212 &984367006 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 984367005} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!114 &984367007 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 984367005} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} +--- !u!114 &984367008 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 984367005} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e354102254874aecbac12539fc4505b3, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 984367007} + targetIds: [] + actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} + simpleAnimationControlMethod: 0 + animationClip: {fileID: 7400000, guid: ef5cc875a54684b7abeeefd4f24107da, type: 2} + cullingMode: 0 + updateMode: 0 + baseGameObject: {fileID: 0} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!4 &984367009 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 984367005} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2126485662 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2126485665} + - component: {fileID: 2126485664} + - component: {fileID: 2126485663} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &2126485663 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_Enabled: 1 +--- !u!20 &2126485664 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 1 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2126485665 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity.meta b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity.meta new file mode 100644 index 0000000..10539f8 --- /dev/null +++ b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6977b8f896215433887311c3be8b846e +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity new file mode 100644 index 0000000..4ff0561 --- /dev/null +++ b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity @@ -0,0 +1,646 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 1 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &50763314 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 50763316} + - component: {fileID: 50763315} + m_Layer: 0 + m_Name: SceneContext + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &50763315 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50763314} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89715ad69b973a14899afa2c6730b30b, type: 3} + m_Name: + m_EditorClassIdentifier: + _scriptableObjectInstallers: [] + _monoInstallers: [] + _installerPrefabs: [] + _autoRun: 1 + OnPreInstall: + m_PersistentCalls: + m_Calls: [] + OnPostInstall: + m_PersistentCalls: + m_Calls: [] + OnPreResolve: + m_PersistentCalls: + m_Calls: [] + OnPostResolve: + m_PersistentCalls: + m_Calls: [] + _parentNewObjectsUnderSceneContext: 0 + _contractNames: [] + _parentContractNames: [] +--- !u!4 &50763316 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 50763314} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &451877066 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 451877068} + - component: {fileID: 451877067} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &451877067 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 451877066} + m_Enabled: 1 + serializedVersion: 9 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &451877068 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 451877066} + m_LocalRotation: {x: 0.38268343, y: 0, z: 0, w: 0.92387956} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 45, y: 0, z: 0} +--- !u!1 &1200034642 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1200034646} + - component: {fileID: 1200034645} + - component: {fileID: 1200034644} + - component: {fileID: 1200034643} + - component: {fileID: 1200034647} + m_Layer: 0 + m_Name: Stop + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &1200034643 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1200034642} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 750, y: 50} +--- !u!114 &1200034644 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1200034642} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6fc6fac5bf554d4da6db3c2feda04ca8, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 1200034643} + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} + simpleAnimationEventType: 1 + animationClip: {fileID: 7400000, guid: d93891a464f724b6392131e974182905, type: 2} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!114 &1200034645 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1200034642} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e354102254874aecbac12539fc4505b3, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 1200034644} + targetIds: [] + actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} + simpleAnimationControlMethod: 0 + animationClip: {fileID: 7400000, guid: d93891a464f724b6392131e974182905, type: 2} + cullingMode: 0 + updateMode: 0 + baseGameObject: {fileID: 0} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!4 &1200034646 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1200034642} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1200034647 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1200034642} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!1 &1914031420 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1914031424} + - component: {fileID: 1914031423} + - component: {fileID: 1914031422} + - component: {fileID: 1914031421} + - component: {fileID: 1914031425} + m_Layer: 0 + m_Name: Play + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &1914031421 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1914031420} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: [] + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 750, y: 50} +--- !u!114 &1914031422 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1914031420} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6fc6fac5bf554d4da6db3c2feda04ca8, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 1914031421} + targetIds: [] + actAsTrigger: 0 + flowGraphNodePosition: {x: 400, y: 50} + simpleAnimationEventType: 0 + animationClip: {fileID: 7400000, guid: d93891a464f724b6392131e974182905, type: 2} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!114 &1914031423 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1914031420} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e354102254874aecbac12539fc4505b3, type: 3} + m_Name: + m_EditorClassIdentifier: + targetComponents: + - {fileID: 1914031422} + targetIds: [] + actAsTrigger: 1 + flowGraphNodePosition: {x: 50, y: 50} + simpleAnimationControlMethod: 0 + animationClip: {fileID: 7400000, guid: d93891a464f724b6392131e974182905, type: 2} + cullingMode: 0 + updateMode: 0 + baseGameObject: {fileID: 0} + animator: {fileID: 0} + simpleAnimation: {fileID: 0} +--- !u!4 &1914031424 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1914031420} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &1914031425 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1914031420} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!1 &2126485662 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2126485665} + - component: {fileID: 2126485664} + - component: {fileID: 2126485663} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &2126485663 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_Enabled: 1 +--- !u!20 &2126485664 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 1 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &2126485665 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2126485662} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity.meta b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity.meta new file mode 100644 index 0000000..74ccd5a --- /dev/null +++ b/Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c4ecb70dbd61f493a8b69cfeaf14d49d +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Tests/Runtime/Scenes/Basic/TimelineSignal.unity b/Assets/Tests/Runtime/Scenes/Basic/TimelineSignal.unity index 9c9aa20..48f5ed8 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/TimelineSignal.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/TimelineSignal.unity @@ -314,9 +314,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 7897bf78af8d443e83a6786b2e4fdfda, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 951080160} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 --- !u!114 &951080156 MonoBehaviour: @@ -415,8 +415,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!1 &2126485662 GameObject: diff --git a/Assets/Tests/Runtime/Scenes/Basic/Timer.unity b/Assets/Tests/Runtime/Scenes/Basic/Timer.unity index 214fb7a..efe7eb7 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/Timer.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/Timer.unity @@ -323,9 +323,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 5c68da8d20a7460881ef721586f08251, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 1929524893} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 seconds: 1 --- !u!4 &1929524895 diff --git a/Assets/Tests/Runtime/Scenes/Basic/UIBehaviourEventTrigger.unity b/Assets/Tests/Runtime/Scenes/Basic/UIBehaviourEventTrigger.unity index f6f97bf..74b3347 100644 --- a/Assets/Tests/Runtime/Scenes/Basic/UIBehaviourEventTrigger.unity +++ b/Assets/Tests/Runtime/Scenes/Basic/UIBehaviourEventTrigger.unity @@ -431,9 +431,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 986c65454dfa4cf6a69ff9328f793990, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: + targetComponents: - {fileID: 751339852} - targetConnectorIds: [] + targetIds: [] actAsTrigger: 1 eventTriggerType: 4 uiBehaviour: {fileID: 0} @@ -487,8 +487,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 74f05c1452df4e608e510b8e0954c294, type: 3} m_Name: m_EditorClassIdentifier: - targetConnectorInstances: [] - targetConnectorIds: [] + targetComponents: [] + targetIds: [] actAsTrigger: 0 --- !u!1 &1538909814 GameObject: diff --git a/Assets/Tests/Runtime/Scripts/AllTest.cs b/Assets/Tests/Runtime/Scripts/AllTest.cs index e429b80..b96c066 100644 --- a/Assets/Tests/Runtime/Scripts/AllTest.cs +++ b/Assets/Tests/Runtime/Scripts/AllTest.cs @@ -1,19 +1,20 @@ using System.Collections; -using EventConnector; -using EventConnector.Connector; -using EventConnector.Message; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; +using UniFlow.Connector.Controller; +using UniFlow.Connector.Event; using UniRx.Triggers; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Playables; using UnityEngine.TestTools; using UnityEngine.UI; -using AnimationEvent = EventConnector.Connector.AnimationEvent; +using AnimationEvent = UniFlow.Connector.Event.AnimationEvent; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class AllTest : EventConnectorTestBase + public class AllTest : UniFlowTestBase { [UnityTest] public IEnumerator All() @@ -46,35 +47,41 @@ public IEnumerator Multiple() ); } - private void AssertAll(EventMessages eventMessages) + private void AssertAll(IEnumerable sentConnectors) { - Assert.AreEqual(5, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(6, connectors.Count); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + { + var connector = connectors[0] as UIBehaviourEventTrigger; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.UIBehaviour); + } - Assert.IsInstanceOf(eventMessages[1].Sender); - Assert.IsInstanceOf(eventMessages[1].EventData); + { + var connector = connectors[1] as AnimatorTrigger; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.Animator); + } - Assert.IsInstanceOf(eventMessages[2].Sender); - Assert.IsInstanceOf(eventMessages[2].EventData); - var animationEvent = eventMessages[2].EventData as UnityEngine.AnimationEvent; - Assert.NotNull(animationEvent); - Assert.AreEqual(222.2f, animationEvent.floatParameter); - Assert.AreEqual(333, animationEvent.intParameter); - Assert.AreEqual("444", animationEvent.stringParameter); - Assert.IsInstanceOf(animationEvent.objectReferenceParameter); - Assert.AreEqual("All", animationEvent.objectReferenceParameter.name); + { + var connector = connectors[2] as AnimationEvent; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.Animator); + } - Assert.IsInstanceOf(eventMessages[3].Sender); - Assert.IsInstanceOf(eventMessages[3].EventData); + { + var connector = connectors[3] as PlayableController; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.PlayableDirector); + } + + { + var connector = connectors[4] as Connector.Event.TimelineSignal; + Assert.NotNull(connector); + } - Assert.IsInstanceOf(eventMessages[4].Sender); - Assert.IsInstanceOf(eventMessages[4].EventData); - var timelineEvent = eventMessages[4].EventData as TimelineEventData; - Assert.NotNull(timelineEvent); - Assert.AreEqual(999, timelineEvent.IntParameter); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/AnimationEventTest.cs b/Assets/Tests/Runtime/Scripts/AnimationEventTest.cs index 7122622..9f20004 100644 --- a/Assets/Tests/Runtime/Scripts/AnimationEventTest.cs +++ b/Assets/Tests/Runtime/Scripts/AnimationEventTest.cs @@ -1,12 +1,13 @@ using System.Collections; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; -using UnityEngine; +using UniFlow.Connector.Event; using UnityEngine.TestTools; -using AnimationEvent = EventConnector.Connector.AnimationEvent; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class AnimationEventTest : EventConnectorTestBase + public class AnimationEventTest : UniFlowTestBase { [UnityTest] public IEnumerator AnimationEvent() @@ -20,20 +21,15 @@ public IEnumerator AnimationEvent() ); } - private void AssertAnimationEvent(EventMessages eventMessages) + private void AssertAnimationEvent(IEnumerable sentConnectors) { - Assert.AreEqual(1, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(2, connectors.Count); + + var connector = connectors[0] as AnimationEvent; + Assert.NotNull(connector); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - var animationEvent = eventMessages[0].EventData as UnityEngine.AnimationEvent; - Assert.NotNull(animationEvent); - Assert.AreEqual(11.1f, animationEvent.floatParameter); - Assert.AreEqual(22, animationEvent.intParameter); - Assert.AreEqual("33", animationEvent.stringParameter); - Assert.IsInstanceOf(animationEvent.objectReferenceParameter); - Assert.AreEqual("AnimationEvent", animationEvent.objectReferenceParameter.name); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/AnimatorTriggerTest.cs b/Assets/Tests/Runtime/Scripts/AnimatorTriggerTest.cs index d0ebafe..6d2af36 100644 --- a/Assets/Tests/Runtime/Scripts/AnimatorTriggerTest.cs +++ b/Assets/Tests/Runtime/Scripts/AnimatorTriggerTest.cs @@ -1,13 +1,13 @@ using System.Collections; -using EventConnector.Message; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; -using UnityEngine; +using UniFlow.Connector.Controller; using UnityEngine.TestTools; -using AnimationEvent = EventConnector.Connector.AnimationEvent; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class AnimatorTriggerTest : EventConnectorTestBase + public class AnimatorTriggerTest : UniFlowTestBase { [UnityTest] public IEnumerator AnimatorTrigger() @@ -21,23 +21,15 @@ public IEnumerator AnimatorTrigger() ); } - private void AssertAnimatorTrigger(EventMessages eventMessages) + private void AssertAnimatorTrigger(IEnumerable sentConnectors) { - Assert.AreEqual(2, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(3, connectors.Count); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + var connector = connectors[0] as AnimatorTrigger; + Assert.NotNull(connector); - Assert.IsInstanceOf(eventMessages[1].Sender); - Assert.IsInstanceOf(eventMessages[1].EventData); - var animationEvent = eventMessages[1].EventData as UnityEngine.AnimationEvent; - Assert.NotNull(animationEvent); - Assert.AreEqual(22.2f, animationEvent.floatParameter); - Assert.AreEqual(33, animationEvent.intParameter); - Assert.AreEqual("44", animationEvent.stringParameter); - Assert.IsInstanceOf(animationEvent.objectReferenceParameter); - Assert.AreEqual("AnimatorTrigger", animationEvent.objectReferenceParameter.name); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/AudioControllerTest.cs b/Assets/Tests/Runtime/Scripts/AudioControllerTest.cs index 43e5141..ee6682d 100644 --- a/Assets/Tests/Runtime/Scripts/AudioControllerTest.cs +++ b/Assets/Tests/Runtime/Scripts/AudioControllerTest.cs @@ -1,17 +1,17 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; -using EventConnector.Connector; -using EventConnector.Message; using NUnit.Framework; +using UniFlow.Connector.Controller; using UniRx; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class AudioControllerTest : EventConnectorTestBase + public class AudioControllerTest : UniFlowTestBase { [UnityTest] public IEnumerator Play() @@ -21,7 +21,6 @@ public IEnumerator Play() "AudioController", em => AssertAudioEvent( em, - AudioControlMethod.Play, audioSource => { Assert.True(audioSource.isPlaying); @@ -49,7 +48,6 @@ public IEnumerator Stop() "AudioController", em => AssertAudioEvent( em, - AudioControlMethod.Stop, audioSource => { Assert.False(audioSource.isPlaying); @@ -79,7 +77,6 @@ public IEnumerator Pause() "AudioController", em => AssertAudioEvent( em, - AudioControlMethod.Pause, audioSource => { Assert.False(audioSource.isPlaying); @@ -109,7 +106,6 @@ public IEnumerator UnPause() "AudioController", em => AssertAudioEvent( em, - AudioControlMethod.UnPause, audioSource => { Assert.True(audioSource.isPlaying); @@ -132,21 +128,19 @@ public IEnumerator UnPause() ); } - private void AssertAudioEvent(EventMessages eventMessages, AudioControlMethod audioControlMethod, Action callback) + private void AssertAudioEvent(IEnumerable sentConnectors, Action callback) { - Assert.NotNull(eventMessages); - Assert.AreEqual(2, eventMessages.Count); + var connectors = sentConnectors.ToList(); - Assert.IsInstanceOf(eventMessages[1].Sender); - Assert.IsInstanceOf(eventMessages[1].EventData); + Assert.NotNull(connectors); + Assert.AreEqual(3, connectors.Count); - Assert.NotNull(eventMessages[1].EventData); + var connector = connectors[1] as AudioController; + Assert.NotNull(connector); - Assert.AreEqual(audioControlMethod, ((AudioControllerEventData) eventMessages[1].EventData).AudioControlMethod); - - callback(eventMessages[1].Sender as AudioSource); + callback(connector.AudioSource); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/AudioEventTest.cs b/Assets/Tests/Runtime/Scripts/AudioEventTest.cs index 9d4a9cb..d6dc124 100644 --- a/Assets/Tests/Runtime/Scripts/AudioEventTest.cs +++ b/Assets/Tests/Runtime/Scripts/AudioEventTest.cs @@ -1,18 +1,18 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; -using EventConnector.Connector; -using EventConnector.Message; using NUnit.Framework; +using UniFlow.Connector.Event; using UniRx; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; using Object = UnityEngine.Object; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class AudioEventTest : EventConnectorTestBase + public class AudioEventTest : UniFlowTestBase { [UnityTest] public IEnumerator PlayEvent() @@ -178,14 +178,15 @@ public IEnumerator ComplexEvent() yield return RunAssert( "AudioEvent", - em => + sentConnectors => { - Assert.NotNull(em); - Assert.AreEqual(4, em.Count); - Assert.AreEqual(AudioEventType.Play, ((AudioEventData) em[0].EventData).EventType); - Assert.AreEqual(AudioEventType.Pause, ((AudioEventData) em[1].EventData).EventType); - Assert.AreEqual(AudioEventType.UnPause, ((AudioEventData) em[2].EventData).EventType); - Assert.AreEqual(AudioEventType.Stop, ((AudioEventData) em[3].EventData).EventType); + var connectors = sentConnectors.ToList(); + Assert.NotNull(sentConnectors); + Assert.AreEqual(5, connectors.Count); + Assert.AreEqual(AudioEventType.Play, (connectors[0] as AudioEvent)?.AudioEventType); + Assert.AreEqual(AudioEventType.Pause, (connectors[1] as AudioEvent)?.AudioEventType); + Assert.AreEqual(AudioEventType.UnPause, (connectors[2] as AudioEvent)?.AudioEventType); + Assert.AreEqual(AudioEventType.Stop, (connectors[3] as AudioEvent)?.AudioEventType); HasAssert = true; }, () => @@ -205,20 +206,20 @@ public IEnumerator ComplexEvent() ); } - private void AssertAudioEvent(EventMessages eventMessages, AudioEventType audioEventType, int receiveCount = 1) + private void AssertAudioEvent(IEnumerable sentConnectors, AudioEventType audioEventType, int receiveCount = 1) { - Assert.NotNull(eventMessages); - Assert.AreEqual(1, eventMessages.Count); - Assert.AreEqual(receiveCount, Object.FindObjectOfType().ReceiveCount); - - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + var connectors = sentConnectors.ToList(); - Assert.NotNull(eventMessages[0].EventData); + Assert.NotNull(connectors); + Assert.AreEqual(2 * receiveCount, connectors.Count); + Assert.AreEqual(receiveCount, Object.FindObjectOfType().ReceiveCount); - Assert.AreEqual(audioEventType, ((AudioEventData) eventMessages[0].EventData).EventType); + var connector = connectors[0] as AudioEvent; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.AudioSource); + Assert.AreEqual(audioEventType, connector.AudioEventType); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/CameraEventTest.cs b/Assets/Tests/Runtime/Scripts/CameraEventTest.cs index e4f7b84..e3ca73b 100644 --- a/Assets/Tests/Runtime/Scripts/CameraEventTest.cs +++ b/Assets/Tests/Runtime/Scripts/CameraEventTest.cs @@ -1,17 +1,17 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; -using EventConnector.Connector; -using EventConnector.Message; using NUnit.Framework; +using UniFlow.Connector.Event; using UniRx; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class CameraEventTest : EventConnectorTestBase + public class CameraEventTest : UniFlowTestBase { [UnityTest] public IEnumerator CameraBecomeVisibleEvent() @@ -55,34 +55,32 @@ public IEnumerator CameraBecomeInvisibleEvent() ); } - private void AssertCameraBecomeVisibleEvent(EventMessages eventMessages) + private void AssertCameraBecomeVisibleEvent(IEnumerable sentConnectors) { - Assert.NotNull(eventMessages); - Assert.AreEqual(1, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.NotNull(connectors); + Assert.AreEqual(2, connectors.Count); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + var connector = connectors[0] as CameraEvent; + Assert.NotNull(connector); - Assert.NotNull(eventMessages[0].EventData); - - Assert.AreEqual(CameraEventType.BecomeVisible, ((CameraEventData) eventMessages[0].EventData).EventType); + Assert.AreEqual(CameraEventType.BecomeVisible, connector.CameraEventType); HasAssert = true; } - private void AssertCameraBecomeInvisibleEvent(EventMessages eventMessages) + private void AssertCameraBecomeInvisibleEvent(IEnumerable sentConnectors) { - Assert.NotNull(eventMessages); - Assert.AreEqual(1, eventMessages.Count); - - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + var connectors = sentConnectors.ToList(); + Assert.NotNull(connectors); + Assert.AreEqual(2, connectors.Count); - Assert.NotNull(eventMessages[0].EventData); + var connector = connectors[0] as CameraEvent; + Assert.NotNull(connector); - Assert.AreEqual(CameraEventType.BecomeInvisible, ((CameraEventData) eventMessages[0].EventData).EventType); + Assert.AreEqual(CameraEventType.BecomeInvisible, connector.CameraEventType); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/IntervalTest.cs b/Assets/Tests/Runtime/Scripts/IntervalTest.cs index a7e9ca0..1273e44 100644 --- a/Assets/Tests/Runtime/Scripts/IntervalTest.cs +++ b/Assets/Tests/Runtime/Scripts/IntervalTest.cs @@ -1,35 +1,39 @@ -using System.Collections; -using EventConnector.Connector; -using NUnit.Framework; -using UnityEngine.TestTools; - -namespace EventConnector.Tests.Runtime -{ - public class IntervalTest : EventConnectorTestBase - { - [UnityTest] - public IEnumerator Interval() - { - yield return - RunAssert( - "Interval", - AssertInterval, - null, - 2.5 - ); - } - - private void AssertInterval(EventMessages eventMessages) - { - Assert.AreEqual(2, UnityEngine.Object.FindObjectOfType().ReceiveCount); - Assert.AreEqual(1, eventMessages.Count); - - Assert.AreEqual(EventType.Interval, eventMessages[0].EventType); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - Assert.AreEqual(1.0f, eventMessages[0].EventData); - - HasAssert = true; - } - } -} \ No newline at end of file +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using UniFlow.Connector.Logic; +using UnityEngine; +using UnityEngine.TestTools; + +namespace UniFlow.Tests.Runtime +{ + public class IntervalTest : UniFlowTestBase + { + [UnityTest] + public IEnumerator Interval() + { + yield return + RunAssert( + "Interval", + AssertInterval, + null, + 2.5 + ); + } + + private void AssertInterval(IEnumerable sentConnectors) + { + var connectors = sentConnectors.ToList(); + Assert.AreEqual(2, Object.FindObjectOfType().ReceiveCount); + Assert.AreEqual(4, connectors.Count); + + var connector = connectors[0] as Interval; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.Seconds); + Assert.AreEqual(1.0f, connector.Seconds); + + HasAssert = true; + } + } +} diff --git a/Assets/Tests/Runtime/Scripts/LifecycleEventTest.cs b/Assets/Tests/Runtime/Scripts/LifecycleEventTest.cs index c498228..d2275a6 100644 --- a/Assets/Tests/Runtime/Scripts/LifecycleEventTest.cs +++ b/Assets/Tests/Runtime/Scripts/LifecycleEventTest.cs @@ -1,18 +1,18 @@ using System; using System.Collections; +using System.Collections.Generic; using System.Linq; -using EventConnector.Connector; -using EventConnector.Message; using NUnit.Framework; +using UniFlow.Connector.Event; using UniRx; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TestTools; using Object = UnityEngine.Object; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class LifecycleEventTest : EventConnectorTestBase + public class LifecycleEventTest : UniFlowTestBase { private LifecycleEventType CurrentLifecycleEventType { get; set; } @@ -96,17 +96,17 @@ private IEnumerator RunAssertInternal(LifecycleEventType lifecycleEventType, Act ); } - private void AssertLifecycleEvent(EventMessages eventMessages) + private void AssertLifecycleEvent(IEnumerable sentConnectors) { - Assert.NotNull(eventMessages); - Assert.GreaterOrEqual(eventMessages.Count, 1); + var connectors = sentConnectors.ToList(); + Assert.NotNull(connectors); + Assert.GreaterOrEqual(connectors.Count, 1); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - - Assert.AreEqual(CurrentLifecycleEventType, ((LifecycleEventData) eventMessages[0].EventData).EventType); + var connector = connectors[0] as LifecycleEvent; + Assert.NotNull(connector); + Assert.AreEqual(CurrentLifecycleEventType, connector.LifecycleEventType); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/PlayableControllerTest.cs b/Assets/Tests/Runtime/Scripts/PlayableControllerTest.cs index ffd97b2..0d86bf8 100644 --- a/Assets/Tests/Runtime/Scripts/PlayableControllerTest.cs +++ b/Assets/Tests/Runtime/Scripts/PlayableControllerTest.cs @@ -1,40 +1,45 @@ -using System.Collections; -using EventConnector.Connector; -using EventConnector.Message; -using NUnit.Framework; -using UnityEngine.Playables; -using UnityEngine.TestTools; - -namespace EventConnector.Tests.Runtime -{ - public class PlayableControllerTest : EventConnectorTestBase - { - - [UnityTest] - public IEnumerator PlayableController() - { - yield return - RunAssert( - "PlayableController", - AssertPlayableController, - null, - 1.1 - ); - } - - private void AssertPlayableController(EventMessages eventMessages) - { - Assert.AreEqual(2, eventMessages.Count); - - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - - Assert.IsInstanceOf(eventMessages[1].Sender); - Assert.IsInstanceOf(eventMessages[1].EventData); - var timelineEvent = eventMessages[1].EventData as TimelineEventData; - Assert.NotNull(timelineEvent); - Assert.AreEqual("PlayableControllerTest", timelineEvent.StringParameter); - HasAssert = true; - } - } -} \ No newline at end of file +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using UniFlow.Connector.Controller; +using UnityEngine.Playables; +using UnityEngine.TestTools; + +namespace UniFlow.Tests.Runtime +{ + public class PlayableControllerTest : UniFlowTestBase + { + + [UnityTest] + public IEnumerator PlayableController() + { + yield return + RunAssert( + "PlayableController", + AssertPlayableController, + null, + 1.1 + ); + } + + private void AssertPlayableController(IEnumerable sentConnectors) + { + var connectors = sentConnectors.ToList(); + Assert.AreEqual(3, connectors.Count); + + { + var connector = connectors[0] as PlayableController; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.PlayableDirector); + } + + { + var connector = connectors[1] as Connector.Event.TimelineSignal; + Assert.NotNull(connector); + } + + HasAssert = true; + } + } +} diff --git a/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs b/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs new file mode 100644 index 0000000..c28e60c --- /dev/null +++ b/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs @@ -0,0 +1,68 @@ +using System.Collections; +using System.Linq; +using NUnit.Framework; +using UniFlow.Connector.Controller; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; + +namespace UniFlow.Tests.Runtime +{ + public class SimpleAnimationControllerTest : UniFlowTestBase + { + [UnityTest] + public IEnumerator Play() + { + yield return + RunAssert( + "SimpleAnimationController", + sentConnectors => + { + var connectors = sentConnectors.ToList(); + Assert.That(connectors.Count, Is.EqualTo(2)); + var connector = connectors[0] as SimpleAnimationController; + Assert.That(connector, Is.Not.Null); + Assert.That(connector.SimpleAnimation.isPlaying, Is.True); + HasAssert = true; + }, + () => + { + var go = SceneManager + .GetSceneByName("SimpleAnimationController") + .GetRootGameObjects() + .First(x => x.name == "Play"); + Assert.That(go, Is.Not.Null); + go.SetActive(true); + }, + 0.5 + ); + } + + [UnityTest] + public IEnumerator Stop() + { + yield return + RunAssert( + "SimpleAnimationController", + sentConnectors => + { + var connectors = sentConnectors.ToList(); + Assert.That(connectors.Count, Is.EqualTo(4)); + var connector = connectors[0] as SimpleAnimationController; + Assert.That(connector, Is.Not.Null); + Assert.That(connector.SimpleAnimation.isPlaying, Is.False); + HasAssert = true; + }, + () => + { + var go = SceneManager + .GetSceneByName("SimpleAnimationController") + .GetRootGameObjects() + .First(x => x.name == "Stop"); + Assert.That(go, Is.Not.Null); + go.SetActive(true); + }, + 1.5 + ); + } + } +} diff --git a/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs.meta b/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs.meta new file mode 100644 index 0000000..7355a56 --- /dev/null +++ b/Assets/Tests/Runtime/Scripts/SimpleAnimationControllerTest.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f92da595f87b40438f274e8e683aea8a +timeCreated: 1569998799 \ No newline at end of file diff --git a/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs b/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs new file mode 100644 index 0000000..a88a526 --- /dev/null +++ b/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs @@ -0,0 +1,68 @@ +using System.Collections; +using System.Linq; +using NUnit.Framework; +using UniFlow.Connector.Controller; +using UnityEngine.SceneManagement; +using UnityEngine.TestTools; + +namespace UniFlow.Tests.Runtime +{ + public class SimpleAnimationEventTest : UniFlowTestBase + { + [UnityTest] + public IEnumerator Play() + { + yield return + RunAssert( + "SimpleAnimationEvent", + sentConnectors => + { + var connectors = sentConnectors.ToList(); + Assert.That(connectors.Count, Is.EqualTo(3)); + var connector = connectors[0] as SimpleAnimationController; + Assert.That(connector, Is.Not.Null); + Assert.That(connector.SimpleAnimation.isPlaying, Is.True); + HasAssert = true; + }, + () => + { + var go = SceneManager + .GetSceneByName("SimpleAnimationEvent") + .GetRootGameObjects() + .First(x => x.name == "Play"); + Assert.That(go, Is.Not.Null); + go.SetActive(true); + }, + 0.5 + ); + } + + [UnityTest] + public IEnumerator Stop() + { + yield return + RunAssert( + "SimpleAnimationEvent", + sentConnectors => + { + var connectors = sentConnectors.ToList(); + Assert.That(connectors.Count, Is.EqualTo(3)); + var connector = connectors[0] as SimpleAnimationController; + Assert.That(connector, Is.Not.Null); + Assert.That(connector.SimpleAnimation.GetStates().First().normalizedTime, Is.GreaterThanOrEqualTo(1.0)); + HasAssert = true; + }, + () => + { + var go = SceneManager + .GetSceneByName("SimpleAnimationEvent") + .GetRootGameObjects() + .First(x => x.name == "Stop"); + Assert.That(go, Is.Not.Null); + go.SetActive(true); + }, + 1.5 + ); + } + } +} diff --git a/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs.meta b/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs.meta new file mode 100644 index 0000000..5ea4ea6 --- /dev/null +++ b/Assets/Tests/Runtime/Scripts/SimpleAnimationEventTest.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3d995359d6094123936437abca9a180f +timeCreated: 1569998808 \ No newline at end of file diff --git a/Assets/Tests/Runtime/Scripts/TestReceiver.cs b/Assets/Tests/Runtime/Scripts/TestReceiver.cs index 9ec0ec6..255b96b 100644 --- a/Assets/Tests/Runtime/Scripts/TestReceiver.cs +++ b/Assets/Tests/Runtime/Scripts/TestReceiver.cs @@ -1,14 +1,26 @@ -namespace EventConnector.Tests.Runtime -{ - public class TestReceiver : EventReceiver - { - public EventMessages SentEventMessages { get; private set; } - public int ReceiveCount { get; private set; } - - public override void OnReceive(EventMessages eventMessages) - { - SentEventMessages = eventMessages; - ReceiveCount++; - } - } -} \ No newline at end of file +using System.Collections.Generic; +using UniRx; + +namespace UniFlow.Tests.Runtime +{ + public class TestReceiver : ReceiverBase + { + public IList SentConnectors { get; } = new List(); + public int ReceiveCount { get; private set; } + + private void Awake() + { + Logger.OnMessageAsObservable().Where(x => x != default).Subscribe(SentConnectors.Add); + } + + public void Reset() + { + SentConnectors.Clear(); + } + + public override void OnReceive() + { + ReceiveCount++; + } + } +} diff --git a/Assets/Tests/Runtime/Scripts/TimelineSignalTest.cs b/Assets/Tests/Runtime/Scripts/TimelineSignalTest.cs index 912f264..380ee8c 100644 --- a/Assets/Tests/Runtime/Scripts/TimelineSignalTest.cs +++ b/Assets/Tests/Runtime/Scripts/TimelineSignalTest.cs @@ -1,12 +1,12 @@ using System.Collections; -using EventConnector.Connector; -using EventConnector.Message; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; using UnityEngine.TestTools; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class TimelineSignalTest : EventConnectorTestBase + public class TimelineSignalTest : UniFlowTestBase { [UnityTest] public IEnumerator TimelineSignal() @@ -20,16 +20,14 @@ public IEnumerator TimelineSignal() ); } - private void AssertTimelineSignal(EventMessages eventMessages) + private void AssertTimelineSignal(IEnumerable sentConnectors) { - Assert.AreEqual(1, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(2, connectors.Count); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - var timelineEvent = eventMessages[0].EventData as TimelineEventData; - Assert.NotNull(timelineEvent); - Assert.AreEqual("TimelineSignalTest", timelineEvent.StringParameter); + var connector = connectors[0] as Connector.Event.TimelineSignal; + Assert.NotNull(connector); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/TimerTest.cs b/Assets/Tests/Runtime/Scripts/TimerTest.cs index 2fa8513..9dd0a6d 100644 --- a/Assets/Tests/Runtime/Scripts/TimerTest.cs +++ b/Assets/Tests/Runtime/Scripts/TimerTest.cs @@ -1,11 +1,13 @@ using System.Collections; -using EventConnector.Connector; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; +using UniFlow.Connector.Logic; using UnityEngine.TestTools; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class TimerTest : EventConnectorTestBase + public class TimerTest : UniFlowTestBase { [UnityTest] public IEnumerator Timer() @@ -19,16 +21,17 @@ public IEnumerator Timer() ); } - private void AssertTimer(EventMessages eventMessages) + private void AssertTimer(IEnumerable sentConnectors) { - Assert.AreEqual(1, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(2, connectors.Count); - Assert.AreEqual(EventType.Timer, eventMessages[0].EventType); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); - Assert.AreEqual(1.0f, eventMessages[0].EventData); + var connector = connectors[0] as Timer; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.Seconds); + Assert.AreEqual(1.0f, connector.Seconds); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/UIBehaviourEventTest.cs b/Assets/Tests/Runtime/Scripts/UIBehaviourEventTest.cs index df69802..6cac201 100644 --- a/Assets/Tests/Runtime/Scripts/UIBehaviourEventTest.cs +++ b/Assets/Tests/Runtime/Scripts/UIBehaviourEventTest.cs @@ -1,14 +1,17 @@ using System.Collections; +using System.Collections.Generic; +using System.Linq; using NUnit.Framework; +using UniFlow.Connector.Event; using UniRx.Triggers; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.TestTools; using UnityEngine.UI; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public class UIBehaviourEventTest : EventConnectorTestBase + public class UIBehaviourEventTest : UniFlowTestBase { [UnityTest] public IEnumerator UIBehaviourEventTrigger() @@ -24,13 +27,15 @@ public IEnumerator UIBehaviourEventTrigger() ); } - private void AssertUIBehaviourEventTrigger(EventMessages eventMessages) + private void AssertUIBehaviourEventTrigger(IEnumerable sentConnectors) { - Assert.AreEqual(1, eventMessages.Count); + var connectors = sentConnectors.ToList(); + Assert.AreEqual(2, connectors.Count); - Assert.IsInstanceOf(eventMessages[0].Sender); - Assert.IsInstanceOf(eventMessages[0].EventData); + var connector = connectors[0] as UIBehaviourEventTrigger; + Assert.NotNull(connector); + Assert.IsInstanceOf(connector.UIBehaviour); HasAssert = true; } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/EventConnectorTestBase.cs b/Assets/Tests/Runtime/Scripts/UniFlowTestBase.cs similarity index 77% rename from Assets/Tests/Runtime/Scripts/EventConnectorTestBase.cs rename to Assets/Tests/Runtime/Scripts/UniFlowTestBase.cs index 9a37e56..d5fbe1c 100644 --- a/Assets/Tests/Runtime/Scripts/EventConnectorTestBase.cs +++ b/Assets/Tests/Runtime/Scripts/UniFlowTestBase.cs @@ -1,14 +1,15 @@ using System; using System.Collections; +using System.Collections.Generic; using NUnit.Framework; using UniRx; using UnityEngine.SceneManagement; using Zenject; using Object = UnityEngine.Object; -namespace EventConnector.Tests.Runtime +namespace UniFlow.Tests.Runtime { - public abstract class EventConnectorTestBase : ZenjectIntegrationTestFixture + public abstract class UniFlowTestBase : ZenjectIntegrationTestFixture { private const string ScenePath = "Tests/Runtime/Scenes/Basic/"; protected bool HasAssert { private get; set; } @@ -17,9 +18,10 @@ public abstract class EventConnectorTestBase : ZenjectIntegrationTestFixture public void SetUp() { HasAssert = false; + Logger.Activate(); } - protected IEnumerator RunAssert(string sceneName, Action assertCallback, Action beforeAssertCallback, double waitBeforeAssert = 0, int invokeCount = 1) + protected IEnumerator RunAssert(string sceneName, Action> assertCallback, Action beforeAssertCallback, double waitBeforeAssert = 0, int invokeCount = 1) { PreInstall(); yield return SceneManager.LoadSceneAsync($"{ScenePath}{sceneName}", LoadSceneMode.Additive); @@ -31,7 +33,8 @@ protected IEnumerator RunAssert(string sceneName, Action assertCa { yield return Observable.Timer(TimeSpan.FromSeconds(waitBeforeAssert)).StartAsCoroutine(); } - assertCallback(Object.FindObjectOfType().SentEventMessages); + assertCallback(Object.FindObjectOfType().SentConnectors); + Object.FindObjectOfType().Reset(); } Assert.GreaterOrEqual(Object.FindObjectOfType().ReceiveCount, invokeCount); Assert.True(HasAssert); @@ -41,4 +44,4 @@ protected IEnumerator RunAssert(string sceneName, Action assertCa PostInstall(); } } -} \ No newline at end of file +} diff --git a/Assets/Tests/Runtime/Scripts/EventConnectorTestBase.cs.meta b/Assets/Tests/Runtime/Scripts/UniFlowTestBase.cs.meta similarity index 100% rename from Assets/Tests/Runtime/Scripts/EventConnectorTestBase.cs.meta rename to Assets/Tests/Runtime/Scripts/UniFlowTestBase.cs.meta diff --git a/Assets/Tests/Runtime/Timelines/PlayableController.playable b/Assets/Tests/Runtime/Timelines/PlayableController.playable index 71ef3a8..c8b29c5 100644 --- a/Assets/Tests/Runtime/Timelines/PlayableController.playable +++ b/Assets/Tests/Runtime/Timelines/PlayableController.playable @@ -19,6 +19,7 @@ MonoBehaviour: m_MatchTargetFields: 63 m_RemoveStartOffset: 1 m_ApplyFootIK: 1 + m_Loop: 0 m_Version: 1 m_Rotation: {x: 0, y: 0, z: 0, w: 1} --- !u!114 &11400000 @@ -156,6 +157,7 @@ MonoBehaviour: m_InfiniteClipTimeOffset: 0 m_InfiniteClipRemoveOffset: 0 m_InfiniteClipApplyFootIK: 1 + mInfiniteClipLoop: 0 m_MatchTargetFields: 63 m_Position: {x: 0, y: 0, z: 0} m_EulerAngles: {x: 0, y: 0, z: 0} diff --git a/Assets/Tests/Runtime/EventConnector.Tests.Runtime.asmdef b/Assets/Tests/Runtime/UniFlow.Tests.Runtime.asmdef similarity index 74% rename from Assets/Tests/Runtime/EventConnector.Tests.Runtime.asmdef rename to Assets/Tests/Runtime/UniFlow.Tests.Runtime.asmdef index 2f67dfc..94fff2d 100644 --- a/Assets/Tests/Runtime/EventConnector.Tests.Runtime.asmdef +++ b/Assets/Tests/Runtime/UniFlow.Tests.Runtime.asmdef @@ -1,10 +1,10 @@ { - "name": "EventConnector.Tests.Runtime", + "name": "UniFlow.Tests.Runtime", "references": [ "GUID:04f82f1ff3df44e29a1b2cce70510c34", "GUID:560b04d1a97f54a4e82edc0cbbb69285", "GUID:0d8beb7f090555447a6cf5ce9e54dbb4", - "GUID:a2f2239355369ba4fb6909aeaa41def5", + "GUID:aff632302a0b84b498c3f33f7639b4d3", "GUID:27619889b8ba8c24980f49ee34dbb44a", "GUID:0acc523941302664db1f4e527237feb3" ], @@ -14,11 +14,12 @@ "overrideReferences": true, "precompiledReferences": [ "nunit.framework.dll", - "Zenject-TestFramework.dll" + "Zenject-TestFramework-usage.dll" ], "autoReferenced": false, "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [] + "versionDefines": [], + "noEngineReferences": false } \ No newline at end of file diff --git a/Assets/Tests/Runtime/EventConnector.Tests.Runtime.asmdef.meta b/Assets/Tests/Runtime/UniFlow.Tests.Runtime.asmdef.meta similarity index 100% rename from Assets/Tests/Runtime/EventConnector.Tests.Runtime.asmdef.meta rename to Assets/Tests/Runtime/UniFlow.Tests.Runtime.asmdef.meta diff --git a/Assets/EventConnector.asmdef b/Assets/UniFlow.asmdef similarity index 65% rename from Assets/EventConnector.asmdef rename to Assets/UniFlow.asmdef index 41d7219..e3e22b8 100644 --- a/Assets/EventConnector.asmdef +++ b/Assets/UniFlow.asmdef @@ -1,11 +1,14 @@ { - "name": "EventConnector", + "name": "UniFlow", "references": [ "GUID:f06555f75b070af458a003d92f9efb00", + "GUID:aff632302a0b84b498c3f33f7639b4d3", "GUID:560b04d1a97f54a4e82edc0cbbb69285", + "GUID:f51ebe6a0ceec4240a699833d6309b23", + "GUID:c571cab59b47e4b18969473a38df77be", + "GUID:beb451cbe847343cda1f9c1e001b3e06", "GUID:0d8beb7f090555447a6cf5ce9e54dbb4" ], - "optionalUnityReferences": [], "includePlatforms": [], "excludePlatforms": [], "allowUnsafeCode": false, diff --git a/Assets/EventConnector.asmdef.meta b/Assets/UniFlow.asmdef.meta similarity index 100% rename from Assets/EventConnector.asmdef.meta rename to Assets/UniFlow.asmdef.meta diff --git a/Assets/package.json b/Assets/package.json index 1f6fe05..0816a94 100644 --- a/Assets/package.json +++ b/Assets/package.json @@ -1,9 +1,9 @@ { - "name": "dev.monry.upm.eventconnector", - "displayName": "Event Connector", - "version": "0.0.4-preview.5", + "name": "dev.monry.uniflow", + "displayName": "UniFlow", + "version": "0.1.0-preview.45", "unity": "2019.2", - "description": "EventConnector is a library that can connect various Unity events including user interaction without writing any C# script. Processes such as \"Tutorial that accepts user interaction\" and \"Waiting for the end of playback of Animation, Audio, Timeline, etc.\" can be implemented easily.", + "description": "UniFlow is a library that can connect various Unity events including user interaction without writing any C# script. Processes such as \"Tutorial that accepts user interaction\" and \"Waiting for the end of playback of Animation, Audio, Timeline, etc.\" can be implemented easily.", "author": { "name": "Tetsuya Mori", "url": "https://me.monry.dev/", @@ -13,11 +13,13 @@ "keywords": [], "category": "", "dependencies": { - "com.stevevermeulen.extenject": "9.1.0", - "jp.cysharp.unirx": "7.1.0" + "com.unity.simpleanimation": "1.0.0", + "com.stevevermeulen.extenject": "9.1.3", + "dev.monry.unirx-observabletween": "0.1.0", + "dev.upm-packages.keyeventhandler": "1.1.1" }, "repository": { "type": "git", - "url": "https://github.com/monry/EventConnector" + "url": "https://github.com/monry/UniFlow" } } diff --git a/Packages/manifest.json b/Packages/manifest.json index 015dbc3..0c892b8 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -4,31 +4,36 @@ "name": "Unofficial Unity Package Manager Registry", "url": "https://upm-packages.dev", "scopes": [ - "com.stevevermeulen", - "jp.cysharp", - "dev.monry.upm" + "com.stevevermeulen.extenject", + "com.unity.simpleanimation", + "dev.monry", + "dev.upm-packages" ] } ], "dependencies": { - "com.stevevermeulen.extenject": "9.1.0", + "com.cysharp.unitask": "git+ssh://git@github.com/cysharp/UniTask.git?path=/src/UniTask/Assets/Plugins/UniTask/", + "com.neuecc.unirx": "git+ssh://git@github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts/", + "com.stevevermeulen.extenject": "9.1.3", "com.unity.2d.sprite": "1.0.0", "com.unity.2d.tilemap": "1.0.0", - "com.unity.ads": "2.0.8", - "com.unity.analytics": "3.3.2", - "com.unity.collab-proxy": "1.2.16", - "com.unity.ext.nunit": "1.0.0", - "com.unity.ide.rider": "1.0.8", - "com.unity.ide.vscode": "1.0.7", - "com.unity.multiplayer-hlapi": "1.0.2", - "com.unity.package-manager-ui": "2.2.0", - "com.unity.purchasing": "2.0.6", - "com.unity.test-framework": "1.0.13", - "com.unity.textmeshpro": "2.0.1", - "com.unity.timeline": "1.1.0", + "com.unity.ads": "3.5.2", + "com.unity.analytics": "3.5.3", + "com.unity.collab-proxy": "1.3.9", + "com.unity.ext.nunit": "1.0.5", + "com.unity.ide.rider": "2.0.7", + "com.unity.ide.visualstudio": "2.0.5", + "com.unity.ide.vscode": "1.2.3", + "com.unity.multiplayer-hlapi": "1.0.6", + "com.unity.purchasing": "2.1.1", + "com.unity.simpleanimation": "1.0.0", + "com.unity.test-framework": "1.1.19", + "com.unity.textmeshpro": "3.0.1", + "com.unity.timeline": "1.3.6", "com.unity.ugui": "1.0.0", - "com.unity.xr.legacyinputhelpers": "2.0.2", - "jp.cysharp.unirx": "7.1.0", + "com.unity.xr.legacyinputhelpers": "2.1.6", + "dev.monry.unirx-observabletween": "0.1.0", + "dev.upm-packages.keyeventhandler": "1.1.1", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", "com.unity.modules.animation": "1.0.0", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json new file mode 100644 index 0000000..8eef657 --- /dev/null +++ b/Packages/packages-lock.json @@ -0,0 +1,454 @@ +{ + "dependencies": { + "com.cysharp.unitask": { + "version": "git+ssh://git@github.com/cysharp/UniTask.git?path=/src/UniTask/Assets/Plugins/UniTask/", + "depth": 0, + "source": "git", + "dependencies": {}, + "hash": "7d21a75ea8abbc3ed43afedeb450c8d44f244ece" + }, + "com.neuecc.unirx": { + "version": "git+ssh://git@github.com/neuecc/UniRx.git?path=Assets/Plugins/UniRx/Scripts/", + "depth": 0, + "source": "git", + "dependencies": {}, + "hash": "284d5c50d3f1ddd9fa7df3d382ea904732a9c2ff" + }, + "com.stevevermeulen.extenject": { + "version": "9.1.3", + "depth": 0, + "source": "registry", + "dependencies": { + "dev.upm-packages.moq": "4.13.3", + "dev.upm-packages.nsubstitute": "2.0.4" + }, + "url": "https://upm-packages.dev" + }, + "com.unity.2d.sprite": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.2d.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.ads": { + "version": "3.5.2", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.analytics": { + "version": "3.5.3", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.collab-proxy": { + "version": "1.3.9", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ext.nunit": { + "version": "1.0.5", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ide.rider": { + "version": "2.0.7", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.test-framework": "1.1.1" + }, + "url": "https://packages.unity.com" + }, + "com.unity.ide.visualstudio": { + "version": "2.0.5", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ide.vscode": { + "version": "1.2.3", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.multiplayer-hlapi": { + "version": "1.0.6", + "depth": 0, + "source": "registry", + "dependencies": { + "nuget.mono-cecil": "0.1.6-preview" + }, + "url": "https://packages.unity.com" + }, + "com.unity.purchasing": { + "version": "2.1.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.simpleanimation": { + "version": "1.0.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://upm-packages.dev" + }, + "com.unity.test-framework": { + "version": "1.1.19", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ext.nunit": "1.0.5", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.textmeshpro": { + "version": "3.0.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.unity.ugui": "1.0.0" + }, + "url": "https://packages.unity.com" + }, + "com.unity.timeline": { + "version": "1.3.6", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.ugui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0" + } + }, + "com.unity.xr.legacyinputhelpers": { + "version": "2.1.6", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "dev.monry.unirx-observabletween": { + "version": "0.1.0", + "depth": 0, + "source": "registry", + "dependencies": {}, + "url": "https://upm-packages.dev" + }, + "dev.upm-packages.keyeventhandler": { + "version": "1.1.1", + "depth": 0, + "source": "registry", + "dependencies": { + "com.stevevermeulen.extenject": "9.1.3" + }, + "url": "https://upm-packages.dev" + }, + "dev.upm-packages.moq": { + "version": "4.13.3", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://upm-packages.dev" + }, + "dev.upm-packages.nsubstitute": { + "version": "2.0.4", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://upm-packages.dev" + }, + "nuget.mono-cecil": { + "version": "0.1.6-preview", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, + "com.unity.modules.ai": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.androidjni": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.animation": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.assetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.audio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.cloth": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.director": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.animation": "1.0.0" + } + }, + "com.unity.modules.imageconversion": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.imgui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.jsonserialize": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.particlesystem": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.physics2d": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.screencapture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.subsystems": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.terrain": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.terrainphysics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.terrain": "1.0.0" + } + }, + "com.unity.modules.tilemap": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics2d": "1.0.0" + } + }, + "com.unity.modules.ui": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.uielements": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.uielementsnative": "1.0.0" + } + }, + "com.unity.modules.uielementsnative": { + "version": "1.0.0", + "depth": 1, + "source": "builtin", + "dependencies": { + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.imgui": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.umbra": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unityanalytics": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0" + } + }, + "com.unity.modules.unitywebrequest": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.unitywebrequestassetbundle": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestaudio": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.audio": "1.0.0" + } + }, + "com.unity.modules.unitywebrequesttexture": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.unitywebrequestwww": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.modules.unitywebrequestassetbundle": "1.0.0", + "com.unity.modules.unitywebrequestaudio": "1.0.0", + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.assetbundle": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0" + } + }, + "com.unity.modules.vehicles": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0" + } + }, + "com.unity.modules.video": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.audio": "1.0.0", + "com.unity.modules.ui": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0" + } + }, + "com.unity.modules.vr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.xr": "1.0.0" + } + }, + "com.unity.modules.wind": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": {} + }, + "com.unity.modules.xr": { + "version": "1.0.0", + "depth": 0, + "source": "builtin", + "dependencies": { + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.jsonserialize": "1.0.0", + "com.unity.modules.subsystems": "1.0.0" + } + } + } +} diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 43c3c74..5c3c04c 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -41,4 +41,10 @@ EditorBuildSettings: - enabled: 1 path: Assets/Tests/Runtime/Scenes/Basic/Interval.unity guid: ac7afeeb1f8314eb9b16f588850cdda0 + - enabled: 1 + path: Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationController.unity + guid: 6977b8f896215433887311c3be8b846e + - enabled: 1 + path: Assets/Tests/Runtime/Scenes/Basic/SimpleAnimationEvent.unity + guid: c4ecb70dbd61f493a8b69cfeaf14d49d m_configObjects: {} diff --git a/ProjectSettings/EditorSettings.asset b/ProjectSettings/EditorSettings.asset index 3b2e138..d491e5f 100644 --- a/ProjectSettings/EditorSettings.asset +++ b/ProjectSettings/EditorSettings.asset @@ -3,7 +3,7 @@ --- !u!159 &1 EditorSettings: m_ObjectHideFlags: 0 - serializedVersion: 8 + serializedVersion: 9 m_ExternalVersionControlSupport: Hidden Meta Files m_SerializationMode: 2 m_LineEndingsForNewScripts: 1 @@ -17,10 +17,19 @@ EditorSettings: m_EtcTextureNormalCompressor: 2 m_EtcTextureBestCompressor: 4 m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref - m_ProjectGenerationRootNamespace: EventConnector + m_ProjectGenerationRootNamespace: UniFlow m_CollabEditorSettings: inProgressEnabled: 1 m_EnableTextureStreamingInEditMode: 1 m_EnableTextureStreamingInPlayMode: 1 m_AsyncShaderCompilation: 1 + m_EnterPlayModeOptionsEnabled: 0 + m_EnterPlayModeOptions: 3 m_ShowLightmapResolutionOverlay: 1 + m_UseLegacyProbeSampleCount: 1 + m_AssetPipelineMode: 1 + m_CacheServerMode: 0 + m_CacheServerEndpoint: + m_CacheServerNamespacePrefix: default + m_CacheServerEnableDownload: 1 + m_CacheServerEnableUpload: 1 diff --git a/ProjectSettings/PackageManagerSettings.asset b/ProjectSettings/PackageManagerSettings.asset new file mode 100644 index 0000000..b379555 --- /dev/null +++ b/ProjectSettings/PackageManagerSettings.asset @@ -0,0 +1,60 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &1 +MonoBehaviour: + m_ObjectHideFlags: 61 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} + m_Name: + m_EditorClassIdentifier: + m_EnablePreviewPackages: 0 + m_EnablePackageDependencies: 0 + m_AdvancedSettingsExpanded: 1 + m_ScopedRegistriesSettingsExpanded: 1 + oneTimeWarningShown: 0 + m_Registries: + - m_Id: main + m_Name: + m_Url: https://packages.unity.com + m_Scopes: [] + m_IsDefault: 1 + m_Capabilities: 7 + - m_Id: scoped:Unofficial Unity Package Manager Registry + m_Name: Unofficial Unity Package Manager Registry + m_Url: https://upm-packages.dev + m_Scopes: + - com.stevevermeulen.extenject + - com.unity.simpleanimation + - dev.monry + - dev.upm-packages + m_IsDefault: 0 + m_Capabilities: 0 + m_UserSelectedRegistryName: + m_UserAddingNewScopedRegistry: 0 + m_RegistryInfoDraft: + m_ErrorMessage: + m_Original: + m_Id: scoped:Unofficial Unity Package Manager Registry + m_Name: Unofficial Unity Package Manager Registry + m_Url: https://upm-packages.dev + m_Scopes: + - com.stevevermeulen.extenject + - com.unity.simpleanimation + - dev.monry + - dev.upm-packages + m_IsDefault: 0 + m_Capabilities: 0 + m_Modified: 0 + m_Name: Unofficial Unity Package Manager Registry + m_Url: https://upm-packages.dev + m_Scopes: + - com.stevevermeulen.extenject + - com.unity.simpleanimation + - dev.monry + - dev.upm-packages + m_SelectedScopeIndex: 0 diff --git a/ProjectSettings/ProjectSettings.asset b/ProjectSettings/ProjectSettings.asset index eff3339..a7c63d5 100644 --- a/ProjectSettings/ProjectSettings.asset +++ b/ProjectSettings/ProjectSettings.asset @@ -13,7 +13,7 @@ PlayerSettings: useOnDemandResources: 0 accelerometerFrequency: 60 companyName: DefaultCompany - productName: EventConnector + productName: UniFlow defaultCursor: {fileID: 0} cursorHotspot: {x: 0, y: 0} m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} @@ -151,6 +151,8 @@ PlayerSettings: sharedDepthBuffer: 1 dashSupport: 1 lowOverheadMode: 0 + protectedContext: 0 + v2Signing: 0 enable360StereoCapture: 0 isWsaHolographicRemotingEnabled: 0 protectGraphicsMemory: 0 diff --git a/ProjectSettings/ProjectVersion.txt b/ProjectSettings/ProjectVersion.txt index 7e64146..a328ffd 100644 --- a/ProjectSettings/ProjectVersion.txt +++ b/ProjectSettings/ProjectVersion.txt @@ -1,2 +1,2 @@ -m_EditorVersion: 2019.2.0f1 -m_EditorVersionWithRevision: 2019.2.0f1 (20c1667945cf) +m_EditorVersion: 2020.2.1f1 +m_EditorVersionWithRevision: 2020.2.1f1 (270dd8c3da1c) diff --git a/ProjectSettings/VersionControlSettings.asset b/ProjectSettings/VersionControlSettings.asset new file mode 100644 index 0000000..dca2881 --- /dev/null +++ b/ProjectSettings/VersionControlSettings.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!890905787 &1 +VersionControlSettings: + m_ObjectHideFlags: 0 + m_Mode: Visible Meta Files + m_CollabEditorSettings: + inProgressEnabled: 1 diff --git a/UIElements.xsd b/UIElements.xsd new file mode 100644 index 0000000..4a3eba1 --- /dev/null +++ b/UIElements.xsd @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/UnityEditor.Experimental.UIElements.GraphView.xsd b/UnityEditor.Experimental.UIElements.GraphView.xsd new file mode 100644 index 0000000..6e47008 --- /dev/null +++ b/UnityEditor.Experimental.UIElements.GraphView.xsd @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityEditor.Experimental.UIElements.xsd b/UnityEditor.Experimental.UIElements.xsd new file mode 100644 index 0000000..40d366f --- /dev/null +++ b/UnityEditor.Experimental.UIElements.xsd @@ -0,0 +1,228 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityEditor.PackageManager.UI.xsd b/UnityEditor.PackageManager.UI.xsd new file mode 100644 index 0000000..c03366a --- /dev/null +++ b/UnityEditor.PackageManager.UI.xsd @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityEngine.Experimental.UIElements.xsd b/UnityEngine.Experimental.UIElements.xsd new file mode 100644 index 0000000..4b00590 --- /dev/null +++ b/UnityEngine.Experimental.UIElements.xsd @@ -0,0 +1,269 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UserSettings/EditorUserSettings.asset b/UserSettings/EditorUserSettings.asset new file mode 100644 index 0000000..4681d1d --- /dev/null +++ b/UserSettings/EditorUserSettings.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!162 &1 +EditorUserSettings: + m_ObjectHideFlags: 0 + serializedVersion: 4 + m_ConfigSettings: + vcSharedLogLevel: + value: 0d5e400f0650 + flags: 0 + m_VCAutomaticAdd: 1 + m_VCDebugCom: 0 + m_VCDebugCmd: 0 + m_VCDebugOut: 0 + m_SemanticMergeMode: 2 + m_VCShowFailedCheckout: 1 + m_VCOverwriteFailedCheckoutAssets: 1 + m_VCOverlayIcons: 1 + m_VCAllowAsyncUpdate: 0