Steve Borkman
3 年前
当前提交
eb7c733a
共有 18 个文件被更改,包括 262 次插入 和 131 次删除
-
93com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
-
4com.unity.perception/Runtime/GroundTruth/ConsumerEndpoint.cs
-
8com.unity.perception/Runtime/GroundTruth/Consumers/NoOpConsumer.cs
-
6com.unity.perception/Runtime/GroundTruth/Consumers/OldPerceptionConsumer.cs
-
9com.unity.perception/Runtime/GroundTruth/Consumers/SoloConsumer.cs
-
5com.unity.perception/Runtime/GroundTruth/Consumers/SoloMessageBuilder.cs
-
32com.unity.perception/Runtime/GroundTruth/DatasetCapture.cs
-
6com.unity.perception/Runtime/GroundTruth/SimulationState.cs
-
5com.unity.perception/Tests/Runtime/GroundTruthTests/CollectEndpoint.cs
-
53com.unity.perception/Tests/Runtime/GroundTruthTests/DatasetCaptureTests.cs
-
12com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
-
4com.unity.perception/Tests/Runtime/Randomization/ScenarioTests/ScenarioTests.cs
-
99com.unity.perception/Editor/GroundTruth/SettingsProvider.cs
-
3com.unity.perception/Editor/GroundTruth/SettingsProvider.cs.meta
-
3com.unity.perception/Runtime/Settings.meta
-
40com.unity.perception/Runtime/Settings/PerceptionSettings.cs
-
11com.unity.perception/Runtime/Settings/PerceptionSettings.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.Settings; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth |
|||
{ |
|||
public class PerceptionSettingsProvider : SettingsProvider |
|||
{ |
|||
private SerializedObject m_CustomSettings; |
|||
public static string projectPath = "Project/Perception"; |
|||
|
|||
class Styles |
|||
{ |
|||
public static GUIContent endpoint = new GUIContent("Active Endpoint"); |
|||
} |
|||
|
|||
public PerceptionSettingsProvider(string path, SettingsScope scope = SettingsScope.User) |
|||
: base(path, scope) { } |
|||
|
|||
public override void OnActivate(string searchContext, VisualElement rootElement) |
|||
{ |
|||
m_CustomSettings = PerceptionSettings.GetSerializedSettings(); |
|||
} |
|||
|
|||
public override void OnGUI(string searchContext) |
|||
{ |
|||
EditorGUILayout.PropertyField(m_CustomSettings.FindProperty("endpoint"), Styles.endpoint); |
|||
m_CustomSettings.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
[SettingsProvider] |
|||
public static SettingsProvider CreateMyCustomSettingsProvider() |
|||
{ |
|||
if (PerceptionSettings.IsSettingsAvailable()) |
|||
{ |
|||
var provider = new PerceptionSettingsProvider(projectPath, SettingsScope.Project); |
|||
|
|||
// Automatically extract all keywords from the Styles.
|
|||
provider.keywords = GetSearchKeywordsFromGUIContentProperties<Styles>(); |
|||
return provider; |
|||
} |
|||
|
|||
// Settings Asset doesn't exist yet; no need to display anything in the Settings window.
|
|||
return null; |
|||
} |
|||
} |
|||
|
|||
static class PerceptionSettingsRegister |
|||
{ |
|||
[SettingsProvider] |
|||
public static SettingsProvider CreatePerceptionSettingsProvider() |
|||
{ |
|||
var provider = new SettingsProvider(PerceptionSettingsProvider.projectPath, SettingsScope.Project) |
|||
{ |
|||
label = "Perception", |
|||
|
|||
activateHandler = (searchContext, rootElement) => |
|||
{ |
|||
var settings = PerceptionSettings.GetSerializedSettings(); |
|||
|
|||
// rootElement is a VisualElement. If you add any children to it, the OnGUI function
|
|||
// isn't called because the SettingsProvider uses the UIElements drawing framework.
|
|||
var styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>("Packages/com.unity.perception/Editor/GroundTruth/Uss/Styles.uss"); |
|||
rootElement.styleSheets.Add(styleSheet); |
|||
var title = new Label() |
|||
{ |
|||
text = "Perception" |
|||
}; |
|||
title.AddToClassList("title"); |
|||
rootElement.Add(title); |
|||
|
|||
var properties = new VisualElement() |
|||
{ |
|||
style = |
|||
{ |
|||
flexDirection = FlexDirection.Column |
|||
} |
|||
}; |
|||
properties.AddToClassList("property-list"); |
|||
rootElement.Add(properties); |
|||
|
|||
var tf = new TextField() |
|||
{ |
|||
value = settings.FindProperty("m_SomeString").stringValue |
|||
}; |
|||
tf.AddToClassList("property-value"); |
|||
properties.Add(tf); |
|||
}, |
|||
|
|||
keywords = new HashSet<string>(new[] { "Active Endpoint" }) |
|||
}; |
|||
|
|||
return provider; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 987301ba33874109b5562048bc3d5956 |
|||
timeCreated: 1634067424 |
|
|||
fileFormatVersion: 2 |
|||
guid: a26f91b2e24a4a5d90008ca1851054bd |
|||
timeCreated: 1634074669 |
|
|||
using System.IO; |
|||
using UnityEditor; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
namespace UnityEngine.Perception.Settings |
|||
{ |
|||
public class PerceptionSettings : ScriptableObject |
|||
{ |
|||
const string k_SettingsPath = "Assets/Settings/PerceptionSettings.asset"; |
|||
|
|||
[SerializeField] |
|||
ConsumerEndpoint endpoint; |
|||
|
|||
public static ConsumerEndpoint Endpoint => GetOrCreateSettings().endpoint; |
|||
|
|||
static PerceptionSettings GetOrCreateSettings() |
|||
{ |
|||
var settings = AssetDatabase.LoadAssetAtPath<PerceptionSettings>(k_SettingsPath); |
|||
if (settings == null) |
|||
{ |
|||
settings = ScriptableObject.CreateInstance<PerceptionSettings>(); |
|||
settings.endpoint = null; |
|||
AssetDatabase.CreateAsset(settings, k_SettingsPath); |
|||
AssetDatabase.SaveAssets(); |
|||
} |
|||
return settings; |
|||
} |
|||
|
|||
public static bool IsSettingsAvailable() |
|||
{ |
|||
return File.Exists(PerceptionSettings.k_SettingsPath); |
|||
} |
|||
|
|||
public static SerializedObject GetSerializedSettings() |
|||
{ |
|||
return new SerializedObject(GetOrCreateSettings()); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c5ee903ff896bde4bb82aed4aec2bf61 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue