test
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"displayName": "Unity Remote",
|
||||
"description": "An example with a simple scene for trying out the Unity Remote app."
|
||||
}
|
@@ -0,0 +1,79 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: CubeMaterial
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.9339623, g: 0.13719928, b: 0.13719928, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c8809e96fa09da04aa2008b186fdf0fc
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
# Unity Remote Sample
|
||||
|
||||
This sample is just a simple scene that lets you see try out the Unity Remote app. The app is useful for quickly testing your project in the Unity Editor without having to build and deploy to the device. This is supported for iOS and Android.
|
||||
|
||||
More detailed information about the Unity Remote can be found in the [Unity manual](https://docs.unity3d.com/Manual/UnityRemote5.html).
|
||||
|
||||
Instructions:
|
||||
|
||||
1. Install the Unity Remote app on your Android or iOS device.
|
||||
2. Connect the device to your computer via USB. On Android, make sure you have the Android SDK installed and configured appropriately in Unity. Also, USB debugging needs to be enabled.
|
||||
3. In Unity, go to `Edit > Project Settings > Editor` and select the device in the `Unity Remote` section.
|
||||

|
||||
4. Open the Unity Remote app on the device.
|
||||
5. Open the [`UnityRemoteTest.unity`](UnityRemoteTest.unity) scene from this sample.
|
||||
6. Enter play mode. After a short delay, the Unity Remote app on your device should switch to display the scene and you should be able to interact with the scene in the editor using the device.
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22bf16ad6e7ca7c41bf5234d582dc1f4
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,98 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cb428ad990f451498488aab4b461b70
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 11
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMasterTextureLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2d420239a8de8f418c9038894f5349c
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,178 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.EnhancedTouch;
|
||||
using UnityEngine.UI;
|
||||
using Gyroscope = UnityEngine.InputSystem.Gyroscope;
|
||||
using Touch = UnityEngine.InputSystem.EnhancedTouch.Touch;
|
||||
|
||||
public class UnityRemoteTestScript : MonoBehaviour
|
||||
{
|
||||
// Suppress harmless warning about overriding camera from UnityEngine.Component.camera where this property have been
|
||||
// marked obsolete/deprecated and depending on Unity version this warning may trigger when building a player.
|
||||
// warning CS0109: The member 'UnityRemoteTestScript.camera' does not hide an accessible member. The new keyword is not required.
|
||||
#pragma warning disable 0109
|
||||
public new Camera camera;
|
||||
#pragma warning restore 0109
|
||||
|
||||
public Text accelerometerInputText;
|
||||
public Text touchInputText;
|
||||
public Text gyroInputText;
|
||||
|
||||
// We rotate this cube based on gyro input. Also, we sync its position on screen
|
||||
// the position of the primary touch.
|
||||
public Transform rotatingCube;
|
||||
|
||||
private Vector3 m_Rotation;
|
||||
private float m_CubeOffsetFromCanvas;
|
||||
private Vector3 m_CubeStartingPosition;
|
||||
|
||||
public void ResetCube()
|
||||
{
|
||||
rotatingCube.SetPositionAndRotation(m_CubeStartingPosition, default);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_CubeOffsetFromCanvas = rotatingCube.position.z - transform.position.z;
|
||||
m_CubeStartingPosition = rotatingCube.position;
|
||||
|
||||
EnhancedTouchSupport.Enable();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
EnhancedTouchSupport.Disable();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
UpdateTouch();
|
||||
UpdateAccelerometer();
|
||||
UpdateGyro();
|
||||
}
|
||||
|
||||
private void UpdateTouch()
|
||||
{
|
||||
var touchscreen = GetRemoteDevice<Touchscreen>();
|
||||
if (touchscreen == null)
|
||||
{
|
||||
touchInputText.text = "No remote touchscreen found.";
|
||||
return;
|
||||
}
|
||||
|
||||
// Dump active touches.
|
||||
string activeTouches = null;
|
||||
foreach (var touch in Touch.activeTouches)
|
||||
{
|
||||
// Skip any touch not from our remote touchscreen.
|
||||
if (touch.screen != touchscreen)
|
||||
continue;
|
||||
|
||||
if (activeTouches == null)
|
||||
activeTouches = "Active Touches:\n";
|
||||
|
||||
activeTouches += $"\nid={touch.touchId} phase={touch.phase} position={touch.screenPosition} pressure={touch.pressure}\n";
|
||||
}
|
||||
if (activeTouches == null)
|
||||
activeTouches = "No active touches.";
|
||||
touchInputText.text = activeTouches;
|
||||
|
||||
// Find world-space position of current primary touch (if any).
|
||||
if (touchscreen.primaryTouch.isInProgress)
|
||||
{
|
||||
var touchPosition = touchscreen.primaryTouch.position.ReadValue();
|
||||
var worldSpacePosition =
|
||||
camera.ScreenToWorldPoint(new Vector3(touchPosition.x, touchPosition.y, transform.position.z + m_CubeOffsetFromCanvas));
|
||||
rotatingCube.position = worldSpacePosition;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateAccelerometer()
|
||||
{
|
||||
var accelerometer = GetRemoteDevice<Accelerometer>();
|
||||
if (accelerometer == null)
|
||||
{
|
||||
accelerometerInputText.text = "No remote accelerometer found.";
|
||||
return;
|
||||
}
|
||||
|
||||
var value = accelerometer.acceleration.ReadValue();
|
||||
accelerometerInputText.text = $"Accelerometer: x={value.x} y={value.y} z={value.z}";
|
||||
}
|
||||
|
||||
private void UpdateGyro()
|
||||
{
|
||||
var gyro = GetRemoteDevice<Gyroscope>();
|
||||
var attitude = GetRemoteDevice<AttitudeSensor>();
|
||||
var gravity = GetRemoteDevice<GravitySensor>();
|
||||
var acceleration = GetRemoteDevice<LinearAccelerationSensor>();
|
||||
|
||||
// Enable gyro from remote, if needed.
|
||||
EnableDeviceIfNeeded(gyro);
|
||||
EnableDeviceIfNeeded(attitude);
|
||||
EnableDeviceIfNeeded(gravity);
|
||||
EnableDeviceIfNeeded(acceleration);
|
||||
|
||||
string text;
|
||||
if (gyro == null && attitude == null && gravity == null && acceleration == null)
|
||||
{
|
||||
text = "No remote gyro found.";
|
||||
}
|
||||
else
|
||||
{
|
||||
string gyroText = null;
|
||||
string attitudeText = null;
|
||||
string gravityText = null;
|
||||
string accelerationText = null;
|
||||
|
||||
if (gyro != null)
|
||||
{
|
||||
var rotation = gyro.angularVelocity.ReadValue();
|
||||
gyroText = $"Rotation: x={rotation.x} y={rotation.y} z={rotation.z}";
|
||||
|
||||
// Update rotation of cube.
|
||||
m_Rotation += rotation;
|
||||
rotatingCube.localEulerAngles = m_Rotation;
|
||||
}
|
||||
|
||||
if (attitude != null)
|
||||
{
|
||||
var attitudeValue = attitude.attitude.ReadValue();
|
||||
attitudeText = $"Attitude: x={attitudeValue.x} y={attitudeValue.y} z={attitudeValue.z} w={attitudeValue.w}";
|
||||
}
|
||||
|
||||
if (gravity != null)
|
||||
{
|
||||
var gravityValue = gravity.gravity.ReadValue();
|
||||
gravityText = $"Gravity: x={gravityValue.x} y={gravityValue.y} z={gravityValue.z}";
|
||||
}
|
||||
|
||||
if (acceleration != null)
|
||||
{
|
||||
var accelerationValue = acceleration.acceleration.ReadValue();
|
||||
accelerationText = $"Acceleration: x={accelerationValue.x} y={accelerationValue.y} z={accelerationValue.z}";
|
||||
}
|
||||
|
||||
text = string.Join("\n", gyroText, attitudeText, gravityText, accelerationText);
|
||||
}
|
||||
|
||||
gyroInputText.text = text;
|
||||
}
|
||||
|
||||
private static void EnableDeviceIfNeeded(InputDevice device)
|
||||
{
|
||||
if (device != null && !device.enabled)
|
||||
InputSystem.EnableDevice(device);
|
||||
}
|
||||
|
||||
// Make sure we're not thrown off track by locally having sensors on the device. Instead
|
||||
// explicitly grab the remote ones.
|
||||
private static TDevice GetRemoteDevice<TDevice>()
|
||||
where TDevice : InputDevice
|
||||
{
|
||||
foreach (var device in InputSystem.devices)
|
||||
if (device.remote && device is TDevice deviceOfType)
|
||||
return deviceOfType;
|
||||
return default;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5a183b25bd96f6941b6803a60091cd1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user