GitHub Enterprise
3 年前
当前提交
f2b625c8
共有 16 个文件被更改,包括 1007 次插入 和 118 次删除
-
8com.unity.perception/Editor/Randomization/Editors/RunInUnitySimulationWindow.cs
-
6com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
301com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/ScenarioTests.cs
-
210com.unity.perception/Runtime/PerceptionAnalytics.cs
-
3com.unity.perception/Runtime/PerceptionAnalytics.cs.meta
-
360com.unity.perception/Runtime/PerceptionAnalyticsStructs.cs
-
3com.unity.perception/Runtime/PerceptionAnalyticsStructs.cs.meta
-
50com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/AllMembersAndParametersTestRandomizer.cs
-
11com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/AllMembersAndParametersTestRandomizer.cs.meta
-
24com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/Resources/sampleAnimationPoseConfig.asset
-
8com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/Resources/sampleAnimationPoseConfig.asset.meta
-
23com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/Resources/sampleIdLabelConfig.asset
-
8com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/Resources/sampleIdLabelConfig.asset.meta
-
8TestProjects/PerceptionHDRP/Assets/Scenes.meta
-
3com.unity.perception/Editor/Randomization/Editors/PerceptionEditorAnalytics.cs.meta
-
99com.unity.perception/Editor/Randomization/Editors/PerceptionEditorAnalytics.cs
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using Unity.Simulation; |
|||
using UnityEngine.Analytics; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.Perception.Randomization.Randomizers; |
|||
using UnityEngine.Perception.Randomization.Scenarios; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
|
|||
namespace UnityEngine.Perception.Analytics |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// Editor and Runtime analytics for the Perception package.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// To add an event:
|
|||
/// 1. Create a constant with the name of the event (eg: <see cref="k_EventScenarioInformation"/>)
|
|||
/// 2. Add the constant to <see cref="allEvents" />
|
|||
/// 3. Create a function that will report data for the event and at the start of it call
|
|||
/// <see cref="TryRegisterPerceptionAnalyticsEvent" /> with the event name defined in step 1.
|
|||
/// Note: Remember to use the conditional "#if UNITY_EDITOR" if adding editor analytics.
|
|||
/// </remarks>
|
|||
public static class PerceptionAnalytics |
|||
{ |
|||
const string k_VendorKey = "unity.perception"; |
|||
const int k_MaxElementsInStruct = 100; |
|||
const int k_MaxEventsPerHour = 100; |
|||
|
|||
#region Setup
|
|||
[RuntimeInitializeOnLoadMethod] |
|||
static void OnInitializeOnLoad() |
|||
{ |
|||
Manager.Instance.ShutdownNotification += OnSimulationShutdown; |
|||
} |
|||
|
|||
static void OnSimulationShutdown() |
|||
{ |
|||
var perceptionCamera = Object.FindObjectOfType<PerceptionCamera>(); |
|||
ReportScenarioInformation( |
|||
perceptionCamera, |
|||
ScenarioBase.activeScenario |
|||
); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
/// <summary>
|
|||
/// Stores whether each event has been registered successfully or not.
|
|||
/// </summary>
|
|||
static Dictionary<AnalyticsEvent, bool> s_EventRegistrationStatus = new Dictionary<AnalyticsEvent, bool>(); |
|||
|
|||
#region Event Definitions
|
|||
static readonly AnalyticsEvent k_EventScenarioInformation = new AnalyticsEvent( |
|||
"perceptionScenarioInformation", AnalyticsEventType.RuntimeAndEditor, 1 |
|||
); |
|||
static readonly AnalyticsEvent k_EventRunInUnitySimulation = new AnalyticsEvent( |
|||
"runinunitysimulation", AnalyticsEventType.Editor, 1 |
|||
); |
|||
|
|||
/// <summary>
|
|||
/// All supported events. If an event does not exist in this list, an error will be thrown during
|
|||
/// <see cref="TryRegisterPerceptionAnalyticsEvent" />.
|
|||
/// </summary>
|
|||
static IEnumerable<AnalyticsEvent> allEvents => new[] |
|||
{ |
|||
k_EventScenarioInformation, |
|||
k_EventRunInUnitySimulation |
|||
}; |
|||
#endregion
|
|||
|
|||
#region Helpers
|
|||
|
|||
/// <summary>
|
|||
/// Tries to register an event and returns whether it was registered successfully. The result is also cached in
|
|||
/// the <see cref="s_EventRegistrationStatus" /> dictionary.
|
|||
/// </summary>
|
|||
/// <param name="theEvent">The name of the event.</param>
|
|||
/// <returns>Whether the event was successfully registered/</returns>
|
|||
static bool TryRegisterPerceptionAnalyticsEvent(AnalyticsEvent theEvent) |
|||
{ |
|||
// Make sure the event exists in the dictionary
|
|||
if (!s_EventRegistrationStatus.ContainsKey(theEvent)) |
|||
{ |
|||
if (allEvents.Contains(theEvent)) |
|||
s_EventRegistrationStatus[theEvent] = false; |
|||
else |
|||
throw new NotSupportedException($"Unrecognized event {theEvent} not included in {nameof(allEvents)}."); |
|||
} |
|||
|
|||
// If registered previously, return true
|
|||
if (s_EventRegistrationStatus[theEvent]) |
|||
return true; |
|||
|
|||
// Try registering the event and update the dictionary accordingly
|
|||
s_EventRegistrationStatus[theEvent] = true; |
|||
#if UNITY_EDITOR
|
|||
var status = EditorAnalytics.RegisterEventWithLimit(theEvent.name, k_MaxEventsPerHour, k_MaxElementsInStruct, k_VendorKey); |
|||
#else
|
|||
var status = UnityEngine.Analytics.Analytics.RegisterEvent(theEvent.name, k_MaxEventsPerHour, k_MaxElementsInStruct, k_VendorKey); |
|||
#endif
|
|||
s_EventRegistrationStatus[theEvent] &= status == AnalyticsResult.Ok; |
|||
|
|||
return s_EventRegistrationStatus[theEvent]; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Based on the value of type for <see cref="theEvent" />, sends an Editor Analytics event,
|
|||
/// a Runtime Analytics event, or both.
|
|||
/// </summary>
|
|||
/// <param name="theEvent">The analytics event.</param>
|
|||
/// <param name="data">Payload of the event.</param>
|
|||
static void SendPerceptionAnalyticsEvent(AnalyticsEvent theEvent, object data) |
|||
{ |
|||
#if UNITY_EDITOR
|
|||
if (theEvent.type == AnalyticsEventType.Editor || theEvent.type == AnalyticsEventType.RuntimeAndEditor) |
|||
{ |
|||
EditorAnalytics.SendEventWithLimit(theEvent.name, data, theEvent.versionId); |
|||
} |
|||
#else
|
|||
if (theEvent.type == AnalyticsEventType.Runtime || theEvent.type == AnalyticsEventType.RuntimeAndEditor) |
|||
{ |
|||
UnityEngine.Analytics.Analytics.SendEvent(theEvent.name, data, theEvent.versionId, theEvent.prefix); |
|||
} |
|||
#endif
|
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Event: Scenario Information
|
|||
|
|||
/// <summary>
|
|||
/// Which labelers will be identified and included in the analytics information.
|
|||
/// </summary>
|
|||
public static readonly string[] labelerAllowList = new[] |
|||
{ |
|||
"BoundingBox3DLabeler", "BoundingBox2DLabeler", "InstanceSegmentationLabeler", |
|||
"KeypointLabeler", "ObjectCountLabeler", "SemanticSegmentationLabeler", "RenderedObjectInfoLabeler" |
|||
}; |
|||
|
|||
static void ReportScenarioInformation( |
|||
PerceptionCamera cam, |
|||
ScenarioBase scenario |
|||
) |
|||
{ |
|||
if (!TryRegisterPerceptionAnalyticsEvent(k_EventScenarioInformation)) |
|||
return; |
|||
|
|||
var randomizers = scenario ? scenario.activeRandomizers : new List<Randomizer>(); |
|||
var data = ScenarioCompletedData.FromCameraAndRandomizers(cam, randomizers); |
|||
SendPerceptionAnalyticsEvent(k_EventScenarioInformation, data); |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Event: Run In Unity Simulation
|
|||
public static void ReportRunInUnitySimulationStarted(Guid runId, int totalIterations, int instanceCount, string existingBuildId) |
|||
{ |
|||
if (!TryRegisterPerceptionAnalyticsEvent(k_EventRunInUnitySimulation)) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
totalIterations = totalIterations, |
|||
instanceCount = instanceCount, |
|||
existingBuildId = existingBuildId, |
|||
runStatus = RunStatus.Started.ToString() |
|||
}; |
|||
|
|||
SendPerceptionAnalyticsEvent(k_EventRunInUnitySimulation, data); |
|||
} |
|||
|
|||
public static void ReportRunInUnitySimulationFailed(Guid runId, string errorMessage) |
|||
{ |
|||
if (!TryRegisterPerceptionAnalyticsEvent(k_EventRunInUnitySimulation)) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
errorMessage = errorMessage, |
|||
runStatus = RunStatus.Failed.ToString() |
|||
}; |
|||
|
|||
SendPerceptionAnalyticsEvent(k_EventRunInUnitySimulation, data); |
|||
} |
|||
|
|||
public static void ReportRunInUnitySimulationSucceeded(Guid runId, string runExecutionId) |
|||
{ |
|||
if (!TryRegisterPerceptionAnalyticsEvent(k_EventRunInUnitySimulation)) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
runExecutionId = runExecutionId, |
|||
runStatus = RunStatus.Succeeded.ToString() |
|||
}; |
|||
|
|||
SendPerceptionAnalyticsEvent(k_EventRunInUnitySimulation, data); |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 38657354e82b4c9b8370c9c55a39b1e3 |
|||
timeCreated: 1629939608 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using Unity.Simulation; |
|||
using UnityEngine.Assertions; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.Perception.Randomization.Randomizers; |
|||
using UnityEngine.Perception.Randomization.Samplers; |
|||
|
|||
namespace UnityEngine.Perception.Analytics |
|||
{ |
|||
#region Common
|
|||
|
|||
enum AnalyticsEventType |
|||
{ |
|||
Runtime, |
|||
Editor, |
|||
RuntimeAndEditor |
|||
} |
|||
struct AnalyticsEvent |
|||
{ |
|||
public string name { get; private set; } |
|||
public AnalyticsEventType type { get; private set; } |
|||
public int versionId { get; private set; } |
|||
public string prefix { get; private set; } |
|||
|
|||
public AnalyticsEvent(string name, AnalyticsEventType type, int versionId, string prefix = "") |
|||
{ |
|||
this.name = name; |
|||
this.type = type; |
|||
this.versionId = versionId; |
|||
this.prefix = prefix; |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Run In Unity Simulation
|
|||
|
|||
[Serializable] |
|||
enum RunStatus |
|||
{ |
|||
Started, |
|||
Failed, |
|||
Succeeded |
|||
} |
|||
|
|||
[Serializable] |
|||
struct RunInUnitySimulationData |
|||
{ |
|||
public string runId; |
|||
public int totalIterations; |
|||
public int instanceCount; |
|||
public string existingBuildId; |
|||
public string errorMessage; |
|||
public string runExecutionId; |
|||
public string runStatus; |
|||
} |
|||
|
|||
#endregion
|
|||
|
|||
#region Scenario Information
|
|||
|
|||
[Serializable] |
|||
public class PerceptionCameraData |
|||
{ |
|||
public string captureTriggerMode; |
|||
// same as "firstCaptureFrame" of the Perception Camera
|
|||
public int startAtFrame; |
|||
public int framesBetweenCaptures; |
|||
} |
|||
|
|||
[Serializable] |
|||
public class LabelerData |
|||
{ |
|||
public string name; |
|||
public int labelConfigCount; |
|||
public string objectFilter = ""; |
|||
public int animationPoseCount; |
|||
|
|||
public static LabelerData FromLabeler(CameraLabeler labeler) |
|||
{ |
|||
var labelerType = labeler.GetType(); |
|||
var labelerName = labelerType.Name; |
|||
if (!PerceptionAnalytics.labelerAllowList.Contains(labelerName)) |
|||
return null; |
|||
|
|||
var labelerData = new LabelerData() |
|||
{ |
|||
name = labelerName |
|||
}; |
|||
|
|||
switch (labeler) |
|||
{ |
|||
case BoundingBox3DLabeler bb3dl: |
|||
labelerData.labelConfigCount = bb3dl.idLabelConfig.labelEntries.Count; |
|||
break; |
|||
case BoundingBox2DLabeler bb2dl: |
|||
labelerData.labelConfigCount = bb2dl.idLabelConfig.labelEntries.Count; |
|||
break; |
|||
case InstanceSegmentationLabeler isl: |
|||
labelerData.labelConfigCount = isl.idLabelConfig.labelEntries.Count; |
|||
break; |
|||
case KeypointLabeler kpl: |
|||
labelerData.labelConfigCount = kpl.idLabelConfig.labelEntries.Count; |
|||
labelerData.objectFilter = kpl.objectFilter.ToString(); |
|||
labelerData.animationPoseCount = kpl.animationPoseConfigs.Count; |
|||
break; |
|||
case ObjectCountLabeler ocl: |
|||
labelerData.labelConfigCount = ocl.labelConfig.labelEntries.Count; |
|||
break; |
|||
case SemanticSegmentationLabeler ssl: |
|||
labelerData.labelConfigCount = ssl.labelConfig.labelEntries.Count; |
|||
break; |
|||
case RenderedObjectInfoLabeler rol: |
|||
labelerData.labelConfigCount = rol.idLabelConfig.labelEntries.Count; |
|||
break; |
|||
default: |
|||
labelerData = null; |
|||
break; |
|||
} |
|||
|
|||
return labelerData; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class MemberData |
|||
{ |
|||
public string name; |
|||
public string value; |
|||
public string type; |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ParameterField |
|||
{ |
|||
public string name; |
|||
public string distribution; |
|||
public float value; |
|||
public float rangeMinimum; |
|||
public float rangeMaximum; |
|||
public float mean; |
|||
public float stdDev; |
|||
public int categoricalParameterCount; |
|||
|
|||
public static ParameterField ExtractSamplerInformation(ISampler sampler, string fieldName = "value") |
|||
{ |
|||
switch (sampler) |
|||
{ |
|||
case AnimationCurveSampler _: |
|||
return new ParameterField() |
|||
{ |
|||
name = fieldName, |
|||
distribution = "AnimationCurve" |
|||
}; |
|||
case ConstantSampler cs: |
|||
return new ParameterField() |
|||
{ |
|||
name = fieldName, |
|||
distribution = "Constant", |
|||
value = cs.value |
|||
}; |
|||
case NormalSampler ns: |
|||
return new ParameterField() |
|||
{ |
|||
name = fieldName, |
|||
distribution = "Normal", |
|||
mean = ns.mean, |
|||
stdDev = ns.standardDeviation, |
|||
rangeMinimum = ns.range.minimum, |
|||
rangeMaximum = ns.range.maximum |
|||
}; |
|||
case UniformSampler us: |
|||
return new ParameterField() |
|||
{ |
|||
name = fieldName, |
|||
distribution = "Uniform", |
|||
rangeMinimum = us.range.minimum, |
|||
rangeMaximum = us.range.maximum |
|||
}; |
|||
default: |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public static List<ParameterField> ExtractSamplersInformation(IEnumerable<ISampler> samplers, IEnumerable<string> indexToNameMapping) |
|||
{ |
|||
var samplersList = samplers.ToList(); |
|||
var indexToNameMappingList = indexToNameMapping.ToList(); |
|||
if (samplersList.Count > indexToNameMappingList.Count) |
|||
throw new Exception("Insufficient names provided for mapping ParameterFields"); |
|||
return samplersList.Select((t, i) => ExtractSamplerInformation(t, indexToNameMappingList[i])).ToList(); |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ParameterData |
|||
{ |
|||
public string name; |
|||
public string type; |
|||
public List<ParameterField> fields; |
|||
} |
|||
|
|||
[Serializable] |
|||
public class RandomizerData |
|||
{ |
|||
public string name; |
|||
public MemberData[] members; |
|||
public ParameterData[] parameters; |
|||
|
|||
public static RandomizerData FromRandomizer(Randomizer randomizer) |
|||
{ |
|||
if (randomizer == null) |
|||
return null; |
|||
|
|||
var data = new RandomizerData() |
|||
{ |
|||
name = randomizer.GetType().Name, |
|||
}; |
|||
|
|||
var randomizerType = randomizer.GetType(); |
|||
|
|||
// Filter out randomizers which could be considered personally identifiable.
|
|||
if (randomizerType.Namespace == null || !randomizerType.Namespace.StartsWith("UnityEngine.Perception")) |
|||
return null; |
|||
|
|||
// Naming configuration
|
|||
var vectorFieldNames = new[] { "x", "y", "z", "w" }; |
|||
var hsvaFieldNames = new[] { "hue", "saturation", "value", "alpha" }; |
|||
var rgbFieldNames = new[] { "red", "green", "blue" }; |
|||
|
|||
// Add member fields and parameters separately
|
|||
var members = new List<MemberData>(); |
|||
var parameters = new List<ParameterData>(); |
|||
foreach (var field in randomizerType.GetFields(BindingFlags.Public | BindingFlags.Instance)) |
|||
{ |
|||
var member = field.GetValue(randomizer); |
|||
var memberType = member.GetType(); |
|||
|
|||
// If member is either a categorical or numeric parameter
|
|||
if (memberType.IsSubclassOf(typeof(Parameter))) |
|||
{ |
|||
var pd = new ParameterData() |
|||
{ |
|||
name = field.Name, |
|||
type = memberType.Name, |
|||
fields = new List<ParameterField>() |
|||
}; |
|||
|
|||
// All included parameter types
|
|||
switch (member) |
|||
{ |
|||
case CategoricalParameterBase cp: |
|||
pd.fields.Add(new ParameterField() |
|||
{ |
|||
name = "values", |
|||
distribution = "Categorical", |
|||
categoricalParameterCount = cp.probabilities.Count |
|||
}); |
|||
break; |
|||
case BooleanParameter bP: |
|||
pd.fields.Add(ParameterField.ExtractSamplerInformation(bP.value)); |
|||
break; |
|||
case FloatParameter fP: |
|||
pd.fields.Add(ParameterField.ExtractSamplerInformation(fP.value)); |
|||
break; |
|||
case IntegerParameter iP: |
|||
pd.fields.Add(ParameterField.ExtractSamplerInformation(iP.value)); |
|||
break; |
|||
case Vector2Parameter v2P: |
|||
pd.fields.AddRange(ParameterField.ExtractSamplersInformation(v2P.samplers, vectorFieldNames)); |
|||
break; |
|||
case Vector3Parameter v3P: |
|||
pd.fields.AddRange(ParameterField.ExtractSamplersInformation(v3P.samplers, vectorFieldNames)); |
|||
break; |
|||
case Vector4Parameter v4P: |
|||
pd.fields.AddRange(ParameterField.ExtractSamplersInformation(v4P.samplers, vectorFieldNames)); |
|||
break; |
|||
case ColorHsvaParameter hsvaP: |
|||
pd.fields.AddRange(ParameterField.ExtractSamplersInformation(hsvaP.samplers, hsvaFieldNames)); |
|||
break; |
|||
case ColorRgbParameter rgbP: |
|||
pd.fields.AddRange(ParameterField.ExtractSamplersInformation(rgbP.samplers, rgbFieldNames)); |
|||
break; |
|||
} |
|||
|
|||
parameters.Add(pd); |
|||
} |
|||
else |
|||
{ |
|||
members.Add(new MemberData() |
|||
{ |
|||
name = field.Name, |
|||
type = memberType.FullName, |
|||
value = member.ToString() |
|||
}); |
|||
} |
|||
} |
|||
|
|||
data.members = members.ToArray(); |
|||
data.parameters = parameters.ToArray(); |
|||
return data; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ScenarioCompletedData |
|||
{ |
|||
public string platform; |
|||
public PerceptionCameraData perceptionCamera; |
|||
public LabelerData[] labelers; |
|||
public RandomizerData[] randomizers; |
|||
|
|||
internal static ScenarioCompletedData FromCameraAndRandomizers( |
|||
PerceptionCamera cam, |
|||
IEnumerable<Randomizer> randomizers |
|||
) |
|||
{ |
|||
var data = new ScenarioCompletedData() |
|||
{ |
|||
platform = (Configuration.Instance.IsSimulationRunningInCloud()) ? "USim": Application.platform.ToString() |
|||
}; |
|||
|
|||
if (cam != null) |
|||
{ |
|||
// Perception Camera Data
|
|||
data.perceptionCamera = new PerceptionCameraData() |
|||
{ |
|||
captureTriggerMode = cam.captureTriggerMode.ToString(), |
|||
startAtFrame = cam.firstCaptureFrame, |
|||
framesBetweenCaptures = cam.framesBetweenCaptures |
|||
}; |
|||
|
|||
// Labeler Data
|
|||
data.labelers = cam.labelers |
|||
.Select(LabelerData.FromLabeler) |
|||
.Where(labeler => labeler != null).ToArray(); |
|||
} |
|||
|
|||
var randomizerList = randomizers.ToArray(); |
|||
if (randomizerList.Any()) |
|||
{ |
|||
data.randomizers = randomizerList |
|||
.Select(RandomizerData.FromRandomizer) |
|||
.Where(x => x != null).ToArray(); |
|||
} |
|||
else |
|||
{ |
|||
data.randomizers = new RandomizerData[] { }; |
|||
} |
|||
|
|||
return data; |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 78500bfc6066482ca6af77c3586dcbd2 |
|||
timeCreated: 1632680191 |
|
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.Perception.Randomization.Randomizers; |
|||
using UnityEngine.Perception.Randomization.Samplers; |
|||
|
|||
namespace UnityEngine.Perception.RandomizationTests.ScenarioTests |
|||
{ |
|||
public class AllMembersAndParametersTestRandomizer: Randomizer |
|||
{ |
|||
// Members
|
|||
public bool booleanMember = false; |
|||
public int intMember = 4; |
|||
public uint uintMember = 2; |
|||
public float floatMember = 5; |
|||
public Vector2 vector2Member = new Vector2(4, 7); |
|||
public UniformSampler unsupportedMember = new UniformSampler(); |
|||
|
|||
// Parameters
|
|||
public BooleanParameter booleanParam = new BooleanParameter() |
|||
{ |
|||
value = new ConstantSampler(1) |
|||
}; |
|||
public FloatParameter floatParam = new FloatParameter() |
|||
{ |
|||
value = new AnimationCurveSampler() |
|||
}; |
|||
public IntegerParameter integerParam = new IntegerParameter() |
|||
{ |
|||
value = new UniformSampler(-3, 7) |
|||
}; |
|||
public Vector2Parameter vector2Param = new Vector2Parameter() |
|||
{ |
|||
x = new ConstantSampler(2), |
|||
y = new UniformSampler(-4, 8) |
|||
}; |
|||
public Vector3Parameter vector3Param = new Vector3Parameter() |
|||
{ |
|||
x = new NormalSampler(-5, 9, 4, 2), |
|||
y = new ConstantSampler(3), |
|||
z = new AnimationCurveSampler() |
|||
}; |
|||
public Vector4Parameter vector4Param = new Vector4Parameter() |
|||
{ |
|||
x = new NormalSampler(-5, 9, 4, 2), |
|||
y = new ConstantSampler(3), |
|||
z = new AnimationCurveSampler(), |
|||
w = new UniformSampler(-12, 42) |
|||
}; |
|||
public ColorRgbCategoricalParameter colorRgbCategoricalParam = new ColorRgbCategoricalParameter(); |
|||
}; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5dcdd497a48d3405489861ef856a8495 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%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: 4c69656f5dd14516a3a18e42b3b43a4e, type: 3} |
|||
m_Name: sampleAnimationPoseConfig |
|||
m_EditorClassIdentifier: |
|||
animationClip: {fileID: 0} |
|||
m_Timestamps: |
|||
- startOffsetPercent: 0 |
|||
poseLabel: a |
|||
- startOffsetPercent: 24 |
|||
poseLabel: b |
|||
- startOffsetPercent: 45 |
|||
poseLabel: c |
|||
- startOffsetPercent: 89 |
|||
poseLabel: d |
|
|||
fileFormatVersion: 2 |
|||
guid: 92646dbc24d95413084b0787214fdcb3 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
%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: 2f09f279848e42cea259348b13bce4c5, type: 3} |
|||
m_Name: sampleIdLabelConfig |
|||
m_EditorClassIdentifier: |
|||
m_LabelEntries: |
|||
- label: Test 1 |
|||
id: 1 |
|||
- label: Test 2 |
|||
id: 2 |
|||
- label: Test 3 |
|||
id: 3 |
|||
autoAssignIds: 1 |
|||
startingLabelId: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: c3dce9f8036624486bdc1e97f0934aa1 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 11400000 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 98cfbce5bd48d9d4d99e5c8b8a1ee97b |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3216e9e700a34acc8ac808ffccb8297c |
|||
timeCreated: 1607709612 |
|
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using UnityEngine; |
|||
using UnityEngine.Analytics; |
|||
|
|||
namespace UnityEditor.Perception.Randomization |
|||
{ |
|||
static class PerceptionEditorAnalytics |
|||
{ |
|||
const string k_VendorKey = "unity.perception"; |
|||
const string k_RunInUnitySimulationName = "runinunitysimulation"; |
|||
static int k_MaxItems = 100; |
|||
static int k_MaxEventsPerHour = 100; |
|||
|
|||
static bool s_IsRegistered; |
|||
|
|||
static bool TryRegisterEvents() |
|||
{ |
|||
if (s_IsRegistered) |
|||
return true; |
|||
|
|||
var success = true; |
|||
success &= EditorAnalytics.RegisterEventWithLimit(k_RunInUnitySimulationName, k_MaxEventsPerHour, k_MaxItems, |
|||
k_VendorKey) == AnalyticsResult.Ok; |
|||
|
|||
s_IsRegistered = success; |
|||
return success; |
|||
} |
|||
|
|||
public static void ReportRunInUnitySimulationStarted(Guid runId, int totalIterations, int instanceCount, string existingBuildId) |
|||
{ |
|||
if (!TryRegisterEvents()) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
totalIterations = totalIterations, |
|||
instanceCount = instanceCount, |
|||
existingBuildId = existingBuildId, |
|||
runStatus = RunStatus.Started.ToString() |
|||
}; |
|||
EditorAnalytics.SendEventWithLimit(k_RunInUnitySimulationName, data); |
|||
} |
|||
|
|||
public static void ReportRunInUnitySimulationFailed(Guid runId, string errorMessage) |
|||
{ |
|||
if (!TryRegisterEvents()) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
errorMessage = errorMessage, |
|||
runStatus = RunStatus.Failed.ToString() |
|||
}; |
|||
EditorAnalytics.SendEventWithLimit(k_RunInUnitySimulationName, data); |
|||
} |
|||
|
|||
public static void ReportRunInUnitySimulationSucceeded(Guid runId, string runExecutionId) |
|||
{ |
|||
if (!TryRegisterEvents()) |
|||
return; |
|||
|
|||
var data = new RunInUnitySimulationData |
|||
{ |
|||
runId = runId.ToString(), |
|||
runExecutionId = runExecutionId, |
|||
runStatus = RunStatus.Succeeded.ToString() |
|||
}; |
|||
EditorAnalytics.SendEventWithLimit(k_RunInUnitySimulationName, data); |
|||
} |
|||
|
|||
enum RunStatus |
|||
{ |
|||
Started, |
|||
Failed, |
|||
Succeeded |
|||
} |
|||
|
|||
struct RunInUnitySimulationData |
|||
{ |
|||
[UsedImplicitly] |
|||
public string runId; |
|||
[UsedImplicitly] |
|||
public int totalIterations; |
|||
[UsedImplicitly] |
|||
public int instanceCount; |
|||
[UsedImplicitly] |
|||
public string existingBuildId; |
|||
[UsedImplicitly] |
|||
public string errorMessage; |
|||
[UsedImplicitly] |
|||
public string runExecutionId; |
|||
[UsedImplicitly] |
|||
public string runStatus; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue