diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cadf2d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,42 @@ +[Ll]ibrary/ +[Tt]emp/ +[Oo]bj/ +[Bb]uild/ +[Bb]uilds/ +Assets/AssetStoreTools* + +# Visual Studio cache directory +.vs/ + +# Autogenerated VS/MD/Consulo solution and project files +ExportedObj/ +.consulo/ +*.csproj +*.unityproj +*.sln +*.suo +*.tmp +*.user +*.userprefs +*.pidb +*.booproj +*.svd +*.pdb +*.opendb +*.VC.db + +# Unity3D generated meta files +*.pidb.meta +*.pdb.meta + +# Unity3D Generated File On Crash Reports +sysinfo.txt + +# Builds +*.apk +*.unitypackage + +# Crashlytics generated file +Assets/StreamingAssets/crashlytics-build.properties + + diff --git a/Assets/Scenes.meta b/Assets/Scenes.meta new file mode 100644 index 0000000..17072cf --- /dev/null +++ b/Assets/Scenes.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4f704ae4b4f98ae41a0bce26658850c1 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity new file mode 100644 index 0000000..45fc188 --- /dev/null +++ b/Assets/Scenes/SampleScene.unity @@ -0,0 +1,547 @@ +%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.37311953, g: 0.38074014, b: 0.3587274, a: 1} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 10 + m_Resolution: 2 + m_BakeResolution: 10 + m_AtlasSize: 512 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 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: 256 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 1 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &534669902 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 534669905} + - component: {fileID: 534669904} + - component: {fileID: 534669903} + m_Layer: 0 + m_Name: Main Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &534669903 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 +--- !u!20 &534669904 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_projectionMatrixMode: 1 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_FocalLength: 50 + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &534669905 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 534669902} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &647830407 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 647830408} + - component: {fileID: 647830410} + - component: {fileID: 647830409} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &647830408 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 647830407} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1000883321} + m_RootOrder: 0 + 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 &647830409 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 647830407} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 10 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: Button +--- !u!222 &647830410 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 647830407} + m_CullTransparentMesh: 0 +--- !u!1 &1000883320 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1000883321} + - component: {fileID: 1000883324} + - component: {fileID: 1000883323} + - component: {fileID: 1000883322} + m_Layer: 5 + m_Name: Button + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1000883321 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000883320} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 647830408} + m_Father: {fileID: 1748231024} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 160, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1000883322 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000883320} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1000883323} + m_OnClick: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &1000883323 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000883320} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 +--- !u!222 &1000883324 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1000883320} + m_CullTransparentMesh: 0 +--- !u!1 &1423036222 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1423036225} + - component: {fileID: 1423036224} + - component: {fileID: 1423036223} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1423036223 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1423036222} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1423036224 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1423036222} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1423036225 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1423036222} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1748231019 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1748231024} + - component: {fileID: 1748231023} + - component: {fileID: 1748231022} + - component: {fileID: 1748231021} + - component: {fileID: 1748231020} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1748231020 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1748231019} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4bb6194a881cdb34b8dc729592b2b828, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &1748231021 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1748231019} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1748231022 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1748231019} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1748231023 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1748231019} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &1748231024 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1748231019} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1000883321} + m_Father: {fileID: 0} + m_RootOrder: 1 + 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} diff --git a/Assets/Scenes/SampleScene.unity.meta b/Assets/Scenes/SampleScene.unity.meta new file mode 100644 index 0000000..9531828 --- /dev/null +++ b/Assets/Scenes/SampleScene.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 99c9720ab356a0642a771bea13969a05 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity.meta b/Assets/UITestUnity.meta new file mode 100644 index 0000000..eece680 --- /dev/null +++ b/Assets/UITestUnity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b497581c215629443a8d021d220b4498 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects.meta b/Assets/UITestUnity/GameObjects.meta new file mode 100644 index 0000000..3216c96 --- /dev/null +++ b/Assets/UITestUnity/GameObjects.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 22d53163facae6d47bbbc6b891d5564f +folderAsset: yes +timeCreated: 1478546522 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameButton.cs b/Assets/UITestUnity/GameObjects/GameButton.cs new file mode 100644 index 0000000..d19d340 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameButton.cs @@ -0,0 +1,7 @@ +namespace Xamarin.GameTestServer +{ + public class GameButton : GameElement + { + public string Text { get; set; } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/GameObjects/GameButton.cs.meta b/Assets/UITestUnity/GameObjects/GameButton.cs.meta new file mode 100644 index 0000000..1b5c9f0 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameButton.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: efbf16090a4632340aaea5a4ef644b56 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameCollider.cs b/Assets/UITestUnity/GameObjects/GameCollider.cs new file mode 100644 index 0000000..af9b788 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameCollider.cs @@ -0,0 +1,7 @@ +namespace Xamarin.GameTestServer +{ + public class GameCollider : GameElement + { + public string Text { get; set; } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/GameObjects/GameCollider.cs.meta b/Assets/UITestUnity/GameObjects/GameCollider.cs.meta new file mode 100644 index 0000000..301527d --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameCollider.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 02bbe719bdd3d104489728cad8edafca +timeCreated: 1477698947 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameElement.cs b/Assets/UITestUnity/GameObjects/GameElement.cs new file mode 100644 index 0000000..794de4c --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameElement.cs @@ -0,0 +1,34 @@ +using System; +using System.Drawing; + +namespace Xamarin.GameTestServer +{ + public class GameElement + { + public string Name { get; set; } + public string Id { get; set; } + public string Type { get; set; } + public string Parent { get; set; } + public string[] Children { get; set; } + + public PointF Location { get; set; } + public RectangleF Rectangle { get; set;} + public bool? IsOnScreen { get; set; } + + public static T InitFrom(GameElement elm) where T : GameElement + { + var t = Activator.CreateInstance(); + t.Name = elm.Name; + t.Id = elm.Id; + t.Type = elm.Type; + t.Parent = elm.Parent; + t.Children = elm.Children; + t.Location = elm.Location; + t.Rectangle = elm.Rectangle; + t.IsOnScreen = elm.IsOnScreen; + + return t; + } + } +} + diff --git a/Assets/UITestUnity/GameObjects/GameElement.cs.meta b/Assets/UITestUnity/GameObjects/GameElement.cs.meta new file mode 100644 index 0000000..1562ac6 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameElement.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1c258306a4d7184449f123e8e9a196dc +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameElementExtensions.cs b/Assets/UITestUnity/GameObjects/GameElementExtensions.cs new file mode 100644 index 0000000..c6f56f9 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameElementExtensions.cs @@ -0,0 +1,145 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Drawing; +using System; + +namespace Xamarin.GameTestServer +{ + static partial class GameElementExtension + { + public static GameElement ToGameObject(this object obj) + { + var gobj = obj as GameObject; + if (gobj != null) + { + return new GameElement + { + Id = gobj.GetInstanceID().ToString(), + Name = gobj.name + }; + } + + return null; + } + + private static GameElement GetProperties(UnityEngine.Object go) + { + var elm = new GameElement + { + Name = go.name, + Id = go.GetInstanceID().ToString(), + Type = typeof(GameObject).ToString(), + IsOnScreen = null + }; + + if (go.GetType().IsSubclassOf(typeof(Component)) || go.GetType() == typeof(Component)) + { + var gc = (Component)go; + var tf = gc.GetComponent(); + if (tf != null) + { + float x = tf.position.x; + float y = tf.position.y; + var parent = tf.parent?.name; + + var children = new string[tf.childCount]; + int i = 0; + foreach (Transform child in tf.transform) + children[i++] = child.name; + + elm.Rectangle = new RectangleF(x, y, tf.rect.width, tf.rect.height); + elm.Location = new PointF(x, y); + elm.Parent = parent; + elm.Children = children; + elm.IsOnScreen = gc.gameObject.activeSelf; + } + } + + return elm; + } + + public static T ToGameElement(this UnityEngine.Object obj) where T : GameElement + { + return (T)ToGameElement(obj, typeof(T)); + } + + public static GameElement ToGameElement(this UnityEngine.Object obj, Type type) + { + var go = GetProperties(obj); + if (type == typeof(Text) || type == typeof(GameText)) + { + var text = obj as Text; + if (text != null) + { + var gt = GameText.InitFrom(go); + gt.Text = text.text; + gt.Type = text.GetType().ToString(); + + return gt; + } + } + else if (type == typeof(Button) || type == typeof(GameButton)) + { + var btn = obj as Button; + if (btn != null) + { + var txtComponent = btn.GetComponentInChildren(); + string txt = (txtComponent == null) ? "" : txtComponent.text; + + var gb = GameButton.InitFrom(go); + gb.Text = txt; + gb.Type = btn.GetType().ToString(); + + return gb; + } + } + else if (type == typeof(InputField) || type == typeof(GameInputField)) + { + var input = obj as InputField; + if (input != null) + { + var gi = GameInputField.InitFrom(go); + gi.Text = input.text; + gi.Type = input.GetType().ToString(); + + return gi; + } + } + else if (type == typeof(Image) || type == typeof(GameImage)) + { + var image = obj as Image; + if (image != null) + { + var gi = GameImage.InitFrom(go); + gi.Color = ColorUtility.ToHtmlStringRGB(image.color); + gi.Type = image.GetType().ToString(); + + return gi; + } + } + else + { + return go; + } + + throw new Exception("Could not convert GameElement"); + } + + public static RectangleF ToRectangle(this Bounds rect) + { + return new RectangleF(rect.min.x, rect.min.y, rect.size.x, rect.size.y); + } + public static RectangleF ToRectangle(this Rect rect) + { + return new RectangleF(rect.x, rect.y, rect.width, rect.height); + } + public static PointF ToPoint(this Vector2 vector) + { + return new PointF(vector.x, vector.y); + } + public static PointF ToPoint(this Vector3 vector) + { + return new PointF(vector.x, vector.y); + } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/GameObjects/GameElementExtensions.cs.meta b/Assets/UITestUnity/GameObjects/GameElementExtensions.cs.meta new file mode 100644 index 0000000..8bc2e6b --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameElementExtensions.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c87f6bf2b8d5a2647a2399d7765b38a0 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameImage.cs b/Assets/UITestUnity/GameObjects/GameImage.cs new file mode 100644 index 0000000..6a52ef4 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameImage.cs @@ -0,0 +1,7 @@ +namespace Xamarin.GameTestServer +{ + public class GameImage : GameElement + { + public string Color { get; set; } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/GameObjects/GameImage.cs.meta b/Assets/UITestUnity/GameObjects/GameImage.cs.meta new file mode 100644 index 0000000..3d7fa82 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d3d6947b8f924ae40b8cdc5d78ae82ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameInputField.cs b/Assets/UITestUnity/GameObjects/GameInputField.cs new file mode 100644 index 0000000..f8590d4 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameInputField.cs @@ -0,0 +1,7 @@ +namespace Xamarin.GameTestServer +{ + public class GameInputField : GameElement + { + public string Text { get; set; } + } +} diff --git a/Assets/UITestUnity/GameObjects/GameInputField.cs.meta b/Assets/UITestUnity/GameObjects/GameInputField.cs.meta new file mode 100644 index 0000000..399f077 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameInputField.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d3a6195025a8a12439943afc83be85da +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameObjects/GameText.cs b/Assets/UITestUnity/GameObjects/GameText.cs new file mode 100644 index 0000000..4be527d --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameText.cs @@ -0,0 +1,7 @@ +namespace Xamarin.GameTestServer +{ + public class GameText : GameElement + { + public string Text { get; set; } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/GameObjects/GameText.cs.meta b/Assets/UITestUnity/GameObjects/GameText.cs.meta new file mode 100644 index 0000000..5f2fe17 --- /dev/null +++ b/Assets/UITestUnity/GameObjects/GameText.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ed4985e0c6f85754184dac202d3dd1a2 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/GameServer.cs b/Assets/UITestUnity/GameServer.cs new file mode 100644 index 0000000..8d6ef01 --- /dev/null +++ b/Assets/UITestUnity/GameServer.cs @@ -0,0 +1,130 @@ +using System; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading; +using UnityEngine; + +namespace Xamarin.GameTestServer +{ + public static class Utils + { + public static HttpMethod ConvertMethod(string method) + { + switch (method.ToUpper()) + { + case "GET": + return HttpMethod.Get; + case "POST": + return HttpMethod.Post; + case "PUT": + return HttpMethod.Put; + case "DELETE": + return HttpMethod.Delete; + } + + throw new Exception("Could not parse method"); + } + } + + /// + /// The webserver itself + /// + public class GameServer + { + private readonly int PORT = 8081; + static GameServer shared; + + public static GameServer Shared { + get { + return shared ?? (shared = new GameServer ()); + } + set { + shared = value; + } + } + + private readonly HttpListener _listener = new HttpListener (); + + public GameServer () + { + if (!HttpListener.IsSupported) + throw new NotSupportedException ("Http Listener is not supported"); + + var prefixes = new [] { + $"http://*:{PORT}/", + }; + + foreach (string s in prefixes) + _listener.Prefixes.Add (s); + + _listener.Start (); + } + + /// + /// Starts the server. + /// + public void Start () + { + Loom.Init (); + _listener.Start (); + ThreadPool.QueueUserWorkItem ((o) => + { + Debug.Log ("Webserver running 1..."); + + try { + while (_listener.IsListening) { + ThreadPool.QueueUserWorkItem ((c) => + { + var ctx = c as HttpListenerContext; + try { + byte[] buf = ProcessReponse (ctx); + if (buf != null) { + ctx.Response.ContentLength64 = buf.Length; + ctx.Response.OutputStream.Write (buf, 0, buf.Length); + } + } catch (Exception e) { + Console.WriteLine (e); + ctx.Response.StatusCode = 500; + } finally { + // always close the stream + ctx.Response.OutputStream.Close (); + } + }, _listener.GetContext ()); + } + } catch (Exception ex) { + Console.WriteLine (ex); + } + }); + } + + byte[] ProcessReponse (HttpListenerContext context) + { + var request = context.Request; + try { + Debug.Log("Raw URL:" + request.RawUrl); + var path = string.IsNullOrEmpty(request.Url.Query) ? request.RawUrl : request.RawUrl.Replace(request.Url.Query,""); + if (path == "/") + return new byte[0]; + + path = path.TrimStart ('/'); + Debug.Log (string.Format("Path: {0}", path)); + var route = Router.GetRoute (path); + if (!route.SupportsMethod (Utils.ConvertMethod(context.Request.HttpMethod))) { + context.Response.StatusCode = 405; + var error = "Unsupported method: " + context.Response.StatusCode; + Debug.LogError(error); + return Encoding.ASCII.GetBytes(error); + } + + context.Response.ContentType = route.ContentType; + return route.GetResponseBytes (request); + } catch (Exception ex) { + Debug.LogError(ex); + context.Response.StatusCode = 404; + return Encoding.ASCII.GetBytes(ex.Message); + } + } + + } +} diff --git a/Assets/UITestUnity/GameServer.cs.meta b/Assets/UITestUnity/GameServer.cs.meta new file mode 100644 index 0000000..e5b3032 --- /dev/null +++ b/Assets/UITestUnity/GameServer.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b5cb1310f2fa88340abc450e2b9d2f51 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Router.meta b/Assets/UITestUnity/Router.meta new file mode 100644 index 0000000..8e43c7b --- /dev/null +++ b/Assets/UITestUnity/Router.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fe64e5065604f104c9f4e2ada5f2824f +folderAsset: yes +timeCreated: 1478546522 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Router/Loom.cs b/Assets/UITestUnity/Router/Loom.cs new file mode 100644 index 0000000..d889d67 --- /dev/null +++ b/Assets/UITestUnity/Router/Loom.cs @@ -0,0 +1,100 @@ +using UnityEngine; +using System.Collections.Generic; +using System; +using System.Threading; +using System.Linq; + +[ExecuteInEditMode] +public class Loom : MonoBehaviour +{ + private static Loom _current; + private int _count; + private List _actions = new List(); + private List _delayed = new List(); + + public static Loom Current + { + get { + return _current; + } + } + + public static void Init() + { + if (_current == null) + { + var g = new GameObject("Loom"); + g.hideFlags = HideFlags.HideAndDontSave; + _current = g.AddComponent(); + } + } + + public class DelayedQueueItem + { + public float time; + public Action action; + } + + public static void QueueOnMainThread(Action action) + { + QueueOnMainThread( action, 0f); + } + + public static void QueueOnMainThread(Action action, float time) + { + if(time != 0) + { + lock(Current._delayed) + { + Current._delayed.Add(new DelayedQueueItem { time = Time.time + time, action = action}); + } + } + else + { + lock (Current._actions) + { + Current._actions.Add(action); + } + } + } + + public static void RunAsync(Action a) + { + var t = new Thread(RunAction); + t.Priority = System.Threading.ThreadPriority.Normal; + t.Start(a); + } + + private static void RunAction(object action) + { + ((Action)action)(); + } + + void OnDisable() + { + if (_current == this) + _current = null; + } + + void Update() + { + var actions = new List(); + lock (_actions) + { + actions.AddRange(_actions); + _actions.Clear(); + foreach(var a in actions) + { + a(); + } + } + lock(_delayed) + { + foreach(var delayed in _delayed.Where(d=>d.time <= Time.time).ToList()) + { + _delayed.Remove(delayed); + delayed.action(); + } + } + } +} diff --git a/Assets/UITestUnity/Router/Loom.cs.meta b/Assets/UITestUnity/Router/Loom.cs.meta new file mode 100644 index 0000000..314adbd --- /dev/null +++ b/Assets/UITestUnity/Router/Loom.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e9529a5c0e9360e489242785ee6406a7 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Router/Route.cs b/Assets/UITestUnity/Router/Route.cs new file mode 100644 index 0000000..421a262 --- /dev/null +++ b/Assets/UITestUnity/Router/Route.cs @@ -0,0 +1,110 @@ +using System; +using System.Net; +using System.IO; +using System.Text; +using System.Collections.Specialized; +using UnityEngine; +using System.Net.Http; +using System.Threading; + +namespace Xamarin.GameTestServer +{ + public abstract class Route + { + public abstract bool SupportsMethod (HttpMethod method); + + public virtual string ContentType { + get { + return "application/json"; + } + } + + public virtual string GetResponseString (HttpMethod method, NameValueCollection queryString, string data) + { + throw new Exception ("You need to provide either GetResponseString or GetResponseBytes"); + } + + public virtual string GetResponseString (HttpListenerRequest request) + { + return null; + } + + public virtual byte[] GetResponseBytes (HttpListenerRequest request) + { + var responseString = GetResponseString (request); + if (responseString != null) { + return Encoding.UTF8.GetBytes (responseString); + } + + var method = Utils.ConvertMethod(request.HttpMethod); + + string data; + using (var reader = new StreamReader (request.InputStream)) + data = reader.ReadToEnd (); + + //Unity does not handle query strings properly. So we need to get it our self. + var queryString = CreateQueryString(request.Url.Query); + + var responseData = GetResponseBytes(method, queryString, data); + + if (responseData != null) + return responseData; + + responseString = GetResponseString (method, queryString,data); + return Encoding.UTF8.GetBytes (responseString); + } + + public virtual byte[] GetResponseBytes(HttpMethod method, NameValueCollection queryString, string data) + { + return null; + } + + public static NameValueCollection CreateQueryString (string query) + { + if (query == null || query.Length == 0) { + return new NameValueCollection (1); + } + + var query_string = new NameValueCollection (); + if (query [0] == '?') + query = query.Substring (1); + string [] components = query.Split ('&'); + foreach (string kv in components) { + int pos = kv.IndexOf ('='); + if (pos == -1) { + query_string.Add (null, WWW.UnEscapeURL (kv)); + } else { + string key = WWW.UnEscapeURL(kv.Substring (0, pos)); + string val = WWW.UnEscapeURL (kv.Substring (pos + 1)); + + query_string.Add (key, val); + } + } + return query_string; + } + + public void RunInUIThread(Action t) + { + bool completed = false; + Loom.QueueOnMainThread(() => { + try + { + t.Invoke(); + } + catch (Exception ex) + { + Debug.LogError(ex); + } + finally + { + completed = true; + } + }); + while (!completed) + { + Thread.Sleep(100); + } + } + } +} + diff --git a/Assets/UITestUnity/Router/Route.cs.meta b/Assets/UITestUnity/Router/Route.cs.meta new file mode 100644 index 0000000..01fa1b6 --- /dev/null +++ b/Assets/UITestUnity/Router/Route.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 05edbe039568b1640a937044dc2f315d +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Router/RouteT.cs b/Assets/UITestUnity/Router/RouteT.cs new file mode 100644 index 0000000..5826dfc --- /dev/null +++ b/Assets/UITestUnity/Router/RouteT.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; +using System.Collections.Specialized; +using System.Net.Http; + +namespace Xamarin.GameTestServer +{ + public abstract class Route : Route + { + public abstract T GetResponse (HttpMethod method, NameValueCollection queryString, string data); + + public override string GetResponseString (HttpMethod method, NameValueCollection queryString, string data) + { + return JsonConvert.SerializeObject(GetResponse (method, queryString, data)); + } + } +} \ No newline at end of file diff --git a/Assets/UITestUnity/Router/RouteT.cs.meta b/Assets/UITestUnity/Router/RouteT.cs.meta new file mode 100644 index 0000000..d9d96c4 --- /dev/null +++ b/Assets/UITestUnity/Router/RouteT.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 94fd2b53f4faf82489f0baa585b16fdd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Router/Router.cs b/Assets/UITestUnity/Router/Router.cs new file mode 100644 index 0000000..ba8d904 --- /dev/null +++ b/Assets/UITestUnity/Router/Router.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; + +namespace Xamarin.GameTestServer +{ + public static class Router + { + static Router() + { + UnityRoutes.Enable (); + } + + static Dictionary routes = new Dictionary(); + public static void AddRoute(string path,Route route) + { + routes [path.ToLower()] = route; + } + + public static Route GetRoute (string path) + { + Route route; + routes.TryGetValue (path.ToLower(), out route); + return route; + } + } +} + diff --git a/Assets/UITestUnity/Router/Router.cs.meta b/Assets/UITestUnity/Router/Router.cs.meta new file mode 100644 index 0000000..218a254 --- /dev/null +++ b/Assets/UITestUnity/Router/Router.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 649c5e9d95bab7941a8717fe70599184 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Routes.meta b/Assets/UITestUnity/Routes.meta new file mode 100644 index 0000000..bc4c5ec --- /dev/null +++ b/Assets/UITestUnity/Routes.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ea17180bc713c30479d1f6de76ade8f9 +folderAsset: yes +timeCreated: 1478546522 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Routes/CurrentScreenRoute.cs b/Assets/UITestUnity/Routes/CurrentScreenRoute.cs new file mode 100644 index 0000000..3cd1fab --- /dev/null +++ b/Assets/UITestUnity/Routes/CurrentScreenRoute.cs @@ -0,0 +1,34 @@ +using System.Net; +using System.Net.Http; + +namespace Xamarin.GameTestServer.Unity +{ + /// + /// Gets current screen + /// + public class CurrentScreenRoute : Route + { + public static string RoutePath = "CurrentScreen"; + public static void Enable() + { + Router.AddRoute (RoutePath, new CurrentScreenRoute ()); + } + + public override bool SupportsMethod (HttpMethod method) + { + return method == HttpMethod.Get; + } + + public override string GetResponseString(HttpListenerRequest request) + { + string screenName = ""; + RunInUIThread(() => + { + screenName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; + }); + + return screenName; + } + } +} + diff --git a/Assets/UITestUnity/Routes/CurrentScreenRoute.cs.meta b/Assets/UITestUnity/Routes/CurrentScreenRoute.cs.meta new file mode 100644 index 0000000..0982b0a --- /dev/null +++ b/Assets/UITestUnity/Routes/CurrentScreenRoute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 77eace8895ea4fe4caa357603f157df6 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Routes/DeviceInfoRoute.cs b/Assets/UITestUnity/Routes/DeviceInfoRoute.cs new file mode 100644 index 0000000..0f23429 --- /dev/null +++ b/Assets/UITestUnity/Routes/DeviceInfoRoute.cs @@ -0,0 +1,43 @@ +using UnityEngine; +using System.Collections.Specialized; +using System.Net.Http; + +namespace Xamarin.GameTestServer.Unity +{ + public class DeviceInfo + { + public int Height { get; set; } + public int Width { get; set; } + public float DPI { get; set; } + } + + /// + /// Gets basic device info + /// + public class DeviceInfoRoute : Route + { + public static readonly string RoutePath = "DeviceInfo"; + public static void Enable() + { + Router.AddRoute(RoutePath, new DeviceInfoRoute()); + } + + public override bool SupportsMethod(HttpMethod method) + { + return method == HttpMethod.Get; + } + + public override DeviceInfo GetResponse(HttpMethod method, NameValueCollection queryString, string data) + { + var device = new DeviceInfo(); + RunInUIThread(() => + { + device.Height = Screen.height; + device.Width = Screen.width; + device.DPI = Screen.dpi; + }); + + return device; + } + } +} diff --git a/Assets/UITestUnity/Routes/DeviceInfoRoute.cs.meta b/Assets/UITestUnity/Routes/DeviceInfoRoute.cs.meta new file mode 100644 index 0000000..1e5d954 --- /dev/null +++ b/Assets/UITestUnity/Routes/DeviceInfoRoute.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 502fbc6f4696148359d16a7c51123e95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Routes/GameObjectFind.cs b/Assets/UITestUnity/Routes/GameObjectFind.cs new file mode 100644 index 0000000..e087bc3 --- /dev/null +++ b/Assets/UITestUnity/Routes/GameObjectFind.cs @@ -0,0 +1,58 @@ +using System; +using UnityEngine; +using System.Collections.Generic; +using System.Net.Http; +using System.Collections.Specialized; + +namespace Xamarin.GameTestServer.Unity +{ + public class GameObjectFind : Route> + { + public static readonly string RoutePath = "GameObjectFind"; + + public static void Enable() + { + Router.AddRoute(RoutePath, new GameObjectFind()); + } + + public override bool SupportsMethod (HttpMethod method) { return method == HttpMethod.Get; } + + public override IEnumerable GetResponse (HttpMethod method, NameValueCollection queryString, string data) + { + var typeName = queryString?.Get("type"); + var objectName = queryString?.Get("name"); + + Type type = typeof(GameObject); + if (!string.IsNullOrEmpty(typeName) && typeName != "GameObject") + { + type = Type.GetType(string.Format("UnityEngine.UI.{0},UnityEngine.UI", typeName)); + } + + var elements = new List(); + + RunInUIThread(() => + { + var objects = GameObject.FindObjectsOfType(type); + foreach (var obj in objects) + { + if (!string.IsNullOrEmpty(objectName)) + { + if (obj.name == objectName) + { + var elem = obj.ToGameElement(type); + elements.Add(elem); + } + } + else + { + var elem = obj.ToGameElement(type); + elements.Add(elem); + } + } + }); + + return elements; + } + } +} + diff --git a/Assets/UITestUnity/Routes/GameObjectFind.cs.meta b/Assets/UITestUnity/Routes/GameObjectFind.cs.meta new file mode 100644 index 0000000..4b4d1dc --- /dev/null +++ b/Assets/UITestUnity/Routes/GameObjectFind.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f2041a180ba63844eb4641a5344bace7 +timeCreated: 1466550758 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/UITestUnity/Routes/InvokeButtonRoute.cs b/Assets/UITestUnity/Routes/InvokeButtonRoute.cs new file mode 100644 index 0000000..3bbfba8 --- /dev/null +++ b/Assets/UITestUnity/Routes/InvokeButtonRoute.cs @@ -0,0 +1,36 @@ +using System.Collections.Specialized; +using System.Linq; +using System.Net.Http; +using UnityEngine; +using UnityEngine.UI; + +namespace Xamarin.GameTestServer.Unity +{ + /// + /// Invokes click event on button + /// + public class InvokeButtonRoute : Route + { + public static readonly string RoutePath = "InvokeButton"; + + public static void Enable() + { + Router.AddRoute(RoutePath, new InvokeButtonRoute()); + } + + public override bool SupportsMethod(HttpMethod method) { return method == HttpMethod.Post; } + + public override GameButton GetResponse(HttpMethod method, NameValueCollection queryString, string data) + { + var objectName = queryString?.Get("name"); + var buttonElm = new GameButton(); + RunInUIThread(() => + { + var btn = GameObject.FindObjectsOfType