mirror of
https://github.com/storytold/Azure-Kinect-Sample-for-Unity.git
synced 2026-10-11 21:39:58 +00:00
sample
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: InternalsVisibleTo("Unity.Analytics.DataPrivacy.Tests")]
|
||||
[assembly: InternalsVisibleTo("Unity.Analytics.DataPrivacy.WebRequest.Tests")]
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7aad9e80c95b4991a1f4d017c8caf386
|
||||
timeCreated: 1526477558
|
||||
@@ -0,0 +1,132 @@
|
||||
#if ENABLE_CLOUD_SERVICES_ANALYTICS
|
||||
using System;
|
||||
using System.Text;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace UnityEngine.Analytics
|
||||
{
|
||||
public class DataPrivacy
|
||||
{
|
||||
[Serializable]
|
||||
internal struct UserPostData
|
||||
{
|
||||
public string appid;
|
||||
public string userid;
|
||||
public long sessionid;
|
||||
public string platform;
|
||||
public UInt32 platformid;
|
||||
public string sdk_ver;
|
||||
public bool debug_device;
|
||||
public string deviceid;
|
||||
public string plugin_ver;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
internal struct TokenData
|
||||
{
|
||||
public string url;
|
||||
public string token;
|
||||
}
|
||||
|
||||
const string kVersion = "3.0.0";
|
||||
const string kVersionString = "DataPrivacyPackage/" + kVersion;
|
||||
|
||||
internal const string kBaseUrl = "https://data-optout-service.uca.cloud.unity3d.com";
|
||||
const string kTokenUrl = kBaseUrl + "/token";
|
||||
|
||||
internal static UserPostData GetUserData()
|
||||
{
|
||||
var postData = new UserPostData
|
||||
{
|
||||
appid = Application.cloudProjectId,
|
||||
userid = AnalyticsSessionInfo.userId,
|
||||
sessionid = AnalyticsSessionInfo.sessionId,
|
||||
platform = Application.platform.ToString(),
|
||||
platformid = (UInt32)Application.platform,
|
||||
sdk_ver = Application.unityVersion,
|
||||
debug_device = Debug.isDebugBuild,
|
||||
deviceid = SystemInfo.deviceUniqueIdentifier,
|
||||
plugin_ver = kVersionString
|
||||
};
|
||||
|
||||
return postData;
|
||||
}
|
||||
|
||||
static string GetUserAgent()
|
||||
{
|
||||
var message = "UnityPlayer/{0} ({1}/{2}{3} {4})";
|
||||
return String.Format(message,
|
||||
Application.unityVersion,
|
||||
Application.platform.ToString(),
|
||||
(UInt32)Application.platform,
|
||||
Debug.isDebugBuild ? "-dev" : "",
|
||||
kVersionString);
|
||||
}
|
||||
|
||||
static String getErrorString(UnityWebRequest www)
|
||||
{
|
||||
var json = www.downloadHandler.text;
|
||||
var error = www.error;
|
||||
if (String.IsNullOrEmpty(error))
|
||||
{
|
||||
// 5.5 sometimes fails to parse an error response, and the only clue will be
|
||||
// in www.responseHeadersString, which isn't accessible.
|
||||
error = "Empty response";
|
||||
}
|
||||
|
||||
if (!String.IsNullOrEmpty(json))
|
||||
{
|
||||
error += ": " + json;
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
public static void FetchPrivacyUrl(Action<string> success, Action<string> failure = null)
|
||||
{
|
||||
string postJson = JsonUtility.ToJson(GetUserData());
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(postJson);
|
||||
var uploadHandler = new UploadHandlerRaw(bytes);
|
||||
uploadHandler.contentType = "application/json";
|
||||
|
||||
var www = UnityWebRequest.Post(kTokenUrl, "");
|
||||
www.uploadHandler = uploadHandler;
|
||||
#if !UNITY_WEBGL
|
||||
www.SetRequestHeader("User-Agent", GetUserAgent());
|
||||
#endif
|
||||
var async = www.SendWebRequest();
|
||||
|
||||
async.completed += (AsyncOperation async2) =>
|
||||
{
|
||||
var json = www.downloadHandler.text;
|
||||
if (!String.IsNullOrEmpty(www.error) || String.IsNullOrEmpty(json))
|
||||
{
|
||||
var error = getErrorString(www);
|
||||
if (failure != null)
|
||||
{
|
||||
failure(error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TokenData tokenData;
|
||||
tokenData.url = ""; // Just to quell "possibly unassigned" error
|
||||
try
|
||||
{
|
||||
tokenData = JsonUtility.FromJson<TokenData>(json);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (failure != null)
|
||||
{
|
||||
failure(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
success(tokenData.url);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //ENABLE_CLOUD_SERVICES_ANALYTICS
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bff25ea4cf0d3d841b6787b9f649f21b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,52 @@
|
||||
#if ENABLE_CLOUD_SERVICES_ANALYTICS
|
||||
using System;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UnityEngine.Analytics
|
||||
{
|
||||
public class DataPrivacyButton : Button
|
||||
{
|
||||
bool urlOpened = false;
|
||||
|
||||
DataPrivacyButton()
|
||||
{
|
||||
onClick.AddListener(OpenDataPrivacyUrl);
|
||||
}
|
||||
|
||||
void OnFailure(string reason)
|
||||
{
|
||||
interactable = true;
|
||||
Debug.LogWarning(String.Format("Failed to get data privacy url: {0}", reason));
|
||||
}
|
||||
|
||||
void OpenUrl(string url)
|
||||
{
|
||||
interactable = true;
|
||||
urlOpened = true;
|
||||
|
||||
#if UNITY_WEBGL && !UNITY_EDITOR
|
||||
Application.ExternalEval("window.open(\"" + url + "\",\"_blank\")");
|
||||
#else
|
||||
Application.OpenURL(url);
|
||||
#endif
|
||||
}
|
||||
|
||||
void OpenDataPrivacyUrl()
|
||||
{
|
||||
interactable = false;
|
||||
DataPrivacy.FetchPrivacyUrl(OpenUrl, OnFailure);
|
||||
}
|
||||
|
||||
void OnApplicationFocus(bool hasFocus)
|
||||
{
|
||||
if (hasFocus && urlOpened)
|
||||
{
|
||||
urlOpened = false;
|
||||
// Immediately refresh the remote config so new privacy settings can be enabled
|
||||
// as soon as possible if they have changed.
|
||||
RemoteSettings.ForceUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //ENABLE_CLOUD_SERVICES_ANALYTICS
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5ebb11c6fc3a2f498bd89593f7744aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,246 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &109074
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22409074}
|
||||
- 222: {fileID: 22209074}
|
||||
- 114: {fileID: 11409072}
|
||||
m_Layer: 5
|
||||
m_Name: Image
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &109076
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22409076}
|
||||
- 222: {fileID: 22209076}
|
||||
- 114: {fileID: 11409074}
|
||||
- 114: {fileID: 11409076}
|
||||
m_Layer: 5
|
||||
m_Name: DataPrivacyButton
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!1 &109078
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
serializedVersion: 4
|
||||
m_Component:
|
||||
- 224: {fileID: 22409078}
|
||||
- 222: {fileID: 22209078}
|
||||
- 114: {fileID: 11409078}
|
||||
m_Layer: 0
|
||||
m_Name: Text
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &11409072
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109074}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: .196078405, g: .196078405, b: .196078405, a: 1}
|
||||
m_Sprite: {fileID: 21300000, guid: 599a5fd92bab81a4ab02e52d0b1b1c60, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
--- !u!114 &11409074
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109076}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_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!114 &11409076
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109076}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a5ebb11c6fc3a2f498bd89593f7744aa, 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: .960784316, g: .960784316, b: .960784316, a: 1}
|
||||
m_PressedColor: {r: .784313738, g: .784313738, b: .784313738, a: 1}
|
||||
m_DisabledColor: {r: .784313738, g: .784313738, b: .784313738, a: .501960814}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: .100000001
|
||||
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: 11409074}
|
||||
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 &11409078
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109078}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: .196078405, g: .196078405, b: .196078405, a: 1}
|
||||
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_RichText: 0
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Open Data Privacy Page
|
||||
--- !u!222 &22209074
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109074}
|
||||
--- !u!222 &22209076
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109076}
|
||||
--- !u!222 &22209078
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109078}
|
||||
--- !u!224 &22409074
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109074}
|
||||
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: 22409076}
|
||||
m_RootOrder: 1
|
||||
m_AnchorMin: {x: 1, y: .5}
|
||||
m_AnchorMax: {x: 1, y: .5}
|
||||
m_AnchoredPosition: {x: -8, y: 0}
|
||||
m_SizeDelta: {x: 20, y: 20}
|
||||
m_Pivot: {x: 1, y: .5}
|
||||
--- !u!224 &22409076
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109076}
|
||||
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: 22409078}
|
||||
- {fileID: 22409074}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: .5, y: .5}
|
||||
m_AnchorMax: {x: .5, y: .5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 200, y: 30}
|
||||
m_Pivot: {x: .5, y: .5}
|
||||
--- !u!224 &22409078
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 1
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 100100000}
|
||||
m_GameObject: {fileID: 109078}
|
||||
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: 22409076}
|
||||
m_RootOrder: 0
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: .850000024, y: 1}
|
||||
m_AnchoredPosition: {x: 8, y: 0}
|
||||
m_SizeDelta: {x: -12, y: 0}
|
||||
m_Pivot: {x: 0, y: .5}
|
||||
--- !u!1001 &100100000
|
||||
Prefab:
|
||||
m_ObjectHideFlags: 1
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications: []
|
||||
m_RemovedComponents: []
|
||||
m_ParentPrefab: {fileID: 0}
|
||||
m_RootGameObject: {fileID: 109076}
|
||||
m_IsPrefabParent: 1
|
||||
m_IsExploded: 1
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71b11355001648444b41d17fd36c150d
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
@@ -0,0 +1,48 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 599a5fd92bab81a4ab02e52d0b1b1c60
|
||||
TextureImporter:
|
||||
fileIDToRecycleName:
|
||||
664227380: ImportLogs
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 256
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: 16
|
||||
mipBias: -1
|
||||
wrapMode: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: 8
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Unity.Analytics.DataPrivacy",
|
||||
"references": [],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fda7ebe61ab2164383d10e32efb9c6e
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user