[WIP] firebase init Error

This commit is contained in:
2024-08-02 20:09:59 +08:00
commit b77fd9f498
7087 changed files with 1466846 additions and 0 deletions

95
sdk-intergration/.gitignore vendored Normal file
View File

@@ -0,0 +1,95 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
/[Bb]in/
/SerializedBuildInfo/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta
/AssetsBammbooooooGameShare.PNG
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
.vsconfig
# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
*.apk
*.unitypackage
# Crashlytics generated file
crashlytics-build.properties
# ignore Test Scripts & resources in test folder
/[Aa]ssets/[Tt]emp[Tt]est/
/[Aa]ssets/[Tt]emp[Tt]est
/[Aa]ssets/[Tt]emp[Tt]est.meta
# ignore build info from reporter
/[Aa]ssets/StreamingAssets/build_info/
/[Aa]ssets/StreamingAssets/build_info
/[Aa]ssets/StreamingAssets/build_info.meta
## ignore generated playfab async scripts
#/LocalPackages/asap.playfab.async/Runtime/Gen.meta
#/LocalPackages/asap.playfab.async/Runtime/Gen/
#/LocalPackages/asap.playfab.async/Runtime/Gen
# ignore core source code
/LocalPackages/GameCore/
/LocalPackages/asap.core/
# HybridCLR Temp project
/HybridCLRData/StrippedAOTDllsTempProj
/Assets/StreamingAssets/*.bundle
/Assets/StreamingAssets/*.bundle.meta

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5f02ad5303d014bf4b369551cfe7b988
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,768 @@
%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.12733836, g: 0.13418846, b: 0.12118524, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0
serializedVersion: 12
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1
m_IndirectOutputScale: 1
m_AlbedoBoost: 1
m_EnvironmentLightingMode: 0
m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
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_LightProbeSampleCountMultiplier: 4
m_LightingDataAsset: {fileID: 0}
m_LightingSettings: {fileID: 0}
--- !u!196 &4
NavMeshSettings:
serializedVersion: 2
m_ObjectHideFlags: 0
m_BuildSettings:
serializedVersion: 3
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
buildHeightMesh: 0
maxJobWorkers: 0
preserveTilesOutsideBounds: 0
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &198000829
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 198000832}
- component: {fileID: 198000831}
- component: {fileID: 198000830}
m_Layer: 0
m_Name: EventSystem
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &198000830
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 198000829}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4f231c4fb786f3946a6b90b886c48677, type: 3}
m_Name:
m_EditorClassIdentifier:
m_SendPointerHoverToParent: 1
m_HorizontalAxis: Horizontal
m_VerticalAxis: Vertical
m_SubmitButton: Submit
m_CancelButton: Cancel
m_InputActionsPerSecond: 10
m_RepeatDelay: 0.5
m_ForceModuleActive: 0
--- !u!114 &198000831
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 198000829}
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 &198000832
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 198000829}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &276006784
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 276006785}
- component: {fileID: 276006787}
- component: {fileID: 276006786}
m_Layer: 5
m_Name: Text (Legacy)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &276006785
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 276006784}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1910171036}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 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 &276006786
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 276006784}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, 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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 33
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: 'Login
'
--- !u!222 &276006787
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 276006784}
m_CullTransparentMesh: 1
--- !u!1 &330585543
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 330585546}
- component: {fileID: 330585545}
- component: {fileID: 330585544}
- component: {fileID: 330585547}
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 &330585544
AudioListener:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
--- !u!20 &330585545
Camera:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 2
m_BackGroundColor: {r: 0.16148986, g: 0.16839476, b: 0.1792453, a: 0}
m_projectionMatrixMode: 1
m_GateFitMode: 2
m_FOVAxisMode: 0
m_Iso: 200
m_ShutterSpeed: 0.005
m_Aperture: 16
m_FocusDistance: 10
m_FocalLength: 50
m_BladeCount: 5
m_Curvature: {x: 2, y: 11}
m_BarrelClipping: 0.25
m_Anamorphism: 0
m_SensorSize: {x: 36, y: 24}
m_LensShift: {x: 0, y: 0}
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 &330585546
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &330585547
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 330585543}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_RenderShadows: 1
m_RequiresDepthTextureOption: 2
m_RequiresOpaqueTextureOption: 2
m_CameraType: 0
m_Cameras: []
m_RendererIndex: -1
m_VolumeLayerMask:
serializedVersion: 2
m_Bits: 1
m_VolumeTrigger: {fileID: 0}
m_VolumeFrameworkUpdateModeOption: 2
m_RenderPostProcessing: 1
m_Antialiasing: 0
m_AntialiasingQuality: 2
m_StopNaN: 0
m_Dithering: 0
m_ClearDepth: 1
m_AllowXRRendering: 1
m_AllowHDROutput: 1
m_UseScreenCoordOverride: 0
m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0}
m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0}
m_RequiresDepthTexture: 0
m_RequiresColorTexture: 0
m_Version: 2
m_TaaSettings:
quality: 3
frameInfluence: 0.1
jitterScale: 1
mipBias: 0
varianceClampScale: 0.9
contrastAdaptiveSharpening: 0
--- !u!1 &1451597218
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1451597222}
- component: {fileID: 1451597221}
- component: {fileID: 1451597220}
- component: {fileID: 1451597219}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1451597219
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451597218}
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 &1451597220
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451597218}
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
m_PresetInfoIsWorld: 0
--- !u!223 &1451597221
Canvas:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451597218}
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_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 0
m_UpdateRectTransformForStandalone: 0
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0
--- !u!224 &1451597222
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1451597218}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1910171036}
- {fileID: 2070325009}
m_Father: {fileID: 0}
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 &1788702878
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1788702880}
- component: {fileID: 1788702879}
m_Layer: 0
m_Name: SDKTest
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1788702879
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788702878}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b44cb388792044ef7b607d165c2da304, type: 3}
m_Name:
m_EditorClassIdentifier:
loginBtn: {fileID: 1910171037}
log: {fileID: 2070325010}
--- !u!4 &1788702880
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1788702878}
serializedVersion: 2
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1910171035
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1910171036}
- component: {fileID: 1910171039}
- component: {fileID: 1910171038}
- component: {fileID: 1910171037}
m_Layer: 5
m_Name: Button (Legacy)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &1910171036
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1910171035}
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_ConstrainProportionsScale: 0
m_Children:
- {fileID: 276006785}
m_Father: {fileID: 1451597222}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -163}
m_SizeDelta: {x: 160, y: 60}
m_Pivot: {x: 0.5, y: 1}
--- !u!114 &1910171037
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1910171035}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_WrapAround: 0
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_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, 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_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_SelectedTrigger: Selected
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 1910171038}
m_OnClick:
m_PersistentCalls:
m_Calls: []
--- !u!114 &1910171038
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1910171035}
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_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
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
--- !u!222 &1910171039
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1910171035}
m_CullTransparentMesh: 1
--- !u!1 &2070325008
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2070325009}
- component: {fileID: 2070325011}
- component: {fileID: 2070325010}
m_Layer: 5
m_Name: Text (Legacy)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2070325009
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2070325008}
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_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1451597222}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 1.7019043, y: -107.1734}
m_SizeDelta: {x: -35.1729, y: -266.5389}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2070325010
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2070325008}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.8207547, g: 0.8207547, b: 0.8207547, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 27
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 61
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text:
--- !u!222 &2070325011
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2070325008}
m_CullTransparentMesh: 1
--- !u!1660057539 &9223372036854775807
SceneRoots:
m_ObjectHideFlags: 0
m_Roots:
- {fileID: 330585546}
- {fileID: 1451597222}
- {fileID: 198000832}
- {fileID: 1788702880}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 99c9720ab356a0642a771bea13969a05
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1008f4ab2ad01408bb47f004c99aff06
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
//using tysdk;
using UnityEngine;
using UnityEngine.UI;
public class SDKTest : MonoBehaviour
{
[SerializeField]
private Button loginBtn;
[SerializeField]
private Text log;
//void Start()
//{
//loginBtn.onClick.AddListener(OnLogin);
//}
//private async void OnLogin()
//{
//log.text = string.Empty;
//var info = await TYSdkFacade.Instance.Login(EAccoutType.hwGuest);
//log.text = $"Login: {info.isSuccess}";
//}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b44cb388792044ef7b607d165c2da304
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 709f11a7f3c4041caa4ef136ea32d874
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,123 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-7893295128165547882
MonoBehaviour:
m_ObjectHideFlags: 3
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: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
threshold:
m_OverrideState: 1
m_Value: 1
min: 0
intensity:
m_OverrideState: 1
m_Value: 1
min: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
min: 0
max: 1
clamp:
m_OverrideState: 0
m_Value: 65472
min: 0
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
hdr: 0
showAlpha: 0
showEyeDropper: 1
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
skipIterations:
m_OverrideState: 0
m_Value: 1
min: 0
max: 16
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dirtIntensity:
m_OverrideState: 0
m_Value: 0
min: 0
--- !u!114 &-7011558710299706105
MonoBehaviour:
m_ObjectHideFlags: 3
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: 899c54efeace73346a0a16faa3afe726, type: 3}
m_Name: Vignette
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
color:
m_OverrideState: 0
m_Value: {r: 0, g: 0, b: 0, a: 1}
hdr: 0
showAlpha: 0
showEyeDropper: 1
center:
m_OverrideState: 0
m_Value: {x: 0.5, y: 0.5}
intensity:
m_OverrideState: 1
m_Value: 0.25
min: 0
max: 1
smoothness:
m_OverrideState: 1
m_Value: 0.4
min: 0.01
max: 1
rounded:
m_OverrideState: 0
m_Value: 0
--- !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: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: SampleSceneProfile
m_EditorClassIdentifier:
components:
- {fileID: 849379129802519247}
- {fileID: -7893295128165547882}
- {fileID: -7011558710299706105}
--- !u!114 &849379129802519247
MonoBehaviour:
m_ObjectHideFlags: 3
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: 97c23e3b12dc18c42a140437e53d3951, type: 3}
m_Name: Tonemapping
m_EditorClassIdentifier:
active: 1
m_AdvancedMode: 0
mode:
m_OverrideState: 1
m_Value: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a6560a915ef98420e9faacc1c7438823
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-1878332245247344467
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: f62c9c65cf3354c93be831c8bc075510, type: 3}
m_Name: SSAO
m_EditorClassIdentifier:
m_Active: 1
m_Shader: {fileID: 0}
m_Settings:
Downsample: 1
AfterOpaque: 0
Source: 0
NormalSamples: 0
Intensity: 0.5
DirectLightingStrength: 0.25
Radius: 0.25
SampleCount: 4
--- !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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
m_Name: URP-Balanced-Renderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
m_RendererFeatures:
- {fileID: -1878332245247344467}
m_RendererFeatureMap: adc0de57c6d2eee5
m_UseNativeRenderPass: 0
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
screenSpaceShadowPS: {fileID: 0}
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 0}
coreBlitColorAndDepthPS: {fileID: 0}
cameraMotionVector: {fileID: 0}
objectMotionVector: {fileID: 0}
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 2
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_DepthPrimingMode: 0
m_AccurateGbufferNormals: 0
m_ClusteredRendering: 0
m_TileSize: 32

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e634585d5c4544dd297acaee93dc2beb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
%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: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-Balanced
m_EditorClassIdentifier:
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: e634585d5c4544dd297acaee93dc2beb, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 2
m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512
m_AdditionalLightsShadowResolutionTierLow: 128
m_AdditionalLightsShadowResolutionTierMedium: 256
m_AdditionalLightsShadowResolutionTierHigh: 512
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 50
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 512
m_AdditionalLightsCookieFormat: 1
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
m_UseFastSRGBLinearConversion: 0
m_SupportDataDrivenLensFlare: 1
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 3
m_PrefilteringModeAdditionalLight: 3
m_PrefilteringModeAdditionalLightShadows: 0
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeScreenSpaceOcclusion: 2
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1
m_PrefilterHDROutput: 1
m_PrefilterSSAODepthNormals: 1
m_PrefilterSSAOSourceDepthLow: 0
m_PrefilterSSAOSourceDepthMedium: 1
m_PrefilterSSAOSourceDepthHigh: 1
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOBlueNoise: 1
m_PrefilterSSAOSampleCountLow: 0
m_PrefilterSSAOSampleCountMedium: 1
m_PrefilterSSAOSampleCountHigh: 1
m_PrefilterDBufferMRT1: 1
m_PrefilterDBufferMRT2: 1
m_PrefilterDBufferMRT3: 1
m_PrefilterSoftShadowsQualityLow: 1
m_PrefilterSoftShadowsQualityMedium: 1
m_PrefilterSoftShadowsQualityHigh: 1
m_PrefilterSoftShadows: 0
m_PrefilterScreenCoord: 1
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e1260c1148f6143b28bae5ace5e9c5d1
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-1878332245247344467
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: f62c9c65cf3354c93be831c8bc075510, type: 3}
m_Name: SSAO
m_EditorClassIdentifier:
m_Active: 1
m_Settings:
AOMethod: 1
Downsample: 0
AfterOpaque: 0
Source: 1
NormalSamples: 1
Intensity: 0.5
DirectLightingStrength: 0.25
Radius: 0.25
Samples: 0
BlurQuality: 0
Falloff: 100
SampleCount: -1
m_BlueNoise256Textures:
- {fileID: 2800000, guid: 36f118343fc974119bee3d09e2111500, type: 3}
- {fileID: 2800000, guid: 4b7b083e6b6734e8bb2838b0b50a0bc8, type: 3}
- {fileID: 2800000, guid: c06cc21c692f94f5fb5206247191eeee, type: 3}
- {fileID: 2800000, guid: cb76dd40fa7654f9587f6a344f125c9a, type: 3}
- {fileID: 2800000, guid: e32226222ff144b24bf3a5a451de54bc, type: 3}
- {fileID: 2800000, guid: 3302065f671a8450b82c9ddf07426f3a, type: 3}
- {fileID: 2800000, guid: 56a77a3e8d64f47b6afe9e3c95cb57d5, type: 3}
m_Shader: {fileID: 4800000, guid: 0849e84e3d62649e8882e9d6f056a017, type: 3}
--- !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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
m_Name: URP-HighFidelity-Renderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
hdrDebugViewPS: {fileID: 4800000, guid: 573620ae32aec764abd4d728906d2587, type: 3}
m_RendererFeatures:
- {fileID: -1878332245247344467}
m_RendererFeatureMap: adc0de57c6d2eee5
m_UseNativeRenderPass: 0
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
xrSystemData: {fileID: 11400000, guid: 60e1133243b97e347b653163a8c01b64, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
screenSpaceShadowPS: {fileID: 0}
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
fallbackLoadingPS: {fileID: 4800000, guid: 7f888aff2ac86494babad1c2c5daeee2, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 4800000, guid: 93446b5c5339d4f00b85c159e1159b7c, type: 3}
coreBlitColorAndDepthPS: {fileID: 4800000, guid: d104b2fc1ca6445babb8e90b0758136b,
type: 3}
blitHDROverlay: {fileID: 4800000, guid: a89bee29cffa951418fc1e2da94d1959, type: 3}
cameraMotionVector: {fileID: 4800000, guid: c56b7e0d4c7cb484e959caeeedae9bbf,
type: 3}
objectMotionVector: {fileID: 4800000, guid: 7b3ede40266cd49a395def176e1bc486,
type: 3}
dataDrivenLensFlare: {fileID: 4800000, guid: 6cda457ac28612740adb23da5d39ea92,
type: 3}
m_AssetVersion: 2
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 2
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_DepthPrimingMode: 0
m_CopyDepthMode: 0
m_AccurateGbufferNormals: 0
m_IntermediateTextureMode: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c40be3174f62c4acf8c1216858c64956
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
%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: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-HighFidelity
m_EditorClassIdentifier:
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: c40be3174f62c4acf8c1216858c64956, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 4
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 4096
m_AdditionalLightsRenderingMode: 1
m_AdditionalLightsPerObjectLimit: 8
m_AdditionalLightShadowsSupported: 1
m_AdditionalLightsShadowmapResolution: 4096
m_AdditionalLightsShadowResolutionTierLow: 128
m_AdditionalLightsShadowResolutionTierMedium: 256
m_AdditionalLightsShadowResolutionTierHigh: 512
m_ReflectionProbeBlending: 1
m_ReflectionProbeBoxProjection: 1
m_ShadowDistance: 150
m_ShadowCascadeCount: 4
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 1
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 4096
m_AdditionalLightsCookieFormat: 4
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 32
m_UseFastSRGBLinearConversion: 0
m_SupportDataDrivenLensFlare: 1
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 3
m_PrefilteringModeAdditionalLight: 3
m_PrefilteringModeAdditionalLightShadows: 2
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeScreenSpaceOcclusion: 2
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1
m_PrefilterHDROutput: 1
m_PrefilterSSAODepthNormals: 0
m_PrefilterSSAOSourceDepthLow: 1
m_PrefilterSSAOSourceDepthMedium: 1
m_PrefilterSSAOSourceDepthHigh: 1
m_PrefilterSSAOInterleaved: 0
m_PrefilterSSAOBlueNoise: 1
m_PrefilterSSAOSampleCountLow: 1
m_PrefilterSSAOSampleCountMedium: 1
m_PrefilterSSAOSampleCountHigh: 0
m_PrefilterDBufferMRT1: 1
m_PrefilterDBufferMRT2: 1
m_PrefilterDBufferMRT3: 1
m_PrefilterSoftShadowsQualityLow: 1
m_PrefilterSoftShadowsQualityMedium: 1
m_PrefilterSoftShadowsQualityHigh: 1
m_PrefilterSoftShadows: 0
m_PrefilterScreenCoord: 1
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7b7fd9122c28c4d15b667c7040e3b3fd
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,52 @@
%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: de640fe3d0db1804a85f9fc8f5cadab6, type: 3}
m_Name: URP-Performant-Renderer
m_EditorClassIdentifier:
debugShaders:
debugReplacementPS: {fileID: 4800000, guid: cf852408f2e174538bcd9b7fda1c5ae7,
type: 3}
m_RendererFeatures: []
m_RendererFeatureMap:
m_UseNativeRenderPass: 0
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
shaders:
blitPS: {fileID: 4800000, guid: c17132b1f77d20942aa75f8429c0f8bc, type: 3}
copyDepthPS: {fileID: 4800000, guid: d6dae50ee9e1bfa4db75f19f99355220, type: 3}
screenSpaceShadowPS: {fileID: 0}
samplingPS: {fileID: 4800000, guid: 04c410c9937594faa893a11dceb85f7e, type: 3}
stencilDeferredPS: {fileID: 4800000, guid: e9155b26e1bc55942a41e518703fe304, type: 3}
fallbackErrorPS: {fileID: 4800000, guid: e6e9a19c3678ded42a3bc431ebef7dbd, type: 3}
materialErrorPS: {fileID: 4800000, guid: 5fd9a8feb75a4b5894c241777f519d4e, type: 3}
coreBlitPS: {fileID: 0}
coreBlitColorAndDepthPS: {fileID: 0}
cameraMotionVector: {fileID: 0}
objectMotionVector: {fileID: 0}
m_OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_TransparentLayerMask:
serializedVersion: 2
m_Bits: 4294967295
m_DefaultStencilState:
overrideStencilState: 0
stencilReference: 0
stencilCompareFunction: 8
passOperation: 2
failOperation: 0
zFailOperation: 0
m_ShadowTransparentReceive: 1
m_RenderingMode: 0
m_DepthPrimingMode: 0
m_AccurateGbufferNormals: 0
m_ClusteredRendering: 0
m_TileSize: 32

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 707360a9c581a4bd7aa53bfeb1429f71
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,114 @@
%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: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: URP-Performant
m_EditorClassIdentifier:
k_AssetVersion: 11
k_AssetPreviousVersion: 11
m_RendererType: 1
m_RendererData: {fileID: 0}
m_RendererDataList:
- {fileID: 11400000, guid: 707360a9c581a4bd7aa53bfeb1429f71, type: 2}
m_DefaultRendererIndex: 0
m_RequireDepthTexture: 0
m_RequireOpaqueTexture: 0
m_OpaqueDownsampling: 1
m_SupportsTerrainHoles: 1
m_SupportsHDR: 0
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 1
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 0
m_FsrSharpness: 0.92
m_EnableLODCrossFade: 1
m_LODCrossFadeDitheringType: 1
m_ShEvalMode: 0
m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 0
m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 0
m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 512
m_AdditionalLightsShadowResolutionTierLow: 128
m_AdditionalLightsShadowResolutionTierMedium: 256
m_AdditionalLightsShadowResolutionTierHigh: 512
m_ReflectionProbeBlending: 0
m_ReflectionProbeBoxProjection: 0
m_ShadowDistance: 50
m_ShadowCascadeCount: 1
m_Cascade2Split: 0.25
m_Cascade3Split: {x: 0.1, y: 0.3}
m_Cascade4Split: {x: 0.067, y: 0.2, z: 0.467}
m_CascadeBorder: 0.1
m_ShadowDepthBias: 1
m_ShadowNormalBias: 1
m_AnyShadowsSupported: 1
m_SoftShadowsSupported: 0
m_ConservativeEnclosingSphere: 0
m_NumIterationsEnclosingSphere: 64
m_SoftShadowQuality: 2
m_AdditionalLightsCookieResolution: 2048
m_AdditionalLightsCookieFormat: 3
m_UseSRPBatcher: 1
m_SupportsDynamicBatching: 0
m_MixedLightingSupported: 1
m_SupportsLightCookies: 1
m_SupportsLightLayers: 0
m_DebugLevel: 0
m_StoreActionsOptimization: 0
m_EnableRenderGraph: 0
m_UseAdaptivePerformance: 1
m_ColorGradingMode: 0
m_ColorGradingLutSize: 16
m_UseFastSRGBLinearConversion: 0
m_SupportDataDrivenLensFlare: 1
m_ShadowType: 1
m_LocalShadowsSupported: 0
m_LocalShadowsAtlasResolution: 256
m_MaxPixelLights: 0
m_ShadowAtlasResolution: 256
m_VolumeFrameworkUpdateMode: 0
m_Textures:
blueNoise64LTex: {fileID: 2800000, guid: e3d24661c1e055f45a7560c033dbb837, type: 3}
bayerMatrixTex: {fileID: 2800000, guid: f9ee4ed84c1d10c49aabb9b210b0fc44, type: 3}
m_PrefilteringModeMainLightShadows: 0
m_PrefilteringModeAdditionalLight: 0
m_PrefilteringModeAdditionalLightShadows: 0
m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeScreenSpaceOcclusion: 0
m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1
m_PrefilterHDROutput: 1
m_PrefilterSSAODepthNormals: 1
m_PrefilterSSAOSourceDepthLow: 1
m_PrefilterSSAOSourceDepthMedium: 1
m_PrefilterSSAOSourceDepthHigh: 1
m_PrefilterSSAOInterleaved: 1
m_PrefilterSSAOBlueNoise: 1
m_PrefilterSSAOSampleCountLow: 1
m_PrefilterSSAOSampleCountMedium: 1
m_PrefilterSSAOSampleCountHigh: 1
m_PrefilterDBufferMRT1: 1
m_PrefilterDBufferMRT2: 1
m_PrefilterDBufferMRT3: 1
m_PrefilterSoftShadowsQualityLow: 1
m_PrefilterSoftShadowsQualityMedium: 1
m_PrefilterSoftShadowsQualityHigh: 1
m_PrefilterSoftShadows: 0
m_PrefilterScreenCoord: 1
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d0e2fc18fe036412f8223b3b3d9ad574
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
%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: 2ec995e51a6e251468d2a3fd8a686257, type: 3}
m_Name: UniversalRenderPipelineGlobalSettings
m_EditorClassIdentifier:
k_AssetVersion: 3
m_RenderingLayerNames:
- Light Layer default
- Light Layer 1
- Light Layer 2
- Light Layer 3
- Light Layer 4
- Light Layer 5
- Light Layer 6
- Light Layer 7
m_ValidRenderingLayers: 255
lightLayerName0: Light Layer default
lightLayerName1: Light Layer 1
lightLayerName2: Light Layer 2
lightLayerName3: Light Layer 3
lightLayerName4: Light Layer 4
lightLayerName5: Light Layer 5
lightLayerName6: Light Layer 6
lightLayerName7: Light Layer 7
m_StripDebugVariants: 1
m_StripUnusedPostProcessingVariants: 1
m_StripUnusedVariants: 1
m_StripUnusedLODCrossFadeVariants: 1
m_StripScreenCoordOverrideVariants: 1
supportRuntimeDebugDisplay: 0
m_ShaderVariantLogLevel: 0
m_ExportShaderVariants: 1

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 18dc0cd2c080841dea60987a38ce93fa
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ddfa0c1d1c36b4079848d61bac0913ff
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 03a65c11b1b2d4d068764ce890d18383
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: c1a485995f7ae9f45aa14f7874080d34
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7cfdf311c08fcd5459adad944e39452a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
namespace UniRx
{
public static class WebRequestExtensions
{
static IObservable<TResult> AbortableDeferredAsyncRequest<TResult>(Func<AsyncCallback, object, IAsyncResult> begin, Func<IAsyncResult, TResult> end, WebRequest request)
{
var result = Observable.Create<TResult>(observer =>
{
var isCompleted = -1;
var subscription = Observable.FromAsyncPattern<TResult>(begin,
ar =>
{
try
{
Interlocked.Increment(ref isCompleted);
return end(ar);
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.RequestCanceled) return default(TResult);
throw;
}
})()
.Subscribe(observer);
return Disposable.Create(() =>
{
if (Interlocked.Increment(ref isCompleted) == 0)
{
subscription.Dispose();
request.Abort();
}
});
});
return result;
}
public static IObservable<WebResponse> GetResponseAsObservable(this WebRequest request)
{
return AbortableDeferredAsyncRequest<WebResponse>(request.BeginGetResponse, request.EndGetResponse, request);
}
public static IObservable<HttpWebResponse> GetResponseAsObservable(this HttpWebRequest request)
{
return AbortableDeferredAsyncRequest<HttpWebResponse>(request.BeginGetResponse, ar => (HttpWebResponse)request.EndGetResponse(ar), request);
}
public static IObservable<Stream> GetRequestStreamAsObservable(this WebRequest request)
{
return AbortableDeferredAsyncRequest<Stream>(request.BeginGetRequestStream, request.EndGetRequestStream, request);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b32bc36ffafee2342a895ebfd43fa0e7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f7ab5087ac844a04bb7da6cc0f2eb761
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
namespace UniRx
{
public sealed class BooleanDisposable : IDisposable, ICancelable
{
public bool IsDisposed { get; private set; }
public BooleanDisposable()
{
}
internal BooleanDisposable(bool isDisposed)
{
IsDisposed = isDisposed;
}
public void Dispose()
{
if (!IsDisposed) IsDisposed = true;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f1639b500ad3cea44a609ead03d0ad56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
// original code from GitHub Reactive-Extensions/Rx.NET
// some modified.
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
#if (NETFX_CORE || NET_4_6 || NET_STANDARD_2_0 || UNITY_WSA_10_0)
using System;
using System.Threading;
namespace UniRx
{
/// <summary>
/// Represents a disposable resource that has an associated <seealso cref="T:System.Threading.CancellationToken"/> that will be set to the cancellation requested state upon disposal.
/// </summary>
public sealed class CancellationDisposable : ICancelable
{
private readonly CancellationTokenSource _cts;
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CancellationDisposable"/> class that uses an existing <seealso cref="T:System.Threading.CancellationTokenSource"/>.
/// </summary>
/// <param name="cts"><seealso cref="T:System.Threading.CancellationTokenSource"/> used for cancellation.</param>
/// <exception cref="ArgumentNullException"><paramref name="cts"/> is null.</exception>
public CancellationDisposable(CancellationTokenSource cts)
{
if (cts == null)
throw new ArgumentNullException("cts");
_cts = cts;
}
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CancellationDisposable"/> class that uses a new <seealso cref="T:System.Threading.CancellationTokenSource"/>.
/// </summary>
public CancellationDisposable()
: this(new CancellationTokenSource())
{
}
/// <summary>
/// Gets the <see cref="T:System.Threading.CancellationToken"/> used by this CancellationDisposable.
/// </summary>
public CancellationToken Token
{
get { return _cts.Token; }
}
/// <summary>
/// Cancels the underlying <seealso cref="T:System.Threading.CancellationTokenSource"/>.
/// </summary>
public void Dispose()
{
_cts.Cancel();
}
/// <summary>
/// Gets a value that indicates whether the object is disposed.
/// </summary>
public bool IsDisposed
{
get { return _cts.IsCancellationRequested; }
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 796d45b99da58ae46b2e2bdef9ac889f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,283 @@
using System;
using System.Collections.Generic;
// using System.Linq; do not use LINQ
using System.Text;
namespace UniRx
{
// copy, modified from Rx Official
public sealed class CompositeDisposable : ICollection<IDisposable>, IDisposable, ICancelable
{
private readonly object _gate = new object();
private bool _disposed;
private List<IDisposable> _disposables;
private int _count;
private const int SHRINK_THRESHOLD = 64;
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CompositeDisposable"/> class with no disposables contained by it initially.
/// </summary>
public CompositeDisposable()
{
_disposables = new List<IDisposable>();
}
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CompositeDisposable"/> class with the specified number of disposables.
/// </summary>
/// <param name="capacity">The number of disposables that the new CompositeDisposable can initially store.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than zero.</exception>
public CompositeDisposable(int capacity)
{
if (capacity < 0)
throw new ArgumentOutOfRangeException("capacity");
_disposables = new List<IDisposable>(capacity);
}
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CompositeDisposable"/> class from a group of disposables.
/// </summary>
/// <param name="disposables">Disposables that will be disposed together.</param>
/// <exception cref="ArgumentNullException"><paramref name="disposables"/> is null.</exception>
public CompositeDisposable(params IDisposable[] disposables)
{
if (disposables == null)
throw new ArgumentNullException("disposables");
_disposables = new List<IDisposable>(disposables);
_count = _disposables.Count;
}
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.CompositeDisposable"/> class from a group of disposables.
/// </summary>
/// <param name="disposables">Disposables that will be disposed together.</param>
/// <exception cref="ArgumentNullException"><paramref name="disposables"/> is null.</exception>
public CompositeDisposable(IEnumerable<IDisposable> disposables)
{
if (disposables == null)
throw new ArgumentNullException("disposables");
_disposables = new List<IDisposable>(disposables);
_count = _disposables.Count;
}
/// <summary>
/// Gets the number of disposables contained in the CompositeDisposable.
/// </summary>
public int Count
{
get
{
return _count;
}
}
/// <summary>
/// Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
/// </summary>
/// <param name="item">Disposable to add.</param>
/// <exception cref="ArgumentNullException"><paramref name="item"/> is null.</exception>
public void Add(IDisposable item)
{
if (item == null)
throw new ArgumentNullException("item");
var shouldDispose = false;
lock (_gate)
{
shouldDispose = _disposed;
if (!_disposed)
{
_disposables.Add(item);
_count++;
}
}
if (shouldDispose)
item.Dispose();
}
/// <summary>
/// Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
/// </summary>
/// <param name="item">Disposable to remove.</param>
/// <returns>true if found; false otherwise.</returns>
/// <exception cref="ArgumentNullException"><paramref name="item"/> is null.</exception>
public bool Remove(IDisposable item)
{
if (item == null)
throw new ArgumentNullException("item");
var shouldDispose = false;
lock (_gate)
{
if (!_disposed)
{
//
// List<T> doesn't shrink the size of the underlying array but does collapse the array
// by copying the tail one position to the left of the removal index. We don't need
// index-based lookup but only ordering for sequential disposal. So, instead of spending
// cycles on the Array.Copy imposed by Remove, we use a null sentinel value. We also
// do manual Swiss cheese detection to shrink the list if there's a lot of holes in it.
//
var i = _disposables.IndexOf(item);
if (i >= 0)
{
shouldDispose = true;
_disposables[i] = null;
_count--;
if (_disposables.Capacity > SHRINK_THRESHOLD && _count < _disposables.Capacity / 2)
{
var old = _disposables;
_disposables = new List<IDisposable>(_disposables.Capacity / 2);
foreach (var d in old)
if (d != null)
_disposables.Add(d);
}
}
}
}
if (shouldDispose)
item.Dispose();
return shouldDispose;
}
/// <summary>
/// Disposes all disposables in the group and removes them from the group.
/// </summary>
public void Dispose()
{
var currentDisposables = default(IDisposable[]);
lock (_gate)
{
if (!_disposed)
{
_disposed = true;
currentDisposables = _disposables.ToArray();
_disposables.Clear();
_count = 0;
}
}
if (currentDisposables != null)
{
foreach (var d in currentDisposables)
if (d != null)
d.Dispose();
}
}
/// <summary>
/// Removes and disposes all disposables from the CompositeDisposable, but does not dispose the CompositeDisposable.
/// </summary>
public void Clear()
{
var currentDisposables = default(IDisposable[]);
lock (_gate)
{
currentDisposables = _disposables.ToArray();
_disposables.Clear();
_count = 0;
}
foreach (var d in currentDisposables)
if (d != null)
d.Dispose();
}
/// <summary>
/// Determines whether the CompositeDisposable contains a specific disposable.
/// </summary>
/// <param name="item">Disposable to search for.</param>
/// <returns>true if the disposable was found; otherwise, false.</returns>
/// <exception cref="ArgumentNullException"><paramref name="item"/> is null.</exception>
public bool Contains(IDisposable item)
{
if (item == null)
throw new ArgumentNullException("item");
lock (_gate)
{
return _disposables.Contains(item);
}
}
/// <summary>
/// Copies the disposables contained in the CompositeDisposable to an array, starting at a particular array index.
/// </summary>
/// <param name="array">Array to copy the contained disposables to.</param>
/// <param name="arrayIndex">Target index at which to copy the first disposable of the group.</param>
/// <exception cref="ArgumentNullException"><paramref name="array"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="arrayIndex"/> is less than zero. -or - <paramref name="arrayIndex"/> is larger than or equal to the array length.</exception>
public void CopyTo(IDisposable[] array, int arrayIndex)
{
if (array == null)
throw new ArgumentNullException("array");
if (arrayIndex < 0 || arrayIndex >= array.Length)
throw new ArgumentOutOfRangeException("arrayIndex");
lock (_gate)
{
var disArray = new List<IDisposable>();
foreach (var item in _disposables)
{
if (item != null) disArray.Add(item);
}
Array.Copy(disArray.ToArray(), 0, array, arrayIndex, array.Length - arrayIndex);
}
}
/// <summary>
/// Always returns false.
/// </summary>
public bool IsReadOnly
{
get { return false; }
}
/// <summary>
/// Returns an enumerator that iterates through the CompositeDisposable.
/// </summary>
/// <returns>An enumerator to iterate over the disposables.</returns>
public IEnumerator<IDisposable> GetEnumerator()
{
var res = new List<IDisposable>();
lock (_gate)
{
foreach (var d in _disposables)
{
if (d != null) res.Add(d);
}
}
return res.GetEnumerator();
}
/// <summary>
/// Returns an enumerator that iterates through the CompositeDisposable.
/// </summary>
/// <returns>An enumerator to iterate over the disposables.</returns>
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
/// <summary>
/// Gets a value that indicates whether the object is disposed.
/// </summary>
public bool IsDisposed
{
get { return _disposed; }
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 04ab3effbee4a2d4eb4079f283ed4ac9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,255 @@
using System;
using System.Collections.Generic;
namespace UniRx
{
public sealed class DictionaryDisposable<TKey, TValue> : IDisposable, IDictionary<TKey, TValue>
where TValue : IDisposable
{
bool isDisposed = false;
readonly Dictionary<TKey, TValue> inner;
public DictionaryDisposable()
{
inner = new Dictionary<TKey, TValue>();
}
public DictionaryDisposable(IEqualityComparer<TKey> comparer)
{
inner = new Dictionary<TKey, TValue>(comparer);
}
public TValue this[TKey key]
{
get
{
lock (inner)
{
return inner[key];
}
}
set
{
lock (inner)
{
if (isDisposed) value.Dispose();
TValue oldValue;
if (TryGetValue(key, out oldValue))
{
oldValue.Dispose();
inner[key] = value;
}
else
{
inner[key] = value;
}
}
}
}
public int Count
{
get
{
lock (inner)
{
return inner.Count;
}
}
}
public Dictionary<TKey, TValue>.KeyCollection Keys
{
get
{
throw new NotSupportedException("please use .Select(x => x.Key).ToArray()");
}
}
public Dictionary<TKey, TValue>.ValueCollection Values
{
get
{
throw new NotSupportedException("please use .Select(x => x.Value).ToArray()");
}
}
public void Add(TKey key, TValue value)
{
lock (inner)
{
if (isDisposed)
{
value.Dispose();
return;
}
inner.Add(key, value);
}
}
public void Clear()
{
lock (inner)
{
foreach (var item in inner)
{
item.Value.Dispose();
}
inner.Clear();
}
}
public bool Remove(TKey key)
{
lock (inner)
{
TValue oldValue;
if (inner.TryGetValue(key, out oldValue))
{
var isSuccessRemove = inner.Remove(key);
if (isSuccessRemove)
{
oldValue.Dispose();
}
return isSuccessRemove;
}
else
{
return false;
}
}
}
public bool ContainsKey(TKey key)
{
lock (inner)
{
return inner.ContainsKey(key);
}
}
public bool TryGetValue(TKey key, out TValue value)
{
lock (inner)
{
return inner.TryGetValue(key, out value);
}
}
public Dictionary<TKey, TValue>.Enumerator GetEnumerator()
{
lock (inner)
{
return new Dictionary<TKey, TValue>(inner).GetEnumerator();
}
}
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
{
get
{
return ((ICollection<KeyValuePair<TKey, TValue>>)inner).IsReadOnly;
}
}
ICollection<TKey> IDictionary<TKey, TValue>.Keys
{
get
{
lock (inner)
{
return new List<TKey>(inner.Keys);
}
}
}
ICollection<TValue> IDictionary<TKey, TValue>.Values
{
get
{
lock (inner)
{
return new List<TValue>(inner.Values);
}
}
}
#if !UNITY_METRO
public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
{
lock (inner)
{
((System.Runtime.Serialization.ISerializable)inner).GetObjectData(info, context);
}
}
public void OnDeserialization(object sender)
{
lock (inner)
{
((System.Runtime.Serialization.IDeserializationCallback)inner).OnDeserialization(sender);
}
}
#endif
void ICollection<KeyValuePair<TKey, TValue>>.Add(KeyValuePair<TKey, TValue> item)
{
Add((TKey)item.Key, (TValue)item.Value);
}
bool ICollection<KeyValuePair<TKey, TValue>>.Contains(KeyValuePair<TKey, TValue> item)
{
lock (inner)
{
return ((ICollection<KeyValuePair<TKey, TValue>>)inner).Contains(item);
}
}
void ICollection<KeyValuePair<TKey, TValue>>.CopyTo(KeyValuePair<TKey, TValue>[] array, int arrayIndex)
{
lock (inner)
{
((ICollection<KeyValuePair<TKey, TValue>>)inner).CopyTo(array, arrayIndex);
}
}
IEnumerator<KeyValuePair<TKey, TValue>> IEnumerable<KeyValuePair<TKey, TValue>>.GetEnumerator()
{
lock (inner)
{
return new List<KeyValuePair<TKey, TValue>>((ICollection<KeyValuePair<TKey, TValue>>)inner).GetEnumerator();
}
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
bool ICollection<KeyValuePair<TKey, TValue>>.Remove(KeyValuePair<TKey, TValue> item)
{
throw new NotSupportedException();
}
public void Dispose()
{
lock (inner)
{
if (isDisposed) return;
isDisposed = true;
foreach (var item in inner)
{
item.Value.Dispose();
}
inner.Clear();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3bd99b5ea3dc83d479d8413e94e77159
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
using System;
using System.Collections;
namespace UniRx
{
public static class Disposable
{
public static readonly IDisposable Empty = EmptyDisposable.Singleton;
public static IDisposable Create(Action disposeAction)
{
return new AnonymousDisposable(disposeAction);
}
public static IDisposable CreateWithState<TState>(TState state, Action<TState> disposeAction)
{
return new AnonymousDisposable<TState>(state, disposeAction);
}
class EmptyDisposable : IDisposable
{
public static EmptyDisposable Singleton = new EmptyDisposable();
private EmptyDisposable()
{
}
public void Dispose()
{
}
}
class AnonymousDisposable : IDisposable
{
bool isDisposed = false;
readonly Action dispose;
public AnonymousDisposable(Action dispose)
{
this.dispose = dispose;
}
public void Dispose()
{
if (!isDisposed)
{
isDisposed = true;
dispose();
}
}
}
class AnonymousDisposable<T> : IDisposable
{
bool isDisposed = false;
readonly T state;
readonly Action<T> dispose;
public AnonymousDisposable(T state, Action<T> dispose)
{
this.state = state;
this.dispose = dispose;
}
public void Dispose()
{
if (!isDisposed)
{
isDisposed = true;
dispose(state);
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 41d179cab7c844849a4c63f2f76371c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
namespace UniRx
{
public static partial class DisposableExtensions
{
/// <summary>Add disposable(self) to CompositeDisposable(or other ICollection). Return value is self disposable.</summary>
public static T AddTo<T>(this T disposable, ICollection<IDisposable> container)
where T : IDisposable
{
if (disposable == null) throw new ArgumentNullException("disposable");
if (container == null) throw new ArgumentNullException("container");
container.Add(disposable);
return disposable;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 816274acd0af18844a228abec3685469
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UniRx
{
public interface ICancelable : IDisposable
{
bool IsDisposed { get; }
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bbee67f7b044bd649a7a2d55a036bc3c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections;
namespace UniRx
{
public sealed class MultipleAssignmentDisposable : IDisposable, ICancelable
{
static readonly BooleanDisposable True = new BooleanDisposable(true);
object gate = new object();
IDisposable current;
public bool IsDisposed
{
get
{
lock (gate)
{
return current == True;
}
}
}
public IDisposable Disposable
{
get
{
lock (gate)
{
return (current == True)
? UniRx.Disposable.Empty
: current;
}
}
set
{
var shouldDispose = false;
lock (gate)
{
shouldDispose = (current == True);
if (!shouldDispose)
{
current = value;
}
}
if (shouldDispose && value != null)
{
value.Dispose();
}
}
}
public void Dispose()
{
IDisposable old = null;
lock (gate)
{
if (current != True)
{
old = current;
current = True;
}
}
if (old != null) old.Dispose();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ea1b74f112baf4945a063577517fd5b3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,152 @@
// This code is borrwed from Rx Official and some modified.
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace UniRx
{
/// <summary>
/// Represents a disposable resource that only disposes its underlying disposable resource when all <see cref="GetDisposable">dependent disposable objects</see> have been disposed.
/// </summary>
public sealed class RefCountDisposable : ICancelable
{
private readonly object _gate = new object();
private IDisposable _disposable;
private bool _isPrimaryDisposed;
private int _count;
/// <summary>
/// Initializes a new instance of the <see cref="T:System.Reactive.Disposables.RefCountDisposable"/> class with the specified disposable.
/// </summary>
/// <param name="disposable">Underlying disposable.</param>
/// <exception cref="ArgumentNullException"><paramref name="disposable"/> is null.</exception>
public RefCountDisposable(IDisposable disposable)
{
if (disposable == null)
throw new ArgumentNullException("disposable");
_disposable = disposable;
_isPrimaryDisposed = false;
_count = 0;
}
/// <summary>
/// Gets a value that indicates whether the object is disposed.
/// </summary>
public bool IsDisposed
{
get { return _disposable == null; }
}
/// <summary>
/// Returns a dependent disposable that when disposed decreases the refcount on the underlying disposable.
/// </summary>
/// <returns>A dependent disposable contributing to the reference count that manages the underlying disposable's lifetime.</returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", Justification = "Backward compat + non-trivial work for a property getter.")]
public IDisposable GetDisposable()
{
lock (_gate)
{
if (_disposable == null)
{
return Disposable.Empty;
}
else
{
_count++;
return new InnerDisposable(this);
}
}
}
/// <summary>
/// Disposes the underlying disposable only when all dependent disposables have been disposed.
/// </summary>
public void Dispose()
{
var disposable = default(IDisposable);
lock (_gate)
{
if (_disposable != null)
{
if (!_isPrimaryDisposed)
{
_isPrimaryDisposed = true;
if (_count == 0)
{
disposable = _disposable;
_disposable = null;
}
}
}
}
if (disposable != null)
disposable.Dispose();
}
private void Release()
{
var disposable = default(IDisposable);
lock (_gate)
{
if (_disposable != null)
{
_count--;
if (_isPrimaryDisposed)
{
if (_count == 0)
{
disposable = _disposable;
_disposable = null;
}
}
}
}
if (disposable != null)
disposable.Dispose();
}
sealed class InnerDisposable : IDisposable
{
private RefCountDisposable _parent;
object parentLock = new object();
public InnerDisposable(RefCountDisposable parent)
{
_parent = parent;
}
public void Dispose()
{
RefCountDisposable parent;
lock (parentLock)
{
parent = _parent;
_parent = null;
}
if (parent != null)
parent.Release();
}
}
}
public partial class Observable
{
static IObservable<T> AddRef<T>(IObservable<T> xs, RefCountDisposable r)
{
return Observable.Create<T>((IObserver<T> observer) => new CompositeDisposable(new IDisposable[]
{
r.GetDisposable(),
xs.Subscribe(observer)
}));
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 83dbb734c17948847a172cec99890c20
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using System;
using System.Threading;
namespace UniRx
{
public sealed class ScheduledDisposable : ICancelable
{
private readonly IScheduler scheduler;
private volatile IDisposable disposable;
private int isDisposed = 0;
public ScheduledDisposable(IScheduler scheduler, IDisposable disposable)
{
this.scheduler = scheduler;
this.disposable = disposable;
}
public IScheduler Scheduler
{
get { return scheduler; }
}
public IDisposable Disposable
{
get { return disposable; }
}
public bool IsDisposed
{
get { return isDisposed != 0; }
}
public void Dispose()
{
Scheduler.Schedule(DisposeInner);
}
private void DisposeInner()
{
if (Interlocked.Increment(ref isDisposed) == 1)
{
disposable.Dispose();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a30e192f18379d24da9371a6e2088eb7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections;
namespace UniRx
{
public sealed class SerialDisposable : IDisposable, ICancelable
{
readonly object gate = new object();
IDisposable current;
bool disposed;
public bool IsDisposed { get { lock (gate) { return disposed; } } }
public IDisposable Disposable
{
get
{
return current;
}
set
{
var shouldDispose = false;
var old = default(IDisposable);
lock (gate)
{
shouldDispose = disposed;
if (!shouldDispose)
{
old = current;
current = value;
}
}
if (old != null)
{
old.Dispose();
}
if (shouldDispose && value != null)
{
value.Dispose();
}
}
}
public void Dispose()
{
var old = default(IDisposable);
lock (gate)
{
if (!disposed)
{
disposed = true;
old = current;
current = null;
}
}
if (old != null)
{
old.Dispose();
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0da8c2f0bc2da484eaba771c7bfd1408
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections;
namespace UniRx
{
// should be use Interlocked.CompareExchange for Threadsafe?
// but CompareExchange cause ExecutionEngineException on iOS.
// AOT...
// use lock instead
public sealed class SingleAssignmentDisposable : IDisposable, ICancelable
{
readonly object gate = new object();
IDisposable current;
bool disposed;
public bool IsDisposed { get { lock (gate) { return disposed; } } }
public IDisposable Disposable
{
get
{
return current;
}
set
{
var old = default(IDisposable);
bool alreadyDisposed;
lock (gate)
{
alreadyDisposed = disposed;
old = current;
if (!alreadyDisposed)
{
if (value == null) return;
current = value;
}
}
if (alreadyDisposed && value != null)
{
value.Dispose();
return;
}
if (old != null) throw new InvalidOperationException("Disposable is already set");
}
}
public void Dispose()
{
IDisposable old = null;
lock (gate)
{
if (!disposed)
{
disposed = true;
old = current;
current = null;
}
}
if (old != null) old.Dispose();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ededd3033b89fd240ae9533d76102b0a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,277 @@
using System;
using System.Collections.Generic;
using System.Threading;
namespace UniRx
{
/// <summary>
/// Represents a group of disposable resources that are disposed together.
/// </summary>
public abstract class StableCompositeDisposable : ICancelable
{
/// <summary>
/// Creates a new group containing two disposable resources that are disposed together.
/// </summary>
/// <param name="disposable1">The first disposable resoruce to add to the group.</param>
/// <param name="disposable2">The second disposable resoruce to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable Create(IDisposable disposable1, IDisposable disposable2)
{
if (disposable1 == null) throw new ArgumentNullException("disposable1");
if (disposable2 == null) throw new ArgumentNullException("disposable2");
return new Binary(disposable1, disposable2);
}
/// <summary>
/// Creates a new group containing three disposable resources that are disposed together.
/// </summary>
/// <param name="disposable1">The first disposable resoruce to add to the group.</param>
/// <param name="disposable2">The second disposable resoruce to add to the group.</param>
/// <param name="disposable3">The third disposable resoruce to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable Create(IDisposable disposable1, IDisposable disposable2, IDisposable disposable3)
{
if (disposable1 == null) throw new ArgumentNullException("disposable1");
if (disposable2 == null) throw new ArgumentNullException("disposable2");
if (disposable3 == null) throw new ArgumentNullException("disposable3");
return new Trinary(disposable1, disposable2, disposable3);
}
/// <summary>
/// Creates a new group containing four disposable resources that are disposed together.
/// </summary>
/// <param name="disposable1">The first disposable resoruce to add to the group.</param>
/// <param name="disposable2">The second disposable resoruce to add to the group.</param>
/// <param name="disposable3">The three disposable resoruce to add to the group.</param>
/// <param name="disposable4">The four disposable resoruce to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable Create(IDisposable disposable1, IDisposable disposable2, IDisposable disposable3, IDisposable disposable4)
{
if (disposable1 == null) throw new ArgumentNullException("disposable1");
if (disposable2 == null) throw new ArgumentNullException("disposable2");
if (disposable3 == null) throw new ArgumentNullException("disposable3");
if (disposable4 == null) throw new ArgumentNullException("disposable4");
return new Quaternary(disposable1, disposable2, disposable3, disposable4);
}
/// <summary>
/// Creates a new group of disposable resources that are disposed together.
/// </summary>
/// <param name="disposables">Disposable resources to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable Create(params IDisposable[] disposables)
{
if (disposables == null) throw new ArgumentNullException("disposables");
return new NAry(disposables);
}
/// <summary>
/// Creates a new group of disposable resources that are disposed together. Array is not copied, it's unsafe but optimized.
/// </summary>
/// <param name="disposables">Disposable resources to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable CreateUnsafe(IDisposable[] disposables)
{
return new NAryUnsafe(disposables);
}
/// <summary>
/// Creates a new group of disposable resources that are disposed together.
/// </summary>
/// <param name="disposables">Disposable resources to add to the group.</param>
/// <returns>Group of disposable resources that are disposed together.</returns>
public static ICancelable Create(IEnumerable<IDisposable> disposables)
{
if (disposables == null) throw new ArgumentNullException("disposables");
return new NAry(disposables);
}
/// <summary>
/// Disposes all disposables in the group.
/// </summary>
public abstract void Dispose();
/// <summary>
/// Gets a value that indicates whether the object is disposed.
/// </summary>
public abstract bool IsDisposed
{
get;
}
class Binary : StableCompositeDisposable
{
int disposedCallCount = -1;
private volatile IDisposable _disposable1;
private volatile IDisposable _disposable2;
public Binary(IDisposable disposable1, IDisposable disposable2)
{
_disposable1 = disposable1;
_disposable2 = disposable2;
}
public override bool IsDisposed
{
get
{
return disposedCallCount != -1;
}
}
public override void Dispose()
{
if (Interlocked.Increment(ref disposedCallCount) == 0)
{
_disposable1.Dispose();
_disposable2.Dispose();
}
}
}
class Trinary : StableCompositeDisposable
{
int disposedCallCount = -1;
private volatile IDisposable _disposable1;
private volatile IDisposable _disposable2;
private volatile IDisposable _disposable3;
public Trinary(IDisposable disposable1, IDisposable disposable2, IDisposable disposable3)
{
_disposable1 = disposable1;
_disposable2 = disposable2;
_disposable3 = disposable3;
}
public override bool IsDisposed
{
get
{
return disposedCallCount != -1;
}
}
public override void Dispose()
{
if (Interlocked.Increment(ref disposedCallCount) == 0)
{
_disposable1.Dispose();
_disposable2.Dispose();
_disposable3.Dispose();
}
}
}
class Quaternary : StableCompositeDisposable
{
int disposedCallCount = -1;
private volatile IDisposable _disposable1;
private volatile IDisposable _disposable2;
private volatile IDisposable _disposable3;
private volatile IDisposable _disposable4;
public Quaternary(IDisposable disposable1, IDisposable disposable2, IDisposable disposable3, IDisposable disposable4)
{
_disposable1 = disposable1;
_disposable2 = disposable2;
_disposable3 = disposable3;
_disposable4 = disposable4;
}
public override bool IsDisposed
{
get
{
return disposedCallCount != -1;
}
}
public override void Dispose()
{
if (Interlocked.Increment(ref disposedCallCount) == 0)
{
_disposable1.Dispose();
_disposable2.Dispose();
_disposable3.Dispose();
_disposable4.Dispose();
}
}
}
class NAry : StableCompositeDisposable
{
int disposedCallCount = -1;
private volatile List<IDisposable> _disposables;
public NAry(IDisposable[] disposables)
: this((IEnumerable<IDisposable>)disposables)
{
}
public NAry(IEnumerable<IDisposable> disposables)
{
_disposables = new List<IDisposable>(disposables);
//
// Doing this on the list to avoid duplicate enumeration of disposables.
//
if (_disposables.Contains(null)) throw new ArgumentException("Disposables can't contains null", "disposables");
}
public override bool IsDisposed
{
get
{
return disposedCallCount != -1;
}
}
public override void Dispose()
{
if (Interlocked.Increment(ref disposedCallCount) == 0)
{
foreach (var d in _disposables)
{
d.Dispose();
}
}
}
}
class NAryUnsafe : StableCompositeDisposable
{
int disposedCallCount = -1;
private volatile IDisposable[] _disposables;
public NAryUnsafe(IDisposable[] disposables)
{
_disposables = disposables;
}
public override bool IsDisposed
{
get
{
return disposedCallCount != -1;
}
}
public override void Dispose()
{
if (Interlocked.Increment(ref disposedCallCount) == 0)
{
var len = _disposables.Length;
for (int i = 0; i < len; i++)
{
_disposables[i].Dispose();
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87575e8d144406c478700baa1aa225d2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,140 @@
// original code from rx.codeplex.com
// some modified.
/* ------------------ */
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace UniRx
{
/// <summary>
/// Represents a .NET event invocation consisting of the strongly typed object that raised the event and the data that was generated by the event.
/// </summary>
/// <typeparam name="TSender">
/// The type of the sender that raised the event.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TEventArgs">
/// The type of the event data generated by the event.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
public interface IEventPattern<TSender, TEventArgs>
{
/// <summary>
/// Gets the sender object that raised the event.
/// </summary>
TSender Sender { get; }
/// <summary>
/// Gets the event data that was generated by the event.
/// </summary>
TEventArgs EventArgs { get; }
}
/// <summary>
/// Represents a .NET event invocation consisting of the weakly typed object that raised the event and the data that was generated by the event.
/// </summary>
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
public class EventPattern<TEventArgs> : EventPattern<object, TEventArgs>
{
/// <summary>
/// Creates a new data representation instance of a .NET event invocation with the given sender and event data.
/// </summary>
/// <param name="sender">The sender object that raised the event.</param>
/// <param name="e">The event data that was generated by the event.</param>
public EventPattern(object sender, TEventArgs e)
: base(sender, e)
{
}
}
/// <summary>
/// Represents a .NET event invocation consisting of the strongly typed object that raised the event and the data that was generated by the event.
/// </summary>
/// <typeparam name="TSender">The type of the sender that raised the event.</typeparam>
/// <typeparam name="TEventArgs">The type of the event data generated by the event.</typeparam>
public class EventPattern<TSender, TEventArgs> : IEquatable<EventPattern<TSender, TEventArgs>>, IEventPattern<TSender, TEventArgs>
{
/// <summary>
/// Creates a new data representation instance of a .NET event invocation with the given sender and event data.
/// </summary>
/// <param name="sender">The sender object that raised the event.</param>
/// <param name="e">The event data that was generated by the event.</param>
public EventPattern(TSender sender, TEventArgs e)
{
Sender = sender;
EventArgs = e;
}
/// <summary>
/// Gets the sender object that raised the event.
/// </summary>
public TSender Sender { get; private set; }
/// <summary>
/// Gets the event data that was generated by the event.
/// </summary>
public TEventArgs EventArgs { get; private set; }
/// <summary>
/// Determines whether the current EventPattern&lt;TSender, TEventArgs&gt; object represents the same event as a specified EventPattern&lt;TSender, TEventArgs&gt; object.
/// </summary>
/// <param name="other">An object to compare to the current EventPattern&lt;TSender, TEventArgs&gt; object.</param>
/// <returns>true if both EventPattern&lt;TSender, TEventArgs&gt; objects represent the same event; otherwise, false.</returns>
public bool Equals(EventPattern<TSender, TEventArgs> other)
{
if (object.ReferenceEquals(null, other))
return false;
if (object.ReferenceEquals(this, other))
return true;
return EqualityComparer<TSender>.Default.Equals(Sender, other.Sender) && EqualityComparer<TEventArgs>.Default.Equals(EventArgs, other.EventArgs);
}
/// <summary>
/// Determines whether the specified System.Object is equal to the current EventPattern&lt;TSender, TEventArgs&gt;.
/// </summary>
/// <param name="obj">The System.Object to compare with the current EventPattern&lt;TSender, TEventArgs&gt;.</param>
/// <returns>true if the specified System.Object is equal to the current EventPattern&lt;TSender, TEventArgs&gt;; otherwise, false.</returns>
public override bool Equals(object obj)
{
return Equals(obj as EventPattern<TSender, TEventArgs>);
}
/// <summary>
/// Returns the hash code for the current EventPattern&lt;TSender, TEventArgs&gt; instance.
/// </summary>
/// <returns>A hash code for the current EventPattern&lt;TSender, TEventArgs&gt; instance.</returns>
public override int GetHashCode()
{
var x = EqualityComparer<TSender>.Default.GetHashCode(Sender);
var y = EqualityComparer<TEventArgs>.Default.GetHashCode(EventArgs);
return (x << 5) + (x ^ y);
}
/// <summary>
/// Determines whether two specified EventPattern&lt;TSender, TEventArgs&gt; objects represent the same event.
/// </summary>
/// <param name="first">The first EventPattern&lt;TSender, TEventArgs&gt; to compare, or null.</param>
/// <param name="second">The second EventPattern&lt;TSender, TEventArgs&gt; to compare, or null.</param>
/// <returns>true if both EventPattern&lt;TSender, TEventArgs&gt; objects represent the same event; otherwise, false.</returns>
public static bool operator ==(EventPattern<TSender, TEventArgs> first, EventPattern<TSender, TEventArgs> second)
{
return object.Equals(first, second);
}
/// <summary>
/// Determines whether two specified EventPattern&lt;TSender, TEventArgs&gt; objects represent a different event.
/// </summary>
/// <param name="first">The first EventPattern&lt;TSender, TEventArgs&gt; to compare, or null.</param>
/// <param name="second">The second EventPattern&lt;TSender, TEventArgs&gt; to compare, or null.</param>
/// <returns>true if both EventPattern&lt;TSender, TEventArgs&gt; objects don't represent the same event; otherwise, false.</returns>
public static bool operator !=(EventPattern<TSender, TEventArgs> first, EventPattern<TSender, TEventArgs> second)
{
return !object.Equals(first, second);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 96548d194b09dde4d9d771e372874e47
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8b666fb7768d9b34bbc79ebe40e78d20
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,85 @@
// this code is borrowed from RxOfficial(rx.codeplex.com) and modified
using System;
using System.Collections.Generic;
namespace UniRx.InternalUtil
{
/// <summary>
/// Asynchronous lock.
/// </summary>
internal sealed class AsyncLock : IDisposable
{
private readonly Queue<Action> queue = new Queue<Action>();
private bool isAcquired = false;
private bool hasFaulted = false;
/// <summary>
/// Queues the action for execution. If the caller acquires the lock and becomes the owner,
/// the queue is processed. If the lock is already owned, the action is queued and will get
/// processed by the owner.
/// </summary>
/// <param name="action">Action to queue for execution.</param>
/// <exception cref="ArgumentNullException"><paramref name="action"/> is null.</exception>
public void Wait(Action action)
{
if (action == null)
throw new ArgumentNullException("action");
var isOwner = false;
lock (queue)
{
if (!hasFaulted)
{
queue.Enqueue(action);
isOwner = !isAcquired;
isAcquired = true;
}
}
if (isOwner)
{
while (true)
{
var work = default(Action);
lock (queue)
{
if (queue.Count > 0)
work = queue.Dequeue();
else
{
isAcquired = false;
break;
}
}
try
{
work();
}
catch
{
lock (queue)
{
queue.Clear();
hasFaulted = true;
}
throw;
}
}
}
}
/// <summary>
/// Clears the work items in the queue and drops further work being queued.
/// </summary>
public void Dispose()
{
lock (queue)
{
queue.Clear();
hasFaulted = true;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6bc8abe896261614694a6d31dc527aaf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,23 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace UniRx.InternalUtil
{
internal interface ICancellableTaskCompletionSource
{
bool TrySetException(Exception exception);
bool TrySetCanceled();
}
internal class CancellableTaskCompletionSource<T> : TaskCompletionSource<T>, ICancellableTaskCompletionSource
{
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 690a59aad913fe044a00a03088d225f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
namespace UniRx.InternalUtil
{
using System;
internal static class ExceptionExtensions
{
public static void Throw(this Exception exception)
{
#if (NET_4_6 || NET_STANDARD_2_0)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Capture(exception).Throw();
#endif
throw exception;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b84b5b2683a4094da476b5a0c575a8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,61 @@
using System;
namespace UniRx.InternalUtil
{
// ImmutableList is sometimes useful, use for public.
public class ImmutableList<T>
{
public static readonly ImmutableList<T> Empty = new ImmutableList<T>();
T[] data;
public T[] Data
{
get { return data; }
}
ImmutableList()
{
data = new T[0];
}
public ImmutableList(T[] data)
{
this.data = data;
}
public ImmutableList<T> Add(T value)
{
var newData = new T[data.Length + 1];
Array.Copy(data, newData, data.Length);
newData[data.Length] = value;
return new ImmutableList<T>(newData);
}
public ImmutableList<T> Remove(T value)
{
var i = IndexOf(value);
if (i < 0) return this;
var length = data.Length;
if (length == 1) return Empty;
var newData = new T[length - 1];
Array.Copy(data, 0, newData, 0, i);
Array.Copy(data, i + 1, newData, i, length - i - 1);
return new ImmutableList<T>(newData);
}
public int IndexOf(T value)
{
for (var i = 0; i < data.Length; ++i)
{
// ImmutableList only use for IObserver(no worry for boxed)
if (object.Equals(data[i], value)) return i;
}
return -1;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d56c9f596d56bba4b8a87998ceab8bc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UniRx.InternalUtil
{
public class ListObserver<T> : IObserver<T>
{
private readonly ImmutableList<IObserver<T>> _observers;
public ListObserver(ImmutableList<IObserver<T>> observers)
{
_observers = observers;
}
public void OnCompleted()
{
var targetObservers = _observers.Data;
for (int i = 0; i < targetObservers.Length; i++)
{
targetObservers[i].OnCompleted();
}
}
public void OnError(Exception error)
{
var targetObservers = _observers.Data;
for (int i = 0; i < targetObservers.Length; i++)
{
targetObservers[i].OnError(error);
}
}
public void OnNext(T value)
{
var targetObservers = _observers.Data;
for (int i = 0; i < targetObservers.Length; i++)
{
targetObservers[i].OnNext(value);
}
}
internal IObserver<T> Add(IObserver<T> observer)
{
return new ListObserver<T>(_observers.Add(observer));
}
internal IObserver<T> Remove(IObserver<T> observer)
{
var i = Array.IndexOf(_observers.Data, observer);
if (i < 0)
return this;
if (_observers.Data.Length == 2)
{
return _observers.Data[1 - i];
}
else
{
return new ListObserver<T>(_observers.Remove(observer));
}
}
}
public class EmptyObserver<T> : IObserver<T>
{
public static readonly EmptyObserver<T> Instance = new EmptyObserver<T>();
EmptyObserver()
{
}
public void OnCompleted()
{
}
public void OnError(Exception error)
{
}
public void OnNext(T value)
{
}
}
public class ThrowObserver<T> : IObserver<T>
{
public static readonly ThrowObserver<T> Instance = new ThrowObserver<T>();
ThrowObserver()
{
}
public void OnCompleted()
{
}
public void OnError(Exception error)
{
error.Throw();
}
public void OnNext(T value)
{
}
}
public class DisposedObserver<T> : IObserver<T>
{
public static readonly DisposedObserver<T> Instance = new DisposedObserver<T>();
DisposedObserver()
{
}
public void OnCompleted()
{
throw new ObjectDisposedException("");
}
public void OnError(Exception error)
{
throw new ObjectDisposedException("");
}
public void OnNext(T value)
{
throw new ObjectDisposedException("");
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6ec970f7c5d99de44a769c0268b2d611
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,170 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace UniRx.InternalUtil
{
/// <summary>
/// Simple supports(only yield return null) lightweight, threadsafe coroutine dispatcher.
/// </summary>
public class MicroCoroutine
{
const int InitialSize = 16;
readonly object runningAndQueueLock = new object();
readonly object arrayLock = new object();
readonly Action<Exception> unhandledExceptionCallback;
int tail = 0;
bool running = false;
IEnumerator[] coroutines = new IEnumerator[InitialSize];
Queue<IEnumerator> waitQueue = new Queue<IEnumerator>();
public MicroCoroutine(Action<Exception> unhandledExceptionCallback)
{
this.unhandledExceptionCallback = unhandledExceptionCallback;
}
public void AddCoroutine(IEnumerator enumerator)
{
lock (runningAndQueueLock)
{
if (running)
{
waitQueue.Enqueue(enumerator);
return;
}
}
// worst case at multi threading, wait lock until finish Run() but it is super rarely.
lock (arrayLock)
{
// Ensure Capacity
if (coroutines.Length == tail)
{
Array.Resize(ref coroutines, checked(tail * 2));
}
coroutines[tail++] = enumerator;
}
}
public void Run()
{
lock (runningAndQueueLock)
{
running = true;
}
lock (arrayLock)
{
var j = tail - 1;
// eliminate array-bound check for i
for (int i = 0; i < coroutines.Length; i++)
{
var coroutine = coroutines[i];
if (coroutine != null)
{
try
{
if (!coroutine.MoveNext())
{
coroutines[i] = null;
}
else
{
#if UNITY_EDITOR
// validation only on Editor.
if (coroutine.Current != null)
{
UnityEngine.Debug.LogWarning("MicroCoroutine supports only yield return null. return value = " + coroutine.Current);
}
#endif
continue; // next i
}
}
catch (Exception ex)
{
coroutines[i] = null;
try
{
unhandledExceptionCallback(ex);
}
catch { }
}
}
// find null, loop from tail
while (i < j)
{
var fromTail = coroutines[j];
if (fromTail != null)
{
try
{
if (!fromTail.MoveNext())
{
coroutines[j] = null;
j--;
continue; // next j
}
else
{
#if UNITY_EDITOR
// validation only on Editor.
if (fromTail.Current != null)
{
UnityEngine.Debug.LogWarning("MicroCoroutine supports only yield return null. return value = " + coroutine.Current);
}
#endif
// swap
coroutines[i] = fromTail;
coroutines[j] = null;
j--;
goto NEXT_LOOP; // next i
}
}
catch (Exception ex)
{
coroutines[j] = null;
j--;
try
{
unhandledExceptionCallback(ex);
}
catch { }
continue; // next j
}
}
else
{
j--;
}
}
tail = i; // loop end
break; // LOOP END
NEXT_LOOP:
continue;
}
lock (runningAndQueueLock)
{
running = false;
while (waitQueue.Count != 0)
{
if (coroutines.Length == tail)
{
Array.Resize(ref coroutines, checked(tail * 2));
}
coroutines[tail++] = waitQueue.Dequeue();
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5be9ec9fd376cc341ba1ac11c7433d49
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,149 @@
// this code is borrowed from RxOfficial(rx.codeplex.com) and modified
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
namespace UniRx.InternalUtil
{
internal class PriorityQueue<T> where T : IComparable<T>
{
private static long _count = long.MinValue;
private IndexedItem[] _items;
private int _size;
public PriorityQueue()
: this(16)
{
}
public PriorityQueue(int capacity)
{
_items = new IndexedItem[capacity];
_size = 0;
}
private bool IsHigherPriority(int left, int right)
{
return _items[left].CompareTo(_items[right]) < 0;
}
private void Percolate(int index)
{
if (index >= _size || index < 0)
return;
var parent = (index - 1) / 2;
if (parent < 0 || parent == index)
return;
if (IsHigherPriority(index, parent))
{
var temp = _items[index];
_items[index] = _items[parent];
_items[parent] = temp;
Percolate(parent);
}
}
private void Heapify()
{
Heapify(0);
}
private void Heapify(int index)
{
if (index >= _size || index < 0)
return;
var left = 2 * index + 1;
var right = 2 * index + 2;
var first = index;
if (left < _size && IsHigherPriority(left, first))
first = left;
if (right < _size && IsHigherPriority(right, first))
first = right;
if (first != index)
{
var temp = _items[index];
_items[index] = _items[first];
_items[first] = temp;
Heapify(first);
}
}
public int Count { get { return _size; } }
public T Peek()
{
if (_size == 0)
throw new InvalidOperationException("HEAP is Empty");
return _items[0].Value;
}
private void RemoveAt(int index)
{
_items[index] = _items[--_size];
_items[_size] = default(IndexedItem);
Heapify();
if (_size < _items.Length / 4)
{
var temp = _items;
_items = new IndexedItem[_items.Length / 2];
Array.Copy(temp, 0, _items, 0, _size);
}
}
public T Dequeue()
{
var result = Peek();
RemoveAt(0);
return result;
}
public void Enqueue(T item)
{
if (_size >= _items.Length)
{
var temp = _items;
_items = new IndexedItem[_items.Length * 2];
Array.Copy(temp, _items, temp.Length);
}
var index = _size++;
_items[index] = new IndexedItem { Value = item, Id = Interlocked.Increment(ref _count) };
Percolate(index);
}
public bool Remove(T item)
{
for (var i = 0; i < _size; ++i)
{
if (EqualityComparer<T>.Default.Equals(_items[i].Value, item))
{
RemoveAt(i);
return true;
}
}
return false;
}
struct IndexedItem : IComparable<IndexedItem>
{
public T Value;
public long Id;
public int CompareTo(IndexedItem other)
{
var c = Value.CompareTo(other.Value);
if (c == 0)
c = Id.CompareTo(other.Id);
return c;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c243b05a7e47e874ab32d08eb97aa9cd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace UniRx.InternalUtil
{
internal static class PromiseHelper
{
internal static void TrySetResultAll<T>(IEnumerable<TaskCompletionSource<T>> source, T value)
{
var rentArray = source.ToArray(); // better to use Arraypool.
var array = rentArray;
var len = rentArray.Length;
for (int i = 0; i < len; i++)
{
array[i].TrySetResult(value);
array[i] = null;
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f342fd5adc2c160429f58c6cb8f138b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,257 @@
// this code is borrowed from RxOfficial(rx.codeplex.com) and modified
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace UniRx.InternalUtil
{
/// <summary>
/// Abstract base class for scheduled work items.
/// </summary>
internal class ScheduledItem : IComparable<ScheduledItem>
{
private readonly BooleanDisposable _disposable = new BooleanDisposable();
private readonly TimeSpan _dueTime;
private readonly Action _action;
/// <summary>
/// Creates a new scheduled work item to run at the specified time.
/// </summary>
/// <param name="dueTime">Absolute time at which the work item has to be executed.</param>
public ScheduledItem(Action action, TimeSpan dueTime)
{
_dueTime = dueTime;
_action = action;
}
/// <summary>
/// Gets the absolute time at which the item is due for invocation.
/// </summary>
public TimeSpan DueTime
{
get { return _dueTime; }
}
/// <summary>
/// Invokes the work item.
/// </summary>
public void Invoke()
{
if (!_disposable.IsDisposed)
{
_action();
}
}
#region Inequality
/// <summary>
/// Compares the work item with another work item based on absolute time values.
/// </summary>
/// <param name="other">Work item to compare the current work item to.</param>
/// <returns>Relative ordering between this and the specified work item.</returns>
/// <remarks>The inequality operators are overloaded to provide results consistent with the IComparable implementation. Equality operators implement traditional reference equality semantics.</remarks>
public int CompareTo(ScheduledItem other)
{
// MSDN: By definition, any object compares greater than null, and two null references compare equal to each other.
if (object.ReferenceEquals(other, null))
return 1;
return DueTime.CompareTo(other.DueTime);
}
/// <summary>
/// Determines whether one specified ScheduledItem&lt;TAbsolute&gt; object is due before a second specified ScheduledItem&lt;TAbsolute&gt; object.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if the DueTime value of left is earlier than the DueTime value of right; otherwise, false.</returns>
/// <remarks>This operator provides results consistent with the IComparable implementation.</remarks>
public static bool operator <(ScheduledItem left, ScheduledItem right)
{
return left.CompareTo(right) < 0;
}
/// <summary>
/// Determines whether one specified ScheduledItem&lt;TAbsolute&gt; object is due before or at the same of a second specified ScheduledItem&lt;TAbsolute&gt; object.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if the DueTime value of left is earlier than or simultaneous with the DueTime value of right; otherwise, false.</returns>
/// <remarks>This operator provides results consistent with the IComparable implementation.</remarks>
public static bool operator <=(ScheduledItem left, ScheduledItem right)
{
return left.CompareTo(right) <= 0;
}
/// <summary>
/// Determines whether one specified ScheduledItem&lt;TAbsolute&gt; object is due after a second specified ScheduledItem&lt;TAbsolute&gt; object.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if the DueTime value of left is later than the DueTime value of right; otherwise, false.</returns>
/// <remarks>This operator provides results consistent with the IComparable implementation.</remarks>
public static bool operator >(ScheduledItem left, ScheduledItem right)
{
return left.CompareTo(right) > 0;
}
/// <summary>
/// Determines whether one specified ScheduledItem&lt;TAbsolute&gt; object is due after or at the same time of a second specified ScheduledItem&lt;TAbsolute&gt; object.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if the DueTime value of left is later than or simultaneous with the DueTime value of right; otherwise, false.</returns>
/// <remarks>This operator provides results consistent with the IComparable implementation.</remarks>
public static bool operator >=(ScheduledItem left, ScheduledItem right)
{
return left.CompareTo(right) >= 0;
}
#endregion
#region Equality
/// <summary>
/// Determines whether two specified ScheduledItem&lt;TAbsolute, TValue&gt; objects are equal.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if both ScheduledItem&lt;TAbsolute, TValue&gt; are equal; otherwise, false.</returns>
/// <remarks>This operator does not provide results consistent with the IComparable implementation. Instead, it implements reference equality.</remarks>
public static bool operator ==(ScheduledItem left, ScheduledItem right)
{
return object.ReferenceEquals(left, right);
}
/// <summary>
/// Determines whether two specified ScheduledItem&lt;TAbsolute, TValue&gt; objects are inequal.
/// </summary>
/// <param name="left">The first object to compare.</param>
/// <param name="right">The second object to compare.</param>
/// <returns>true if both ScheduledItem&lt;TAbsolute, TValue&gt; are inequal; otherwise, false.</returns>
/// <remarks>This operator does not provide results consistent with the IComparable implementation. Instead, it implements reference equality.</remarks>
public static bool operator !=(ScheduledItem left, ScheduledItem right)
{
return !(left == right);
}
/// <summary>
/// Determines whether a ScheduledItem&lt;TAbsolute&gt; object is equal to the specified object.
/// </summary>
/// <param name="obj">The object to compare to the current ScheduledItem&lt;TAbsolute&gt; object.</param>
/// <returns>true if the obj parameter is a ScheduledItem&lt;TAbsolute&gt; object and is equal to the current ScheduledItem&lt;TAbsolute&gt; object; otherwise, false.</returns>
public override bool Equals(object obj)
{
return object.ReferenceEquals(this, obj);
}
/// <summary>
/// Returns the hash code for the current ScheduledItem&lt;TAbsolute&gt; object.
/// </summary>
/// <returns>A 32-bit signed integer hash code.</returns>
public override int GetHashCode()
{
return base.GetHashCode();
}
#endregion
public IDisposable Cancellation
{
get
{
return _disposable;
}
}
/// <summary>
/// Gets whether the work item has received a cancellation request.
/// </summary>
public bool IsCanceled
{
get { return _disposable.IsDisposed; }
}
}
/// <summary>
/// Efficient scheduler queue that maintains scheduled items sorted by absolute time.
/// </summary>
/// <remarks>This type is not thread safe; users should ensure proper synchronization.</remarks>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1711:IdentifiersShouldNotHaveIncorrectSuffix", Justification = "But it *is* a queue!")]
internal class SchedulerQueue
{
private readonly PriorityQueue<ScheduledItem> _queue;
/// <summary>
/// Creates a new scheduler queue with a default initial capacity.
/// </summary>
public SchedulerQueue()
: this(1024)
{
}
/// <summary>
/// Creats a new scheduler queue with the specified initial capacity.
/// </summary>
/// <param name="capacity">Initial capacity of the scheduler queue.</param>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="capacity"/> is less than zero.</exception>
public SchedulerQueue(int capacity)
{
if (capacity < 0)
throw new ArgumentOutOfRangeException("capacity");
_queue = new PriorityQueue<ScheduledItem>(capacity);
}
/// <summary>
/// Gets the number of scheduled items in the scheduler queue.
/// </summary>
public int Count
{
get
{
return _queue.Count;
}
}
/// <summary>
/// Enqueues the specified work item to be scheduled.
/// </summary>
/// <param name="scheduledItem">Work item to be scheduled.</param>
public void Enqueue(ScheduledItem scheduledItem)
{
_queue.Enqueue(scheduledItem);
}
/// <summary>
/// Removes the specified work item from the scheduler queue.
/// </summary>
/// <param name="scheduledItem">Work item to be removed from the scheduler queue.</param>
/// <returns>true if the item was found; false otherwise.</returns>
public bool Remove(ScheduledItem scheduledItem)
{
return _queue.Remove(scheduledItem);
}
/// <summary>
/// Dequeues the next work item from the scheduler queue.
/// </summary>
/// <returns>Next work item in the scheduler queue (removed).</returns>
public ScheduledItem Dequeue()
{
return _queue.Dequeue();
}
/// <summary>
/// Peeks the next work item in the scheduler queue.
/// </summary>
/// <returns>Next work item in the scheduler queue (not removed).</returns>
public ScheduledItem Peek()
{
return _queue.Peek();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 135cedd30b7d1b545b1f723b9a809f7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,112 @@
using System;
namespace UniRx.InternalUtil
{
public class ThreadSafeQueueWorker
{
const int MaxArrayLength = 0X7FEFFFFF;
const int InitialSize = 16;
object gate = new object();
bool dequing = false;
int actionListCount = 0;
Action<object>[] actionList = new Action<object>[InitialSize];
object[] actionStates = new object[InitialSize];
int waitingListCount = 0;
Action<object>[] waitingList = new Action<object>[InitialSize];
object[] waitingStates = new object[InitialSize];
public void Enqueue(Action<object> action, object state)
{
lock (gate)
{
if (dequing)
{
// Ensure Capacity
if (waitingList.Length == waitingListCount)
{
var newLength = waitingListCount * 2;
if ((uint)newLength > MaxArrayLength) newLength = MaxArrayLength;
var newArray = new Action<object>[newLength];
var newArrayState = new object[newLength];
Array.Copy(waitingList, newArray, waitingListCount);
Array.Copy(waitingStates, newArrayState, waitingListCount);
waitingList = newArray;
waitingStates = newArrayState;
}
waitingList[waitingListCount] = action;
waitingStates[waitingListCount] = state;
waitingListCount++;
}
else
{
// Ensure Capacity
if (actionList.Length == actionListCount)
{
var newLength = actionListCount * 2;
if ((uint)newLength > MaxArrayLength) newLength = MaxArrayLength;
var newArray = new Action<object>[newLength];
var newArrayState = new object[newLength];
Array.Copy(actionList, newArray, actionListCount);
Array.Copy(actionStates, newArrayState, actionListCount);
actionList = newArray;
actionStates = newArrayState;
}
actionList[actionListCount] = action;
actionStates[actionListCount] = state;
actionListCount++;
}
}
}
public void ExecuteAll(Action<Exception> unhandledExceptionCallback)
{
lock (gate)
{
if (actionListCount == 0) return;
dequing = true;
}
for (int i = 0; i < actionListCount; i++)
{
var action = actionList[i];
var state = actionStates[i];
try
{
action(state);
}
catch (Exception ex)
{
unhandledExceptionCallback(ex);
}
finally
{
// Clear
actionList[i] = null;
actionStates[i] = null;
}
}
lock (gate)
{
dequing = false;
var swapTempActionList = actionList;
var swapTempActionStates = actionStates;
actionListCount = waitingListCount;
actionList = waitingList;
actionStates = waitingStates;
waitingListCount = 0;
waitingList = swapTempActionList;
waitingStates = swapTempActionStates;
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8f615773bf9c46c468ab3e28e4ef9366
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,271 @@
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#endif
using System;
using System.Collections.Generic;
using UnityEngine;
namespace UniRx.InternalUtil
{
internal static class UnityEqualityComparer
{
public static readonly IEqualityComparer<Vector2> Vector2 = new Vector2EqualityComparer();
public static readonly IEqualityComparer<Vector3> Vector3 = new Vector3EqualityComparer();
public static readonly IEqualityComparer<Vector4> Vector4 = new Vector4EqualityComparer();
public static readonly IEqualityComparer<Color> Color = new ColorEqualityComparer();
public static readonly IEqualityComparer<Color32> Color32 = new Color32EqualityComparer();
public static readonly IEqualityComparer<Rect> Rect = new RectEqualityComparer();
public static readonly IEqualityComparer<Bounds> Bounds = new BoundsEqualityComparer();
public static readonly IEqualityComparer<Quaternion> Quaternion = new QuaternionEqualityComparer();
static readonly RuntimeTypeHandle vector2Type = typeof(Vector2).TypeHandle;
static readonly RuntimeTypeHandle vector3Type = typeof(Vector3).TypeHandle;
static readonly RuntimeTypeHandle vector4Type = typeof(Vector4).TypeHandle;
static readonly RuntimeTypeHandle colorType = typeof(Color).TypeHandle;
static readonly RuntimeTypeHandle color32Type = typeof(Color32).TypeHandle;
static readonly RuntimeTypeHandle rectType = typeof(Rect).TypeHandle;
static readonly RuntimeTypeHandle boundsType = typeof(Bounds).TypeHandle;
static readonly RuntimeTypeHandle quaternionType = typeof(Quaternion).TypeHandle;
#if UNITY_2017_2_OR_NEWER
public static readonly IEqualityComparer<Vector2Int> Vector2Int = new Vector2IntEqualityComparer();
public static readonly IEqualityComparer<Vector3Int> Vector3Int = new Vector3IntEqualityComparer();
public static readonly IEqualityComparer<RangeInt> RangeInt = new RangeIntEqualityComparer();
public static readonly IEqualityComparer<RectInt> RectInt = new RectIntEqualityComparer();
public static readonly IEqualityComparer<BoundsInt> BoundsInt = new BoundsIntEqualityComparer();
static readonly RuntimeTypeHandle vector2IntType = typeof(Vector2Int).TypeHandle;
static readonly RuntimeTypeHandle vector3IntType = typeof(Vector3Int).TypeHandle;
static readonly RuntimeTypeHandle rangeIntType = typeof(RangeInt).TypeHandle;
static readonly RuntimeTypeHandle rectIntType = typeof(RectInt).TypeHandle;
static readonly RuntimeTypeHandle boundsIntType = typeof(BoundsInt).TypeHandle;
#endif
static class Cache<T>
{
public static readonly IEqualityComparer<T> Comparer;
static Cache()
{
var comparer = GetDefaultHelper(typeof(T));
if (comparer == null)
{
Comparer = EqualityComparer<T>.Default;
}
else
{
Comparer = (IEqualityComparer<T>)comparer;
}
}
}
public static IEqualityComparer<T> GetDefault<T>()
{
return Cache<T>.Comparer;
}
static object GetDefaultHelper(Type type)
{
var t = type.TypeHandle;
if (t.Equals(vector2Type)) return (object)UnityEqualityComparer.Vector2;
if (t.Equals(vector3Type)) return (object)UnityEqualityComparer.Vector3;
if (t.Equals(vector4Type)) return (object)UnityEqualityComparer.Vector4;
if (t.Equals(colorType)) return (object)UnityEqualityComparer.Color;
if (t.Equals(color32Type)) return (object)UnityEqualityComparer.Color32;
if (t.Equals(rectType)) return (object)UnityEqualityComparer.Rect;
if (t.Equals(boundsType)) return (object)UnityEqualityComparer.Bounds;
if (t.Equals(quaternionType)) return (object)UnityEqualityComparer.Quaternion;
#if UNITY_2017_2_OR_NEWER
if (t.Equals(vector2IntType)) return (object)UnityEqualityComparer.Vector2Int;
if (t.Equals(vector3IntType)) return (object)UnityEqualityComparer.Vector3Int;
if (t.Equals(rangeIntType)) return (object)UnityEqualityComparer.RangeInt;
if (t.Equals(rectIntType)) return (object)UnityEqualityComparer.RectInt;
if (t.Equals(boundsIntType)) return (object)UnityEqualityComparer.BoundsInt;
#endif
return null;
}
sealed class Vector2EqualityComparer : IEqualityComparer<Vector2>
{
public bool Equals(Vector2 self, Vector2 vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y);
}
public int GetHashCode(Vector2 obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2;
}
}
sealed class Vector3EqualityComparer : IEqualityComparer<Vector3>
{
public bool Equals(Vector3 self, Vector3 vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y) && self.z.Equals(vector.z);
}
public int GetHashCode(Vector3 obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2 ^ obj.z.GetHashCode() >> 2;
}
}
sealed class Vector4EqualityComparer : IEqualityComparer<Vector4>
{
public bool Equals(Vector4 self, Vector4 vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y) && self.z.Equals(vector.z) && self.w.Equals(vector.w);
}
public int GetHashCode(Vector4 obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2 ^ obj.z.GetHashCode() >> 2 ^ obj.w.GetHashCode() >> 1;
}
}
sealed class ColorEqualityComparer : IEqualityComparer<Color>
{
public bool Equals(Color self, Color other)
{
return self.r.Equals(other.r) && self.g.Equals(other.g) && self.b.Equals(other.b) && self.a.Equals(other.a);
}
public int GetHashCode(Color obj)
{
return obj.r.GetHashCode() ^ obj.g.GetHashCode() << 2 ^ obj.b.GetHashCode() >> 2 ^ obj.a.GetHashCode() >> 1;
}
}
sealed class RectEqualityComparer : IEqualityComparer<Rect>
{
public bool Equals(Rect self, Rect other)
{
return self.x.Equals(other.x) && self.width.Equals(other.width) && self.y.Equals(other.y) && self.height.Equals(other.height);
}
public int GetHashCode(Rect obj)
{
return obj.x.GetHashCode() ^ obj.width.GetHashCode() << 2 ^ obj.y.GetHashCode() >> 2 ^ obj.height.GetHashCode() >> 1;
}
}
sealed class BoundsEqualityComparer : IEqualityComparer<Bounds>
{
public bool Equals(Bounds self, Bounds vector)
{
return self.center.Equals(vector.center) && self.extents.Equals(vector.extents);
}
public int GetHashCode(Bounds obj)
{
return obj.center.GetHashCode() ^ obj.extents.GetHashCode() << 2;
}
}
sealed class QuaternionEqualityComparer : IEqualityComparer<Quaternion>
{
public bool Equals(Quaternion self, Quaternion vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y) && self.z.Equals(vector.z) && self.w.Equals(vector.w);
}
public int GetHashCode(Quaternion obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2 ^ obj.z.GetHashCode() >> 2 ^ obj.w.GetHashCode() >> 1;
}
}
sealed class Color32EqualityComparer : IEqualityComparer<Color32>
{
public bool Equals(Color32 self, Color32 vector)
{
return self.a.Equals(vector.a) && self.r.Equals(vector.r) && self.g.Equals(vector.g) && self.b.Equals(vector.b);
}
public int GetHashCode(Color32 obj)
{
return obj.a.GetHashCode() ^ obj.r.GetHashCode() << 2 ^ obj.g.GetHashCode() >> 2 ^ obj.b.GetHashCode() >> 1;
}
}
#if UNITY_2017_2_OR_NEWER
sealed class Vector2IntEqualityComparer : IEqualityComparer<Vector2Int>
{
public bool Equals(Vector2Int self, Vector2Int vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y);
}
public int GetHashCode(Vector2Int obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2;
}
}
sealed class Vector3IntEqualityComparer : IEqualityComparer<Vector3Int>
{
public static readonly Vector3IntEqualityComparer Default = new Vector3IntEqualityComparer();
public bool Equals(Vector3Int self, Vector3Int vector)
{
return self.x.Equals(vector.x) && self.y.Equals(vector.y) && self.z.Equals(vector.z);
}
public int GetHashCode(Vector3Int obj)
{
return obj.x.GetHashCode() ^ obj.y.GetHashCode() << 2 ^ obj.z.GetHashCode() >> 2;
}
}
sealed class RangeIntEqualityComparer : IEqualityComparer<RangeInt>
{
public bool Equals(RangeInt self, RangeInt vector)
{
return self.start.Equals(vector.start) && self.length.Equals(vector.length);
}
public int GetHashCode(RangeInt obj)
{
return obj.start.GetHashCode() ^ obj.length.GetHashCode() << 2;
}
}
sealed class RectIntEqualityComparer : IEqualityComparer<RectInt>
{
public bool Equals(RectInt self, RectInt other)
{
return self.x.Equals(other.x) && self.width.Equals(other.width) && self.y.Equals(other.y) && self.height.Equals(other.height);
}
public int GetHashCode(RectInt obj)
{
return obj.x.GetHashCode() ^ obj.width.GetHashCode() << 2 ^ obj.y.GetHashCode() >> 2 ^ obj.height.GetHashCode() >> 1;
}
}
sealed class BoundsIntEqualityComparer : IEqualityComparer<BoundsInt>
{
public bool Equals(BoundsInt self, BoundsInt vector)
{
return Vector3IntEqualityComparer.Default.Equals(self.position, vector.position)
&& Vector3IntEqualityComparer.Default.Equals(self.size, vector.size);
}
public int GetHashCode(BoundsInt obj)
{
return Vector3IntEqualityComparer.Default.GetHashCode(obj.position) ^ Vector3IntEqualityComparer.Default.GetHashCode(obj.size) << 2;
}
}
#endif
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a9c966ef8c6c7bf41b6731cf12af432e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,678 @@
// original code from rx.codeplex.com
// some modified.
/* ------------------ */
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Diagnostics;
using System.Globalization;
using System.Collections.Generic;
using System;
using UniRx.InternalUtil;
#pragma warning disable 0659
#pragma warning disable 0661
namespace UniRx
{
/// <summary>
/// Provides a mechanism for receiving push-based notifications and returning a response.
/// </summary>
/// <typeparam name="TValue">
/// The type of the elements received by the observer.
/// This type parameter is contravariant. That is, you can use either the type you specified or any type that is less derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
/// <typeparam name="TResult">
/// The type of the result returned from the observer's notification handlers.
/// This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
/// </typeparam>
public interface IObserver<TValue, TResult>
{
/// <summary>
/// Notifies the observer of a new element in the sequence.
/// </summary>
/// <param name="value">The new element in the sequence.</param>
/// <returns>Result returned upon observation of a new element.</returns>
TResult OnNext(TValue value);
/// <summary>
/// Notifies the observer that an exception has occurred.
/// </summary>
/// <param name="exception">The exception that occurred.</param>
/// <returns>Result returned upon observation of an error.</returns>
TResult OnError(Exception exception);
/// <summary>
/// Notifies the observer of the end of the sequence.
/// </summary>
/// <returns>Result returned upon observation of the sequence completion.</returns>
TResult OnCompleted();
}
/// <summary>
/// Indicates the type of a notification.
/// </summary>
public enum NotificationKind
{
/// <summary>
/// Represents an OnNext notification.
/// </summary>
OnNext,
/// <summary>
/// Represents an OnError notification.
/// </summary>
OnError,
/// <summary>
/// Represents an OnCompleted notification.
/// </summary>
OnCompleted
}
/// <summary>
/// Represents a notification to an observer.
/// </summary>
/// <typeparam name="T">The type of the elements received by the observer.</typeparam>
[Serializable]
public abstract class Notification<T> : IEquatable<Notification<T>>
{
/// <summary>
/// Default constructor used by derived types.
/// </summary>
protected internal Notification()
{
}
/// <summary>
/// Returns the value of an OnNext notification or throws an exception.
/// </summary>
public abstract T Value
{
get;
}
/// <summary>
/// Returns a value that indicates whether the notification has a value.
/// </summary>
public abstract bool HasValue
{
get;
}
/// <summary>
/// Returns the exception of an OnError notification or returns null.
/// </summary>
public abstract Exception Exception
{
get;
}
/// <summary>
/// Gets the kind of notification that is represented.
/// </summary>
public abstract NotificationKind Kind
{
get;
}
/// <summary>
/// Represents an OnNext notification to an observer.
/// </summary>
[DebuggerDisplay("OnNext({Value})")]
[Serializable]
internal sealed class OnNextNotification : Notification<T>
{
T value;
/// <summary>
/// Constructs a notification of a new value.
/// </summary>
public OnNextNotification(T value)
{
this.value = value;
}
/// <summary>
/// Returns the value of an OnNext notification.
/// </summary>
public override T Value { get { return value; } }
/// <summary>
/// Returns null.
/// </summary>
public override Exception Exception { get { return null; } }
/// <summary>
/// Returns true.
/// </summary>
public override bool HasValue { get { return true; } }
/// <summary>
/// Returns NotificationKind.OnNext.
/// </summary>
public override NotificationKind Kind { get { return NotificationKind.OnNext; } }
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
public override int GetHashCode()
{
return EqualityComparer<T>.Default.GetHashCode(Value);
}
/// <summary>
/// Indicates whether this instance and a specified object are equal.
/// </summary>
public override bool Equals(Notification<T> other)
{
if (Object.ReferenceEquals(this, other))
return true;
if (Object.ReferenceEquals(other, null))
return false;
if (other.Kind != NotificationKind.OnNext)
return false;
return EqualityComparer<T>.Default.Equals(Value, other.Value);
}
/// <summary>
/// Returns a string representation of this instance.
/// </summary>
public override string ToString()
{
return String.Format(CultureInfo.CurrentCulture, "OnNext({0})", Value);
}
/// <summary>
/// Invokes the observer's method corresponding to the notification.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
public override void Accept(IObserver<T> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
observer.OnNext(Value);
}
/// <summary>
/// Invokes the observer's method corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(IObserver<T, TResult> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
return observer.OnNext(Value);
}
/// <summary>
/// Invokes the delegate corresponding to the notification.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
onNext(Value);
}
/// <summary>
/// Invokes the delegate corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
return onNext(Value);
}
}
/// <summary>
/// Represents an OnError notification to an observer.
/// </summary>
#if !NO_DEBUGGER_ATTRIBUTES
[DebuggerDisplay("OnError({Exception})")]
#endif
#if !NO_SERIALIZABLE
[Serializable]
#endif
internal sealed class OnErrorNotification : Notification<T>
{
Exception exception;
/// <summary>
/// Constructs a notification of an exception.
/// </summary>
public OnErrorNotification(Exception exception)
{
this.exception = exception;
}
/// <summary>
/// Throws the exception.
/// </summary>
public override T Value { get { exception.Throw(); throw exception; } }
/// <summary>
/// Returns the exception.
/// </summary>
public override Exception Exception { get { return exception; } }
/// <summary>
/// Returns false.
/// </summary>
public override bool HasValue { get { return false; } }
/// <summary>
/// Returns NotificationKind.OnError.
/// </summary>
public override NotificationKind Kind { get { return NotificationKind.OnError; } }
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
public override int GetHashCode()
{
return Exception.GetHashCode();
}
/// <summary>
/// Indicates whether this instance and other are equal.
/// </summary>
public override bool Equals(Notification<T> other)
{
if (Object.ReferenceEquals(this, other))
return true;
if (Object.ReferenceEquals(other, null))
return false;
if (other.Kind != NotificationKind.OnError)
return false;
return Object.Equals(Exception, other.Exception);
}
/// <summary>
/// Returns a string representation of this instance.
/// </summary>
public override string ToString()
{
return String.Format(CultureInfo.CurrentCulture, "OnError({0})", Exception.GetType().FullName);
}
/// <summary>
/// Invokes the observer's method corresponding to the notification.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
public override void Accept(IObserver<T> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
observer.OnError(Exception);
}
/// <summary>
/// Invokes the observer's method corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(IObserver<T, TResult> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
return observer.OnError(Exception);
}
/// <summary>
/// Invokes the delegate corresponding to the notification.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
onError(Exception);
}
/// <summary>
/// Invokes the delegate corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
return onError(Exception);
}
}
/// <summary>
/// Represents an OnCompleted notification to an observer.
/// </summary>
[DebuggerDisplay("OnCompleted()")]
[Serializable]
internal sealed class OnCompletedNotification : Notification<T>
{
/// <summary>
/// Constructs a notification of the end of a sequence.
/// </summary>
public OnCompletedNotification()
{
}
/// <summary>
/// Throws an InvalidOperationException.
/// </summary>
public override T Value { get { throw new InvalidOperationException("No Value"); } }
/// <summary>
/// Returns null.
/// </summary>
public override Exception Exception { get { return null; } }
/// <summary>
/// Returns false.
/// </summary>
public override bool HasValue { get { return false; } }
/// <summary>
/// Returns NotificationKind.OnCompleted.
/// </summary>
public override NotificationKind Kind { get { return NotificationKind.OnCompleted; } }
/// <summary>
/// Returns the hash code for this instance.
/// </summary>
public override int GetHashCode()
{
return typeof(T).GetHashCode() ^ 8510;
}
/// <summary>
/// Indicates whether this instance and other are equal.
/// </summary>
public override bool Equals(Notification<T> other)
{
if (Object.ReferenceEquals(this, other))
return true;
if (Object.ReferenceEquals(other, null))
return false;
return other.Kind == NotificationKind.OnCompleted;
}
/// <summary>
/// Returns a string representation of this instance.
/// </summary>
public override string ToString()
{
return "OnCompleted()";
}
/// <summary>
/// Invokes the observer's method corresponding to the notification.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
public override void Accept(IObserver<T> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
observer.OnCompleted();
}
/// <summary>
/// Invokes the observer's method corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(IObserver<T, TResult> observer)
{
if (observer == null)
throw new ArgumentNullException("observer");
return observer.OnCompleted();
}
/// <summary>
/// Invokes the delegate corresponding to the notification.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
public override void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
onCompleted();
}
/// <summary>
/// Invokes the delegate corresponding to the notification and returns the produced result.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
/// <returns>Result produced by the observation.</returns>
public override TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted)
{
if (onNext == null)
throw new ArgumentNullException("onNext");
if (onError == null)
throw new ArgumentNullException("onError");
if (onCompleted == null)
throw new ArgumentNullException("onCompleted");
return onCompleted();
}
}
/// <summary>
/// Determines whether the current Notification&lt;T&gt; object has the same observer message payload as a specified Notification&lt;T&gt; value.
/// </summary>
/// <param name="other">An object to compare to the current Notification&lt;T&gt; object.</param>
/// <returns>true if both Notification&lt;T&gt; objects have the same observer message payload; otherwise, false.</returns>
/// <remarks>
/// Equality of Notification&lt;T&gt; objects is based on the equality of the observer message payload they represent, including the notification Kind and the Value or Exception (if any).
/// This means two Notification&lt;T&gt; objects can be equal even though they don't represent the same observer method call, but have the same Kind and have equal parameters passed to the observer method.
/// In case one wants to determine whether two Notification&lt;T&gt; objects represent the same observer method call, use Object.ReferenceEquals identity equality instead.
/// </remarks>
public abstract bool Equals(Notification<T> other);
/// <summary>
/// Determines whether the two specified Notification&lt;T&gt; objects have the same observer message payload.
/// </summary>
/// <param name="left">The first Notification&lt;T&gt; to compare, or null.</param>
/// <param name="right">The second Notification&lt;T&gt; to compare, or null.</param>
/// <returns>true if the first Notification&lt;T&gt; value has the same observer message payload as the second Notification&lt;T&gt; value; otherwise, false.</returns>
/// <remarks>
/// Equality of Notification&lt;T&gt; objects is based on the equality of the observer message payload they represent, including the notification Kind and the Value or Exception (if any).
/// This means two Notification&lt;T&gt; objects can be equal even though they don't represent the same observer method call, but have the same Kind and have equal parameters passed to the observer method.
/// In case one wants to determine whether two Notification&lt;T&gt; objects represent the same observer method call, use Object.ReferenceEquals identity equality instead.
/// </remarks>
public static bool operator ==(Notification<T> left, Notification<T> right)
{
if (object.ReferenceEquals(left, right))
return true;
if ((object)left == null || (object)right == null)
return false;
return left.Equals(right);
}
/// <summary>
/// Determines whether the two specified Notification&lt;T&gt; objects have a different observer message payload.
/// </summary>
/// <param name="left">The first Notification&lt;T&gt; to compare, or null.</param>
/// <param name="right">The second Notification&lt;T&gt; to compare, or null.</param>
/// <returns>true if the first Notification&lt;T&gt; value has a different observer message payload as the second Notification&lt;T&gt; value; otherwise, false.</returns>
/// <remarks>
/// Equality of Notification&lt;T&gt; objects is based on the equality of the observer message payload they represent, including the notification Kind and the Value or Exception (if any).
/// This means two Notification&lt;T&gt; objects can be equal even though they don't represent the same observer method call, but have the same Kind and have equal parameters passed to the observer method.
/// In case one wants to determine whether two Notification&lt;T&gt; objects represent a different observer method call, use Object.ReferenceEquals identity equality instead.
/// </remarks>
public static bool operator !=(Notification<T> left, Notification<T> right)
{
return !(left == right);
}
/// <summary>
/// Determines whether the specified System.Object is equal to the current Notification&lt;T&gt;.
/// </summary>
/// <param name="obj">The System.Object to compare with the current Notification&lt;T&gt;.</param>
/// <returns>true if the specified System.Object is equal to the current Notification&lt;T&gt;; otherwise, false.</returns>
/// <remarks>
/// Equality of Notification&lt;T&gt; objects is based on the equality of the observer message payload they represent, including the notification Kind and the Value or Exception (if any).
/// This means two Notification&lt;T&gt; objects can be equal even though they don't represent the same observer method call, but have the same Kind and have equal parameters passed to the observer method.
/// In case one wants to determine whether two Notification&lt;T&gt; objects represent the same observer method call, use Object.ReferenceEquals identity equality instead.
/// </remarks>
public override bool Equals(object obj)
{
return Equals(obj as Notification<T>);
}
/// <summary>
/// Invokes the observer's method corresponding to the notification.
/// </summary>
/// <param name="observer">Observer to invoke the notification on.</param>
public abstract void Accept(IObserver<T> observer);
/// <summary>
/// Invokes the observer's method corresponding to the notification and returns the produced result.
/// </summary>
/// <typeparam name="TResult">The type of the result returned from the observer's notification handlers.</typeparam>
/// <param name="observer">Observer to invoke the notification on.</param>
/// <returns>Result produced by the observation.</returns>
public abstract TResult Accept<TResult>(IObserver<T, TResult> observer);
/// <summary>
/// Invokes the delegate corresponding to the notification.
/// </summary>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
public abstract void Accept(Action<T> onNext, Action<Exception> onError, Action onCompleted);
/// <summary>
/// Invokes the delegate corresponding to the notification and returns the produced result.
/// </summary>
/// <typeparam name="TResult">The type of the result returned from the notification handler delegates.</typeparam>
/// <param name="onNext">Delegate to invoke for an OnNext notification.</param>
/// <param name="onError">Delegate to invoke for an OnError notification.</param>
/// <param name="onCompleted">Delegate to invoke for an OnCompleted notification.</param>
/// <returns>Result produced by the observation.</returns>
public abstract TResult Accept<TResult>(Func<T, TResult> onNext, Func<Exception, TResult> onError, Func<TResult> onCompleted);
/// <summary>
/// Returns an observable sequence with a single notification, using the immediate scheduler.
/// </summary>
/// <returns>The observable sequence that surfaces the behavior of the notification upon subscription.</returns>
public IObservable<T> ToObservable()
{
return this.ToObservable(Scheduler.Immediate);
}
/// <summary>
/// Returns an observable sequence with a single notification.
/// </summary>
/// <param name="scheduler">Scheduler to send out the notification calls on.</param>
/// <returns>The observable sequence that surfaces the behavior of the notification upon subscription.</returns>
public IObservable<T> ToObservable(IScheduler scheduler)
{
if (scheduler == null)
throw new ArgumentNullException("scheduler");
return Observable.Create<T>(observer => scheduler.Schedule(() =>
{
this.Accept(observer);
if (this.Kind == NotificationKind.OnNext)
observer.OnCompleted();
}));
}
}
/// <summary>
/// Provides a set of static methods for constructing notifications.
/// </summary>
public static class Notification
{
/// <summary>
/// Creates an object that represents an OnNext notification to an observer.
/// </summary>
/// <typeparam name="T">The type of the elements received by the observer. Upon dematerialization of the notifications into an observable sequence, this type is used as the element type for the sequence.</typeparam>
/// <param name="value">The value contained in the notification.</param>
/// <returns>The OnNext notification containing the value.</returns>
public static Notification<T> CreateOnNext<T>(T value)
{
return new Notification<T>.OnNextNotification(value);
}
/// <summary>
/// Creates an object that represents an OnError notification to an observer.
/// </summary>
/// <typeparam name="T">The type of the elements received by the observer. Upon dematerialization of the notifications into an observable sequence, this type is used as the element type for the sequence.</typeparam>
/// <param name="error">The exception contained in the notification.</param>
/// <returns>The OnError notification containing the exception.</returns>
/// <exception cref="ArgumentNullException"><paramref name="error"/> is null.</exception>
public static Notification<T> CreateOnError<T>(Exception error)
{
if (error == null)
throw new ArgumentNullException("error");
return new Notification<T>.OnErrorNotification(error);
}
/// <summary>
/// Creates an object that represents an OnCompleted notification to an observer.
/// </summary>
/// <typeparam name="T">The type of the elements received by the observer. Upon dematerialization of the notifications into an observable sequence, this type is used as the element type for the sequence.</typeparam>
/// <returns>The OnCompleted notification.</returns>
public static Notification<T> CreateOnCompleted<T>()
{
return new Notification<T>.OnCompletedNotification();
}
}
}
#pragma warning restore 0659
#pragma warning restore 0661

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3664a093b1bcb2647b966f89270a7f9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 5fe623f66a352d74987af39a4c664dd1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UniRx
{
/// <summary>
/// Notify boolean flag.
/// </summary>
public class BooleanNotifier : IObservable<bool>
{
readonly Subject<bool> boolTrigger = new Subject<bool>();
bool boolValue;
/// <summary>Current flag value</summary>
public bool Value
{
get { return boolValue; }
set
{
boolValue = value;
boolTrigger.OnNext(value);
}
}
/// <summary>
/// Setup initial flag.
/// </summary>
public BooleanNotifier(bool initialValue = false)
{
this.Value = initialValue;
}
/// <summary>
/// Set and raise true if current value isn't true.
/// </summary>
public void TurnOn()
{
if (Value != true)
{
Value = true;
}
}
/// <summary>
/// Set and raise false if current value isn't false.
/// </summary>
public void TurnOff()
{
if (Value != false)
{
Value = false;
}
}
/// <summary>
/// Set and raise reverse value.
/// </summary>
public void SwitchValue()
{
Value = !Value;
}
/// <summary>
/// Subscribe observer.
/// </summary>
public IDisposable Subscribe(IObserver<bool> observer)
{
return boolTrigger.Subscribe(observer);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 9074f54021c6a2541b47dde8afefaa56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace UniRx
{
/// <summary>Event kind of CountNotifier.</summary>
public enum CountChangedStatus
{
/// <summary>Count incremented.</summary>
Increment,
/// <summary>Count decremented.</summary>
Decrement,
/// <summary>Count is zero.</summary>
Empty,
/// <summary>Count arrived max.</summary>
Max
}
/// <summary>
/// Notify event of count flag.
/// </summary>
public class CountNotifier : IObservable<CountChangedStatus>
{
readonly object lockObject = new object();
readonly Subject<CountChangedStatus> statusChanged = new Subject<CountChangedStatus>();
readonly int max;
public int Max { get { return max; } }
public int Count { get; private set; }
/// <summary>
/// Setup max count of signal.
/// </summary>
public CountNotifier(int max = int.MaxValue)
{
if (max <= 0)
{
throw new ArgumentException("max");
}
this.max = max;
}
/// <summary>
/// Increment count and notify status.
/// </summary>
public IDisposable Increment(int incrementCount = 1)
{
if (incrementCount < 0)
{
throw new ArgumentException("incrementCount");
}
lock (lockObject)
{
if (Count == Max) return Disposable.Empty;
else if (incrementCount + Count > Max) Count = Max;
else Count += incrementCount;
statusChanged.OnNext(CountChangedStatus.Increment);
if (Count == Max) statusChanged.OnNext(CountChangedStatus.Max);
return Disposable.Create(() => this.Decrement(incrementCount));
}
}
/// <summary>
/// Decrement count and notify status.
/// </summary>
public void Decrement(int decrementCount = 1)
{
if (decrementCount < 0)
{
throw new ArgumentException("decrementCount");
}
lock (lockObject)
{
if (Count == 0) return;
else if (Count - decrementCount < 0) Count = 0;
else Count -= decrementCount;
statusChanged.OnNext(CountChangedStatus.Decrement);
if (Count == 0) statusChanged.OnNext(CountChangedStatus.Empty);
}
}
/// <summary>
/// Subscribe observer.
/// </summary>
public IDisposable Subscribe(IObserver<CountChangedStatus> observer)
{
return statusChanged.Subscribe(observer);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1cfa03af5f02d9944a209479ec04c416
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using UniRx.InternalUtil;
namespace UniRx
{
public interface IMessagePublisher
{
/// <summary>
/// Send Message to all receiver.
/// </summary>
void Publish<T>(T message);
}
public interface IMessageReceiver
{
/// <summary>
/// Subscribe typed message.
/// </summary>
IObservable<T> Receive<T>();
}
public interface IMessageBroker : IMessagePublisher, IMessageReceiver
{
}
public interface IAsyncMessagePublisher
{
/// <summary>
/// Send Message to all receiver and await complete.
/// </summary>
IObservable<Unit> PublishAsync<T>(T message);
}
public interface IAsyncMessageReceiver
{
/// <summary>
/// Subscribe typed message.
/// </summary>
IDisposable Subscribe<T>(Func<T, IObservable<Unit>> asyncMessageReceiver);
}
public interface IAsyncMessageBroker : IAsyncMessagePublisher, IAsyncMessageReceiver
{
}
/// <summary>
/// In-Memory PubSub filtered by Type.
/// </summary>
public class MessageBroker : IMessageBroker, IDisposable
{
/// <summary>
/// MessageBroker in Global scope.
/// </summary>
public static readonly IMessageBroker Default = new MessageBroker();
bool isDisposed = false;
readonly Dictionary<Type, object> notifiers = new Dictionary<Type, object>();
public void Publish<T>(T message)
{
object notifier;
lock (notifiers)
{
if (isDisposed) return;
if (!notifiers.TryGetValue(typeof(T), out notifier))
{
return;
}
}
((ISubject<T>)notifier).OnNext(message);
}
public IObservable<T> Receive<T>()
{
object notifier;
lock (notifiers)
{
if (isDisposed) throw new ObjectDisposedException("MessageBroker");
if (!notifiers.TryGetValue(typeof(T), out notifier))
{
ISubject<T> n = new Subject<T>().Synchronize();
notifier = n;
notifiers.Add(typeof(T), notifier);
}
}
return ((IObservable<T>)notifier).AsObservable();
}
public void Dispose()
{
lock (notifiers)
{
if (!isDisposed)
{
isDisposed = true;
notifiers.Clear();
}
}
}
}
/// <summary>
/// In-Memory PubSub filtered by Type.
/// </summary>
public class AsyncMessageBroker : IAsyncMessageBroker, IDisposable
{
/// <summary>
/// AsyncMessageBroker in Global scope.
/// </summary>
public static readonly IAsyncMessageBroker Default = new AsyncMessageBroker();
bool isDisposed = false;
readonly Dictionary<Type, object> notifiers = new Dictionary<Type, object>();
public IObservable<Unit> PublishAsync<T>(T message)
{
UniRx.InternalUtil.ImmutableList<Func<T, IObservable<Unit>>> notifier;
lock (notifiers)
{
if (isDisposed) throw new ObjectDisposedException("AsyncMessageBroker");
object _notifier;
if (notifiers.TryGetValue(typeof(T), out _notifier))
{
notifier = (UniRx.InternalUtil.ImmutableList<Func<T, IObservable<Unit>>>)_notifier;
}
else
{
return Observable.ReturnUnit();
}
}
var data = notifier.Data;
var awaiter = new IObservable<Unit>[data.Length];
for (int i = 0; i < data.Length; i++)
{
awaiter[i] = data[i].Invoke(message);
}
return Observable.WhenAll(awaiter);
}
public IDisposable Subscribe<T>(Func<T, IObservable<Unit>> asyncMessageReceiver)
{
lock (notifiers)
{
if (isDisposed) throw new ObjectDisposedException("AsyncMessageBroker");
object _notifier;
if (!notifiers.TryGetValue(typeof(T), out _notifier))
{
var notifier = UniRx.InternalUtil.ImmutableList<Func<T, IObservable<Unit>>>.Empty;
notifier = notifier.Add(asyncMessageReceiver);
notifiers.Add(typeof(T), notifier);
}
else
{
var notifier = (ImmutableList<Func<T, IObservable<Unit>>>)_notifier;
notifier = notifier.Add(asyncMessageReceiver);
notifiers[typeof(T)] = notifier;
}
}
return new Subscription<T>(this, asyncMessageReceiver);
}
public void Dispose()
{
lock (notifiers)
{
if (!isDisposed)
{
isDisposed = true;
notifiers.Clear();
}
}
}
class Subscription<T> : IDisposable
{
readonly AsyncMessageBroker parent;
readonly Func<T, IObservable<Unit>> asyncMessageReceiver;
public Subscription(AsyncMessageBroker parent, Func<T, IObservable<Unit>> asyncMessageReceiver)
{
this.parent = parent;
this.asyncMessageReceiver = asyncMessageReceiver;
}
public void Dispose()
{
lock (parent.notifiers)
{
object _notifier;
if (parent.notifiers.TryGetValue(typeof(T), out _notifier))
{
var notifier = (ImmutableList<Func<T, IObservable<Unit>>>)_notifier;
notifier = notifier.Remove(asyncMessageReceiver);
parent.notifiers[typeof(T)] = notifier;
}
}
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 000792a29ab226543ba3a8b95504d660
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System;
namespace UniRx
{
/// <summary>
/// Notify value on setuped scheduler.
/// </summary>
public class ScheduledNotifier<T> : IObservable<T>, IProgress<T>
{
readonly IScheduler scheduler;
readonly Subject<T> trigger = new Subject<T>();
/// <summary>
/// Use scheduler is Scheduler.DefaultSchedulers.ConstantTimeOperations.
/// </summary>
public ScheduledNotifier()
{
this.scheduler = Scheduler.DefaultSchedulers.ConstantTimeOperations;
}
/// <summary>
/// Use scheduler is argument's scheduler.
/// </summary>
public ScheduledNotifier(IScheduler scheduler)
{
if (scheduler == null)
{
throw new ArgumentNullException("scheduler");
}
this.scheduler = scheduler;
}
/// <summary>
/// Push value to subscribers on setuped scheduler.
/// </summary>
public void Report(T value)
{
scheduler.Schedule(() => trigger.OnNext(value));
}
/// <summary>
/// Push value to subscribers on setuped scheduler.
/// </summary>
public IDisposable Report(T value, TimeSpan dueTime)
{
var cancel = scheduler.Schedule(dueTime, () => trigger.OnNext(value));
return cancel;
}
/// <summary>
/// Push value to subscribers on setuped scheduler.
/// </summary>
public IDisposable Report(T value, DateTimeOffset dueTime)
{
var cancel = scheduler.Schedule(dueTime, () => trigger.OnNext(value));
return cancel;
}
/// <summary>
/// Subscribe observer.
/// </summary>
public IDisposable Subscribe(IObserver<T> observer)
{
if (observer == null)
{
throw new ArgumentNullException("observer");
}
return trigger.Subscribe(observer);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: dcc7c73fe9a5b944a8c7f0cdc3188104
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using UniRx.Operators;
namespace UniRx
{
public static partial class Observable
{
public static IObservable<TSource> Scan<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
{
return new ScanObservable<TSource>(source, accumulator);
}
public static IObservable<TAccumulate> Scan<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
{
return new ScanObservable<TSource, TAccumulate>(source, seed, accumulator);
}
public static IObservable<TSource> Aggregate<TSource>(this IObservable<TSource> source, Func<TSource, TSource, TSource> accumulator)
{
return new AggregateObservable<TSource>(source, accumulator);
}
public static IObservable<TAccumulate> Aggregate<TSource, TAccumulate>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator)
{
return new AggregateObservable<TSource, TAccumulate>(source, seed, accumulator);
}
public static IObservable<TResult> Aggregate<TSource, TAccumulate, TResult>(this IObservable<TSource> source, TAccumulate seed, Func<TAccumulate, TSource, TAccumulate> accumulator, Func<TAccumulate, TResult> resultSelector)
{
return new AggregateObservable<TSource, TAccumulate, TResult>(source, seed, accumulator, resultSelector);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3f8c1d609aca272409af784bf2bf8873
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,133 @@
#if (NET_4_6 || NET_STANDARD_2_0)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace UniRx
{
public static partial class Observable
{
/// <summary>
/// Gets an awaiter that returns the last value of the observable sequence or throws an exception if the sequence is empty.
/// This operation subscribes to the observable sequence, making it hot.
/// </summary>
/// <param name="source">Source sequence to await.</param>
public static AsyncSubject<TSource> GetAwaiter<TSource>(this IObservable<TSource> source)
{
if (source == null) throw new ArgumentNullException("source");
return RunAsync(source, CancellationToken.None);
}
/// <summary>
/// Gets an awaiter that returns the last value of the observable sequence or throws an exception if the sequence is empty.
/// This operation subscribes to the observable sequence, making it hot.
/// </summary>
/// <param name="source">Source sequence to await.</param>
public static AsyncSubject<TSource> GetAwaiter<TSource>(this IConnectableObservable<TSource> source)
{
if (source == null) throw new ArgumentNullException("source");
return RunAsync(source, CancellationToken.None);
}
/// <summary>
/// Gets an awaiter that returns the last value of the observable sequence or throws an exception if the sequence is empty.
/// This operation subscribes to the observable sequence, making it hot.
/// </summary>
/// <param name="source">Source sequence to await.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public static AsyncSubject<TSource> GetAwaiter<TSource>(this IObservable<TSource> source, CancellationToken cancellationToken)
{
if (source == null) throw new ArgumentNullException("source");
return RunAsync(source, cancellationToken);
}
/// <summary>
/// Gets an awaiter that returns the last value of the observable sequence or throws an exception if the sequence is empty.
/// This operation subscribes to the observable sequence, making it hot.
/// </summary>
/// <param name="source">Source sequence to await.</param>
/// <param name="cancellationToken">Cancellation token.</param>
public static AsyncSubject<TSource> GetAwaiter<TSource>(this IConnectableObservable<TSource> source, CancellationToken cancellationToken)
{
if (source == null) throw new ArgumentNullException("source");
return RunAsync(source, cancellationToken);
}
static AsyncSubject<TSource> RunAsync<TSource>(IObservable<TSource> source, CancellationToken cancellationToken)
{
var s = new AsyncSubject<TSource>();
if (cancellationToken.IsCancellationRequested)
{
return Cancel(s, cancellationToken);
}
var d = source.Subscribe(s);
if (cancellationToken.CanBeCanceled)
{
RegisterCancelation(s, d, cancellationToken);
}
return s;
}
static AsyncSubject<TSource> RunAsync<TSource>(IConnectableObservable<TSource> source, CancellationToken cancellationToken)
{
var s = new AsyncSubject<TSource>();
if (cancellationToken.IsCancellationRequested)
{
return Cancel(s, cancellationToken);
}
var d = source.Subscribe(s);
var c = source.Connect();
if (cancellationToken.CanBeCanceled)
{
RegisterCancelation(s, StableCompositeDisposable.Create(d, c), cancellationToken);
}
return s;
}
static AsyncSubject<T> Cancel<T>(AsyncSubject<T> subject, CancellationToken cancellationToken)
{
subject.OnError(new OperationCanceledException(cancellationToken));
return subject;
}
static void RegisterCancelation<T>(AsyncSubject<T> subject, IDisposable subscription, CancellationToken token)
{
//
// Separate method used to avoid heap allocation of closure when no cancellation is needed,
// e.g. when CancellationToken.None is provided to the RunAsync overloads.
//
var ctr = token.Register(() =>
{
subscription.Dispose();
Cancel(subject, token);
});
//
// No null-check for ctr is needed:
//
// - CancellationTokenRegistration is a struct
// - Registration will succeed 99% of the time, no warranting an attempt to avoid spurious Subscribe calls
//
subject.Subscribe(Stubs<T>.Ignore, _ => ctr.Dispose(), ctr.Dispose);
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee1895654e1d4004f8e28bcabe2271df
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
using System;
using UniRx.Operators;
namespace UniRx
{
public static partial class Observable
{
public static IConnectableObservable<T> Multicast<T>(this IObservable<T> source, ISubject<T> subject)
{
return new ConnectableObservable<T>(source, subject);
}
public static IConnectableObservable<T> Publish<T>(this IObservable<T> source)
{
return source.Multicast(new Subject<T>());
}
public static IConnectableObservable<T> Publish<T>(this IObservable<T> source, T initialValue)
{
return source.Multicast(new BehaviorSubject<T>(initialValue));
}
public static IConnectableObservable<T> PublishLast<T>(this IObservable<T> source)
{
return source.Multicast(new AsyncSubject<T>());
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source)
{
return source.Multicast(new ReplaySubject<T>());
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, IScheduler scheduler)
{
return source.Multicast(new ReplaySubject<T>(scheduler));
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, int bufferSize)
{
return source.Multicast(new ReplaySubject<T>(bufferSize));
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, int bufferSize, IScheduler scheduler)
{
return source.Multicast(new ReplaySubject<T>(bufferSize, scheduler));
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, TimeSpan window)
{
return source.Multicast(new ReplaySubject<T>(window));
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, TimeSpan window, IScheduler scheduler)
{
return source.Multicast(new ReplaySubject<T>(window, scheduler));
}
public static IConnectableObservable<T> Replay<T>(this IObservable<T> source, int bufferSize, TimeSpan window, IScheduler scheduler)
{
return source.Multicast(new ReplaySubject<T>(bufferSize, window, scheduler));
}
public static IObservable<T> RefCount<T>(this IConnectableObservable<T> source)
{
return new RefCountObservable<T>(source);
}
/// <summary>
/// same as Publish().RefCount()
/// </summary>
public static IObservable<T> Share<T>(this IObservable<T> source)
{
return source.Publish().RefCount();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3ec1e019566292e4e8d8491b78d57da3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More