Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Commit

Permalink
Ready for 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Dec 26, 2015
1 parent df00e15 commit fe4fc3d
Show file tree
Hide file tree
Showing 9 changed files with 407 additions and 437 deletions.
4 changes: 2 additions & 2 deletions .nuget/UniRx.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>UniRx</id>
<version>5.0.0</version>
<version>5.1.0</version>
<title>UniRx</title>
<authors>neuecc</authors>
<owners>neuecc</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Reactive Extensions for Unity. This is .NET 3.5 subset of UniRx.</description>
<releaseNotes>
<![CDATA[
Initial Release.
drop ReactiveProperty.
]]>
</releaseNotes>
<language>en-US</language>
Expand Down
16 changes: 16 additions & 0 deletions Assets/ObjectTest/UniRxTestSandbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,8 @@ public class UniRxTestSandbox : MonoBehaviour

#if UNITY_5_3

public UnityEngine.UI.Button button;

static IEnumerator Enumerate<T>(IObservable<T> source)
{
Debug.Log("Start:" + Time.frameCount);
Expand Down Expand Up @@ -343,6 +345,20 @@ public void Awake()
//{
// logtext.AppendLine(x.Message);
//});

#if UNITY_5_3

button.OnClickAsObservable().Subscribe(_ =>
{
UnityEngine.Debug.Log("---");
Observable.EveryGameObjectUpdate().Subscribe(x => Debug.Log("EveryGameObjectUpdate" + x));
Observable.EveryUpdate().Subscribe(x => Debug.Log("EveryUpdate:" + x));
Observable.EveryAfterUpdate().Subscribe(x => Debug.Log("EveryAfterUpdate:" + x));
Observable.EveryLateUpdate().Subscribe(x => Debug.Log("EveryLateUpdate:" + x));
Observable.EveryEndOfFrame().Subscribe(x => Debug.Log("EveryEndOfFrame:" + x));
UnityEngine.Debug.Log("---");
});
#endif
}

CompositeDisposable disposables = new CompositeDisposable();
Expand Down
185 changes: 185 additions & 0 deletions Assets/Scenes/TestSandbox.unity
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,116 @@ NavMeshSettings:
cellSize: 0.16666666
manualCellSize: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &254224583
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 254224584}
- 222: {fileID: 254224587}
- 114: {fileID: 254224586}
- 114: {fileID: 254224585}
m_Layer: 5
m_Name: Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &254224584
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 254224583}
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:
- {fileID: 1858683792}
m_Father: {fileID: 1974814134}
m_RootOrder: 2
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -20.2, y: -286.6}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &254224585
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 254224583}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 254224586}
m_OnClick:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &254224586
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 254224583}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, 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: 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
--- !u!222 &254224587
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 254224583}
--- !u!1 &385421059
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -234,6 +344,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 02440cdbc97b02245978ad23e78a3189, type: 3}
m_Name:
m_EditorClassIdentifier:
button: {fileID: 254224585}
V2R:
value: {x: 0, y: 0}
arrayC: []
Expand Down Expand Up @@ -740,6 +851,79 @@ CanvasRenderer:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1187864574}
--- !u!1 &1858683791
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 1858683792}
- 222: {fileID: 1858683794}
- 114: {fileID: 1858683793}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1858683792
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1858683791}
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: 254224584}
m_RootOrder: 0
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1858683793
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1858683791}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, 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_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Button
--- !u!222 &1858683794
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1858683791}
--- !u!1 &1941444485
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -837,6 +1021,7 @@ RectTransform:
m_Children:
- {fileID: 871212533}
- {fileID: 811960235}
- {fileID: 254224584}
m_Father: {fileID: 0}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
Expand Down
37 changes: 28 additions & 9 deletions Assets/UniRx/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UniRx - Reactive Extensions for Unity / ver.5.0.0
UniRx - Reactive Extensions for Unity / ver.5.1.0
===
Created by Yoshifumi Kawai(neuecc)

Expand Down Expand Up @@ -188,7 +188,7 @@ IEnumerator TestNewCustomYieldInstruction()
if (o.HasResult) { Debug.Log(o.Result); }

// other sample(wait until transform.position.y >= 100)
yield return this.ObserveEveryValueChanged(x => x.transform).FirstOrDefault(x => x.position.y >= 100).ToYieldInstruction();
yield return this.transform.ObserveEveryValueChanged(x => x.position).FirstOrDefault(p => p.y >= 100).ToYieldInstruction();
}
```
Normally, we have to use callbacks when we require a coroutine to return a value. Observable.FromCoroutine can convert coroutines to cancellable IObservable[T] instead.
Expand Down Expand Up @@ -470,7 +470,7 @@ this.gameObject.OnMouseDownAsObservable()
.Subscribe(x => Debug.Log(x));
```

UniRx gurantees hot observable(FromEvent/Subject/FromCoroutine/UnityUI.AsObservable..., there are like event) have unhandled exception durability. What is it? If subscribe in subcribe, does not detach event.
UniRx gurantees hot observable(FromEvent/Subject/ReactiveProperty/UnityUI.AsObservable..., there are like event) have unhandled exception durability. What is it? If subscribe in subcribe, does not detach event.

```csharp
button.OnClickAsObservable().Subscribe(_ =>
Expand Down Expand Up @@ -596,7 +596,7 @@ MainThreadDispatcher.StartCoroutine(enumerator)
Observable.FromCoroutine((observer, token) => enumerator(observer, token));

// convert IObservable to Coroutine
yield return Observable.Range(1, 10).StartAsCoroutine();
yield return Observable.Range(1, 10).ToYieldInstruction(); // after Unity 5.3, before can use StartAsCoroutine()

// Lifetime hooks
Observable.EveryApplicationPause();
Expand All @@ -613,6 +613,10 @@ Method |
EveryUpdate|
EveryFixedUpdate|
EveryEndOfFrame|
EveryGameObjectUpdate|
EveryLateUpdate|
EveryAfterUpdate|
ObserveOnMainThread|
NextFrame|
IntervalFrame|
TimerFrame|
Expand All @@ -629,6 +633,21 @@ For example, delayed invoke once:
Observable.TimerFrame(100).Subscribe(_ => Debug.Log("after 100 frame"));
```

Every* Method's execution order is

```
EveryGameObjectUpdate(in MainThreadDispatcher's Execution Order) ->
EveryUpdate ->
EveryAfterUpdate ->
EveryLateUpdate ->
EveryEndOfFrame
```

EveryGameObjectUpdate invoke from same frame if caller is called before MainThreadDispatcher.Update(I recommend MainThreadDispatcher called first than others(ScriptExecutionOrder makes -32000)
EveryLateUpdate, EveryEndOfFrame invoke from same frame.
EveryUpdate, EveryAfterUpdate invoke from next frame.
EveryAfterUpdate is only available in after Unity 5.3.

uGUI Integration
---
UniRx can handle `UnityEvent`s easily. Use `UnityEvent.AsObservable` to subscribe to events:
Expand Down Expand Up @@ -914,7 +933,7 @@ Therefore, when using NETFX_CORE, please refrain from using such constructs as `

DLL Separation
---
If you want to pre-build UniRx, you can build own dll. clone project and open `UniRx.sln`, you can see `UniRx.Library` and `UniRx.Library.Unity`. `UniRx.Library` can use both .NET 3.5 normal CLR application and Unity. `UniRx.Library.Unity` is for Unity project, you should define compile symbol like `UniRxLibrary;UNITY;UNITY_5_3_0;UNITY_5_3;UNITY_5;UNITY_IPHONE;`. We can not provides binary because compile symbol is different each other.
If you want to pre-build UniRx, you can build own dll. clone project and open `UniRx.sln`, you can see `UniRx.Library` and `UniRx.Library.Unity`. `UniRx.Library` can use both .NET 3.5 normal CLR application and Unity. `UniRx.Library.Unity` is for Unity project. You should define compile symbol like `UniRxLibrary;UNITY;UNITY_5_3_0;UNITY_5_3;UNITY_5;` + `UNITY_EDITOR`, `UNITY_IPHONE` or other platform symbol to `UniRx.Library`, `UniRx.Library.Unity`. We can not provides binary because compile symbol is different each other.

If needs `UniRx.Library` for minimal test, it avilable in NuGet.

Expand Down Expand Up @@ -963,10 +982,10 @@ Author's other Unity + LINQ Assets

Author Info
---
Yoshifumi Kawai(a.k.a. neuecc) is a software developer in Japan.
He is the Director/CTO at Grani, Inc.
Grani is a top social game developer in Japan.
He was awarded Microsoft MVP for Visual C# in 2011.
Yoshifumi Kawai(a.k.a. neuecc) is a software developer in Japan.
He is the Director/CTO at Grani, Inc.
Grani is a top social game developer in Japan.
He is awarding Microsoft MVP for Visual C# since 2011.
He is known as the creator of [linq.js](http://linqjs.codeplex.com/)(LINQ to Objects for JavaScript)

Blog: http://neue.cc/ (Japanese)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit fe4fc3d

Please sign in to comment.