Steve Borkman
3 年前
当前提交
0fce16c7
共有 49 个文件被更改,包括 1632 次插入 和 365 次删除
-
11TestProjects/PerceptionURP/Assets/ExampleScripts/CustomAnnotationAndMetricReporter.cs
-
1com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
-
26com.unity.perception/Editor/GroundTruth/Uss/Styles.uss
-
19com.unity.perception/Runtime/GroundTruth/ConsumerEndpoint.cs
-
4com.unity.perception/Runtime/GroundTruth/Consumers/OldPerceptionConsumer.cs
-
46com.unity.perception/Runtime/GroundTruth/Consumers/SoloConsumer.cs
-
8com.unity.perception/Runtime/GroundTruth/Consumers/SoloMessageBuilder.cs
-
31com.unity.perception/Runtime/GroundTruth/DataModel.cs
-
328com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
-
2com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBox3DLabeler.cs
-
19com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
-
3com.unity.perception/Runtime/GroundTruth/Labelers/CameraLabeler.cs
-
2com.unity.perception/Runtime/GroundTruth/Labelers/KeypointLabeler.cs
-
2com.unity.perception/Runtime/GroundTruth/Labelers/ObjectCountLabeler.cs
-
2com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
-
49com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
8com.unity.perception/Runtime/GroundTruth/PerceptionUpdater.cs
-
268com.unity.perception/Runtime/GroundTruth/SimulationState.cs
-
23com.unity.perception/Runtime/GroundTruth/SimulationState_Json.cs
-
2com.unity.perception/Runtime/Randomization/Randomizers/RandomizerExamples/Randomizers/AnimationRandomizer.cs
-
46com.unity.perception/Runtime/Randomization/Scenarios/PerceptionScenario.cs
-
14com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
127com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureSensorSchedulingTests.cs
-
178com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs
-
9com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/TestFixedLengthScenario.cs
-
8com.unity.perception/Editor/GroundTruth/DatasetConsumer.meta
-
27com.unity.perception/Runtime/GroundTruth/Consumers/NoOpConsumer.cs
-
11com.unity.perception/Runtime/GroundTruth/Consumers/NoOpConsumer.cs.meta
-
253com.unity.perception/Editor/GroundTruth/DatasetConsumer/AddConsumerEndpointMenu.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/AddConsumerEndpointMenu.cs.meta
-
14com.unity.perception/Editor/GroundTruth/DatasetConsumer/AddConsumerEndpointMenuAttribute.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/AddConsumerEndpointMenuAttribute.cs.meta
-
79com.unity.perception/Editor/GroundTruth/DatasetConsumer/ConsumerEndpointElement.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/ConsumerEndpointElement.cs.meta
-
31com.unity.perception/Editor/GroundTruth/DatasetConsumer/DatasetCaptureEditor.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/DatasetCaptureEditor.cs.meta
-
111com.unity.perception/Editor/GroundTruth/DatasetConsumer/EndpointList.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/EndpointList.cs.meta
-
93com.unity.perception/Editor/GroundTruth/DatasetConsumer/StaticData.cs
-
11com.unity.perception/Editor/GroundTruth/DatasetConsumer/StaticData.cs.meta
-
8com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml.meta
-
16com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/ConsumerEndpointElement.uxml
-
10com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/ConsumerEndpointElement.uxml.meta
-
6com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/DatasetCaptureElement.uxml
-
10com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/DatasetCaptureElement.uxml.meta
-
16com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/EndpointList.uxml
-
10com.unity.perception/Editor/GroundTruth/DatasetConsumer/Uxml/EndpointList.uxml.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 3cc809492ae10b840963071dbc2e6e39 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Perception.GroundTruth.DataModel; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth.Consumers |
|||
{ |
|||
public class NoOpConsumer : ConsumerEndpoint |
|||
{ |
|||
protected override bool IsComplete() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
public override void OnSimulationStarted(SimulationMetadata metadata) |
|||
{ |
|||
// Do nothing, drop everything on the floor
|
|||
} |
|||
|
|||
public override void OnFrameGenerated(Frame frame) |
|||
{ |
|||
// Do nothing, drop everything on the floor
|
|||
} |
|||
|
|||
public override void OnSimulationCompleted(CompletionMetadata metadata) |
|||
{ |
|||
// Do nothing, drop everything on the floor
|
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 47182fdcdec0dc74fa26fcd45504eb3d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using NUnit.Framework; |
|||
using Unity.Mathematics; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
public class AddConsumerEndpointMenu : VisualElement |
|||
{ |
|||
const string k_DefaultDirectoryText = "ConsumerEndpoints"; |
|||
string m_CurrentPath = string.Empty; |
|||
VisualElement m_DirectoryChevron; |
|||
TextElement m_DirectoryLabelText; |
|||
Dictionary<string, HashSet<string>> m_MenuDirectories = new Dictionary<string, HashSet<string>>(); |
|||
VisualElement m_MenuElements; |
|||
List<MenuItem> m_MenuItems = new List<MenuItem>(); |
|||
Dictionary<string, List<MenuItem>> m_MenuItemsMap = new Dictionary<string, List<MenuItem>>(); |
|||
|
|||
EndpointList m_EndpointList; |
|||
|
|||
string m_SearchString = string.Empty; |
|||
|
|||
public AddConsumerEndpointMenu(VisualElement parentElement, VisualElement button, EndpointList endpointList) |
|||
{ |
|||
m_EndpointList = endpointList; |
|||
var template = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ConsumerEndpoints/AddConsumerEndpointMenu.uxml"); |
|||
template.CloneTree(this); |
|||
style.position = new StyleEnum<Position>(Position.Absolute); |
|||
|
|||
var buttonPosition = button.worldBound.position; |
|||
var top = math.min(buttonPosition.y, parentElement.worldBound.height - 300); |
|||
style.top = top; |
|||
style.left = buttonPosition.x; |
|||
|
|||
focusable = true; |
|||
RegisterCallback<FocusOutEvent>(evt => |
|||
{ |
|||
if (evt.relatedTarget == null || ((VisualElement)evt.relatedTarget).FindCommonAncestor(this) != this) |
|||
ExitMenu(); |
|||
}); |
|||
|
|||
var directoryLabel = this.Q<VisualElement>("directory-label"); |
|||
directoryLabel.RegisterCallback<MouseUpEvent>(evt => { AscendDirectory(); }); |
|||
m_DirectoryLabelText = this.Q<TextElement>("directory-label-text"); |
|||
m_DirectoryChevron = this.Q<VisualElement>("directory-chevron"); |
|||
|
|||
var searchBar = this.Q<TextField>("search-bar"); |
|||
searchBar.schedule.Execute(() => searchBar.ElementAt(0).Focus()); |
|||
searchBar.RegisterValueChangedCallback(evt => searchString = evt.newValue); |
|||
|
|||
m_MenuElements = this.Q<VisualElement>("menu-options"); |
|||
|
|||
CreateMenuItems(); |
|||
DrawDirectoryItems(); |
|||
} |
|||
|
|||
string currentPath |
|||
{ |
|||
get => m_CurrentPath; |
|||
set |
|||
{ |
|||
m_CurrentPath = value; |
|||
DrawDirectoryItems(); |
|||
} |
|||
} |
|||
|
|||
string currentPathName |
|||
{ |
|||
get |
|||
{ |
|||
if (m_CurrentPath == string.Empty) |
|||
return k_DefaultDirectoryText; |
|||
var pathItems = m_CurrentPath.Split('/'); |
|||
return pathItems[pathItems.Length - 1]; |
|||
} |
|||
} |
|||
|
|||
string searchString |
|||
{ |
|||
get => m_SearchString; |
|||
set |
|||
{ |
|||
m_SearchString = value; |
|||
if (m_SearchString == string.Empty) |
|||
DrawDirectoryItems(); |
|||
else |
|||
DrawSearchItems(); |
|||
} |
|||
} |
|||
|
|||
string directoryText |
|||
{ |
|||
set |
|||
{ |
|||
m_DirectoryLabelText.text = value; |
|||
m_DirectoryChevron.style.visibility = value == k_DefaultDirectoryText |
|||
? new StyleEnum<Visibility>(Visibility.Hidden) |
|||
: new StyleEnum<Visibility>(Visibility.Visible); |
|||
} |
|||
} |
|||
|
|||
void ExitMenu() |
|||
{ |
|||
parent.Remove(this); |
|||
} |
|||
|
|||
void AddEndpoint(Type endpointType) |
|||
{ |
|||
#if false
|
|||
m_EndpointList.AddEndpoint(endpointType); |
|||
ExitMenu(); |
|||
#endif
|
|||
} |
|||
|
|||
void AscendDirectory() |
|||
{ |
|||
var pathItems = m_CurrentPath.Split('/'); |
|||
var path = pathItems[0]; |
|||
for (var i = 1; i < pathItems.Length - 1; i++) |
|||
path = $"{path}/{pathItems[i]}"; |
|||
currentPath = path; |
|||
} |
|||
|
|||
void DrawDirectoryItems() |
|||
{ |
|||
directoryText = currentPathName; |
|||
m_MenuElements.Clear(); |
|||
|
|||
if (m_MenuDirectories.ContainsKey(currentPath)) |
|||
{ |
|||
var directories = m_MenuDirectories[currentPath]; |
|||
foreach (var directory in directories) |
|||
m_MenuElements.Add(new MenuDirectoryElement(directory, this)); |
|||
} |
|||
|
|||
if (m_MenuItemsMap.ContainsKey(currentPath)) |
|||
{ |
|||
var menuItems = m_MenuItemsMap[currentPath]; |
|||
foreach (var menuItem in menuItems) |
|||
m_MenuElements.Add(new MenuItemElement(menuItem, this)); |
|||
} |
|||
} |
|||
|
|||
void DrawSearchItems() |
|||
{ |
|||
directoryText = k_DefaultDirectoryText; |
|||
m_MenuElements.Clear(); |
|||
|
|||
var upperSearchString = searchString.ToUpper(); |
|||
foreach (var menuItem in m_MenuItems) |
|||
if (menuItem.itemName.ToUpper().Contains(upperSearchString)) |
|||
m_MenuElements.Add(new MenuItemElement(menuItem, this)); |
|||
} |
|||
|
|||
void CreateMenuItems() |
|||
{ |
|||
var rootList = new List<MenuItem>(); |
|||
m_MenuItemsMap.Add(string.Empty, rootList); |
|||
|
|||
var endpointTypeSet = new HashSet<Type>(); |
|||
#if false
|
|||
foreach (var endpoint in m_EndpointList.datasetCapture.consumerEndpoints) |
|||
endpointTypeSet.Add(endpoint.GetType()); |
|||
#endif
|
|||
foreach (var endpointType in StaticData.endpointTypes) |
|||
{ |
|||
if (endpointTypeSet.Contains(endpointType)) |
|||
continue; |
|||
var menuAttribute = (AddConsumerEndpointMenuAttribute)Attribute.GetCustomAttribute( |
|||
endpointType, typeof(AddConsumerEndpointMenuAttribute)); |
|||
if (menuAttribute != null) |
|||
{ |
|||
var pathItems = menuAttribute.menuPath.Split('/'); |
|||
if (pathItems.Length > 1) |
|||
{ |
|||
var path = string.Empty; |
|||
var itemName = pathItems[pathItems.Length - 1]; |
|||
for (var i = 0; i < pathItems.Length - 1; i++) |
|||
{ |
|||
var childPath = $"{path}/{pathItems[i]}"; |
|||
if (i < pathItems.Length - 1) |
|||
{ |
|||
if (!m_MenuDirectories.ContainsKey(path)) |
|||
m_MenuDirectories.Add(path, new HashSet<string>()); |
|||
m_MenuDirectories[path].Add(childPath); |
|||
} |
|||
|
|||
path = childPath; |
|||
} |
|||
|
|||
if (!m_MenuItemsMap.ContainsKey(path)) |
|||
m_MenuItemsMap.Add(path, new List<MenuItem>()); |
|||
|
|||
var item = new MenuItem(endpointType, itemName); |
|||
m_MenuItems.Add(item); |
|||
m_MenuItemsMap[path].Add(item); |
|||
} |
|||
else |
|||
{ |
|||
if (pathItems.Length == 0) |
|||
throw new AssertionException("Empty consumer endpoint menu path"); |
|||
var item = new MenuItem(endpointType, pathItems[0]); |
|||
m_MenuItems.Add(item); |
|||
rootList.Add(item); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
rootList.Add(new MenuItem(endpointType, endpointType.Name)); |
|||
} |
|||
} |
|||
|
|||
m_MenuItems.Sort((item1, item2) => item1.itemName.CompareTo(item2.itemName)); |
|||
} |
|||
|
|||
class MenuItem |
|||
{ |
|||
public string itemName; |
|||
public Type endpointType; |
|||
|
|||
public MenuItem(Type endpointType, string itemName) |
|||
{ |
|||
this.endpointType = endpointType; |
|||
this.itemName = itemName; |
|||
} |
|||
} |
|||
|
|||
sealed class MenuItemElement : TextElement |
|||
{ |
|||
public MenuItemElement(MenuItem menuItem, AddConsumerEndpointMenu menu) |
|||
{ |
|||
text = menuItem.itemName; |
|||
AddToClassList("consumer-endpoint__add-menu-directory-item"); |
|||
RegisterCallback<MouseUpEvent>(evt => menu.AddEndpoint(menuItem.endpointType)); |
|||
} |
|||
} |
|||
|
|||
sealed class MenuDirectoryElement : VisualElement |
|||
{ |
|||
public MenuDirectoryElement(string directory, AddConsumerEndpointMenu menu) |
|||
{ |
|||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ConsumerEndpoint/MenuDirectoryElement.uxml").CloneTree(this); |
|||
var pathItems = directory.Split('/'); |
|||
this.Q<TextElement>("directory").text = pathItems[pathItems.Length - 1]; |
|||
RegisterCallback<MouseUpEvent>(evt => menu.currentPath = directory); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 544559f30bb964a4fa67eb732cc7b47a |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
public class AddConsumerEndpointMenuAttribute : Attribute |
|||
{ |
|||
public string menuPath; |
|||
|
|||
public AddConsumerEndpointMenuAttribute(string menuPath) |
|||
{ |
|||
this.menuPath = menuPath; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3ad70a0ee31b79c449e1363a0b01c487 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEditor.Perception.Randomization; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
public class ConsumerEndpointElement : VisualElement |
|||
{ |
|||
const string k_CollapsedParameterClass = "collapsed"; |
|||
SerializedProperty m_Collapsed; |
|||
VisualElement m_PropertiesContainer; |
|||
SerializedProperty m_Property; |
|||
|
|||
public ConsumerEndpointElement(SerializedProperty property, EndpointList endpointList) |
|||
{ |
|||
m_Property = property; |
|||
this.endpointList = endpointList; |
|||
|
|||
m_Collapsed = property.FindPropertyRelative("collapsed"); |
|||
collapsed = m_Collapsed.boolValue; |
|||
|
|||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ConsumerEndpoint/ConsumerEndpointElement.uxml").CloneTree(this); |
|||
|
|||
var classNameLabel = this.Q<TextElement>("class-name"); |
|||
var splitType = property.managedReferenceFullTypename.Split(' ', '.'); |
|||
classNameLabel.text = splitType[splitType.Length - 1]; |
|||
|
|||
m_PropertiesContainer = this.Q<VisualElement>("properties"); |
|||
|
|||
var collapseToggle = this.Q<VisualElement>("collapse"); |
|||
collapseToggle.RegisterCallback<MouseUpEvent>(evt => collapsed = !collapsed); |
|||
|
|||
var enabledToggle = this.Q<Toggle>("enabled"); |
|||
enabledToggle.BindProperty(property.FindPropertyRelative("m_Enabled")); |
|||
|
|||
var removeButton = this.Q<Button>("remove"); |
|||
// removeButton.clicked += () => endpointList.RemoveEndpoint(this);
|
|||
|
|||
// this.AddManipulator(new DragToReorderManipulator());
|
|||
|
|||
FillPropertiesContainer(); |
|||
} |
|||
|
|||
ConsumerEndpoint endpoint => (ConsumerEndpoint)StaticData.GetManagedReferenceValue(m_Property); |
|||
|
|||
public Type endpointType => endpoint.GetType(); |
|||
|
|||
public EndpointList endpointList { get; } |
|||
|
|||
public bool collapsed |
|||
{ |
|||
get => m_Collapsed?.boolValue ?? true; |
|||
set |
|||
{ |
|||
if (m_Collapsed == null) |
|||
return; |
|||
|
|||
m_Collapsed.boolValue = value; |
|||
m_Property.serializedObject.ApplyModifiedPropertiesWithoutUndo(); |
|||
if (value) |
|||
AddToClassList(k_CollapsedParameterClass); |
|||
else |
|||
RemoveFromClassList(k_CollapsedParameterClass); |
|||
} |
|||
} |
|||
|
|||
void FillPropertiesContainer() |
|||
{ |
|||
m_PropertiesContainer.Clear(); |
|||
UIElementsEditorUtilities.CreatePropertyFields(m_Property, m_PropertiesContainer); |
|||
|
|||
if (m_PropertiesContainer.childCount == 0) |
|||
m_PropertiesContainer.style.display = new StyleEnum<DisplayStyle>(DisplayStyle.None); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1c2bdd53b35277e4c8f7ba95c6bffedd |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
[CustomEditor(typeof(DatasetCapture), true)] |
|||
public class DatasetCaptureEditor : Editor |
|||
{ |
|||
DatasetCapture m_DatasetCapture; |
|||
SerializedObject m_SerializedObject; |
|||
VisualElement m_EndpointsPlaceholder; |
|||
VisualElement m_Root; |
|||
|
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
#if false
|
|||
m_DatasetCapture = (DatasetCapture)target; |
|||
m_SerializedObject = new SerializedObject(m_DatasetCapture); |
|||
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/DatasetCaptureElement.uxml").CloneTree(); |
|||
|
|||
m_EndpointsPlaceholder = m_Root.Q<VisualElement>("endpoint-list-placeholder"); |
|||
|
|||
// m_EndpointsPlaceholder.Add(new EndpointList());
|
|||
|
|||
return m_Root; |
|||
#endif
|
|||
return null; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e029f41d3f1427e4ba7db2d06efee341 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Net; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
public class EndpointList : VisualElement |
|||
{ |
|||
VisualElement m_Container; |
|||
SerializedProperty m_Property; |
|||
|
|||
public EndpointList(SerializedProperty property) |
|||
{ |
|||
m_Property = property; |
|||
AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/EndpointList.uxml").CloneTree(this); |
|||
|
|||
m_Container = this.Q<VisualElement>("consumer-endpoint-container"); |
|||
|
|||
var addEndpointButton = this.Q<Button>("add-consumer-endpoint-button"); |
|||
addEndpointButton.clicked += () => |
|||
{ |
|||
inspectorContainer.Add(new AddConsumerEndpointMenu(inspectorContainer, addEndpointButton, this)); |
|||
}; |
|||
#if false
|
|||
var expandAllButton = this.Q<Button>("expand-all"); |
|||
expandAllButton.clicked += () => CollapseEndpoints(false); |
|||
|
|||
var collapseAllButton = this.Q<Button>("collapse-all"); |
|||
collapseAllButton.clicked += () => CollapseEndpoints(true); |
|||
#endif
|
|||
RefreshList(); |
|||
Undo.undoRedoPerformed += () => |
|||
{ |
|||
m_Property.serializedObject.Update(); |
|||
RefreshList(); |
|||
}; |
|||
} |
|||
#if false
|
|||
public DatasetCapture datasetCapture => (DatasetCapture)m_Property.serializedObject.targetObject; |
|||
#endif
|
|||
VisualElement inspectorContainer |
|||
{ |
|||
get |
|||
{ |
|||
var viewport = parent; |
|||
while (!viewport.ClassListContains("unity-inspector-main-container")) |
|||
viewport = viewport.parent; |
|||
return viewport; |
|||
} |
|||
} |
|||
|
|||
void RefreshList() |
|||
{ |
|||
m_Container.Clear(); |
|||
if (m_Property.arraySize > 0 && |
|||
string.IsNullOrEmpty(m_Property.GetArrayElementAtIndex(0).managedReferenceFullTypename)) |
|||
{ |
|||
var textElement = new TextElement() |
|||
{ |
|||
text = "One or more endpoints have missing scripts. See console for more info." |
|||
}; |
|||
textElement.AddToClassList("dataset_capture__info-box"); |
|||
textElement.AddToClassList("dataset_capture__error-box"); |
|||
m_Container.Add(textElement); |
|||
return; |
|||
} |
|||
|
|||
for (var i = 0; i < m_Property.arraySize; i++) |
|||
m_Container.Add(new ConsumerEndpointElement(m_Property.GetArrayElementAtIndex(i), this)); |
|||
} |
|||
#if false
|
|||
public void AddEndpoint(Type endpointType) |
|||
{ |
|||
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Add Consumer Endpoint"); |
|||
datasetCapture.CreateConsumerEndpoint(endpointType); |
|||
m_Property.serializedObject.Update(); |
|||
RefreshList(); |
|||
} |
|||
|
|||
public void RemoveEndpoint(ConsumerEndpointElement element) |
|||
{ |
|||
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Remove Consumer Endpoint"); |
|||
datasetCapture.RemoveConsumerEndpointAt(element.parent.IndexOf(element)); |
|||
m_Property.serializedObject.Update(); |
|||
RefreshList(); |
|||
} |
|||
|
|||
public void ReorderEndpoints(int currentIndex, int nextIndex) |
|||
{ |
|||
if (currentIndex == nextIndex) |
|||
return; |
|||
if (nextIndex > currentIndex) |
|||
nextIndex--; |
|||
Undo.RegisterCompleteObjectUndo(m_Property.serializedObject.targetObject, "Reorder Consumer Endpoint"); |
|||
var endpoint = datasetCapture.GetConsumerEndpoint(currentIndex); |
|||
datasetCapture.RemoveConsumerEndpointAt(currentIndex); |
|||
datasetCapture.InsertConsumerEndpoint(nextIndex, endpoint); |
|||
m_Property.serializedObject.Update(); |
|||
RefreshList(); |
|||
} |
|||
|
|||
void CollapseEndpoints(bool collapsed) |
|||
{ |
|||
foreach (var child in m_Container.Children()) |
|||
((ConsumerEndpointElement)child).collapsed = collapsed; |
|||
} |
|||
#endif
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ffff1c74e2a357f458147ff9be9e6071 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth.DatasetConsumer |
|||
{ |
|||
public static class StaticData |
|||
{ |
|||
const string k_ConsumerEndpointDir = "Packages/com.unity.perception/Editor/GroundTruth/DatasetConsumer"; |
|||
internal const string uxmlDir = k_ConsumerEndpointDir + "/Uxml"; |
|||
|
|||
internal static Type[] endpointTypes; |
|||
|
|||
static StaticData() |
|||
{ |
|||
endpointTypes = GetConstructableDerivedTypes<ConsumerEndpoint>(); |
|||
} |
|||
|
|||
static Type[] GetConstructableDerivedTypes<T>() |
|||
{ |
|||
var collection = TypeCache.GetTypesDerivedFrom<T>(); |
|||
var types = new List<Type>(); |
|||
foreach (var type in collection) |
|||
if (!type.IsAbstract && !type.IsInterface) |
|||
types.Add(type); |
|||
return types.ToArray(); |
|||
} |
|||
|
|||
public static FieldInfo GetField(Type type, string fieldName) |
|||
{ |
|||
if (type == null) |
|||
return null; |
|||
const BindingFlags flags = |
|||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance |BindingFlags.DeclaredOnly; |
|||
var fields = type.GetFields(flags); |
|||
foreach (var field in fields) |
|||
if (field.Name == fieldName) |
|||
return field; |
|||
return GetField(type.BaseType, fieldName); |
|||
} |
|||
|
|||
static object GetValue(object source, string name) |
|||
{ |
|||
if (source == null) |
|||
return null; |
|||
var type = source.GetType(); |
|||
var field = GetField(type, name); |
|||
if (field == null) |
|||
{ |
|||
var property = type.GetProperty(name, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase); |
|||
return property == null ? null : property.GetValue(source, null); |
|||
} |
|||
return field.GetValue(source); |
|||
} |
|||
|
|||
static object GetArrayValue(object source, string name, int index) |
|||
{ |
|||
var value = GetValue(source, name); |
|||
if (!(value is IEnumerable enumerable)) |
|||
return null; |
|||
var enumerator = enumerable.GetEnumerator(); |
|||
while (index-- >= 0) |
|||
enumerator.MoveNext(); |
|||
return enumerator.Current; |
|||
} |
|||
|
|||
public static object GetManagedReferenceValue(SerializedProperty prop, bool parent = false) |
|||
{ |
|||
var path = prop.propertyPath.Replace(".Array.data[", "["); |
|||
object obj = prop.serializedObject.targetObject; |
|||
var elements = path.Split('.'); |
|||
if (parent) |
|||
elements = elements.Take(elements.Length - 1).ToArray(); |
|||
|
|||
foreach (var element in elements) |
|||
if (element.Contains("[")) |
|||
{ |
|||
var elementName = element.Substring(0, element.IndexOf("[")); |
|||
var index = Convert.ToInt32(element.Substring(element.IndexOf("[")).Replace("[", "").Replace("]", "")); |
|||
obj = GetArrayValue(obj, elementName, index); |
|||
} |
|||
else |
|||
{ |
|||
obj = GetValue(obj, element); |
|||
} |
|||
|
|||
return obj; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ef7a918bf9607df47814d7a7041454a8 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: a9e1dad40ca390d42a0dcb2b136042d9 |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement class="consumer-endpoint__element"> |
|||
<VisualElement name="drag-handle" class="consumer-endpoint__drag-handle"/> |
|||
<VisualElement style="flex-grow: 1;"> |
|||
<VisualElement style="flex-direction: row; justify-content: space-between;"> |
|||
<VisualElement style="flex-direction: row; align-items: center;"> |
|||
<VisualElement name="collapse" class="randomization__collapse-toggle foldout-open"/> |
|||
<Toggle name="enabled"/> |
|||
<TextElement name="class-name" text="Consumer Endpoint Class Name"/> |
|||
</VisualElement> |
|||
<Button name="remove" class="randomization__remove-item-button"/> |
|||
</VisualElement> |
|||
<VisualElement name="properties" class="randomization__collapsible-container" style="padding-left: 16px;"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: 18ab57ec859168e4db7287a0dcc1206f |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements"> |
|||
<VisualElement> |
|||
<Style src="../../Uss/Styles.uss"/> |
|||
<VisualElement name="endpoint-list-placeholder" style = "margin-top: 10px"/> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: d55dcb751c632144ca061bf5bc90f892 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
|
|||
<UXML xmlns="UnityEngine.UIElements"> |
|||
<VisualElement style="min-height: 132px;"> |
|||
<VisualElement class="dataset-capture__dark-viewport"> |
|||
<TextElement text="Consumer Endpoints" class="scenario__title-label"/> |
|||
<TextElement |
|||
class="dataset-capture__info-box" |
|||
text="Need to say a bunch of stuff here."/> |
|||
<VisualElement name="consumer-endpoints-container" style="margin-top: 3px; min-height: 100px;"/> |
|||
<VisualElement style="flex-direction: row; align-items: center; justify-content: center; margin-top: 2px;"> |
|||
<Button name="add-consumer-endpoint-button" text="Add Endpoint"/> |
|||
<Button name="expand-all" text="Expand All"/> |
|||
<Button name="collapse-all" text="Collapse All"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
fileFormatVersion: 2 |
|||
guid: c1b51a431ff3c334b8d57dba2acf2ee2 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0} |
撰写
预览
正在加载...
取消
保存
Reference in new issue