Steven Leal
4 年前
当前提交
7d0ec48a
共有 25 个文件被更改,包括 201 次插入 和 605 次删除
-
2com.unity.perception/Editor/Randomization/Uss/ParameterStyles.uss
-
10com.unity.perception/Editor/Randomization/Uxml/ParameterListItemElement.uxml
-
129com.unity.perception/Editor/Randomization/VisualElements/ParameterListItemElement.cs
-
34com.unity.perception/Runtime/Randomization/ParameterBehaviours/ParameterBehaviour.cs
-
20com.unity.perception/Runtime/Randomization/Scenarios/ScenarioBase.cs
-
73com.unity.perception/Editor/Randomization/Editors/ParametersAssetEditor.cs
-
46com.unity.perception/Editor/Randomization/Uss/ParameterAssetStyles.uss
-
21com.unity.perception/Editor/Randomization/Uxml/ParameterAssetEditor.uxml
-
33com.unity.perception/Runtime/Randomization/ParameterBehaviours/ParameterAsset.cs
-
30com.unity.perception/Editor/Randomization/Editors/ParameterBehaviourEditor.cs
-
3com.unity.perception/Editor/Randomization/Editors/ParameterBehaviourEditor.cs.meta
-
11com.unity.perception/Editor/Randomization/Editors/ParameterListEditor.cs.meta
-
121com.unity.perception/Editor/Randomization/Editors/ParameterListEditor.cs
-
29com.unity.perception/Editor/Randomization/Editors/RandomParametersAssetEditor.cs
-
81com.unity.perception/Editor/Randomization/Uss/ParameterListStyles.uss
-
21com.unity.perception/Editor/Randomization/Uxml/ParameterListEditor.uxml
-
12com.unity.perception/Editor/Randomization/VisualElements/ParameterDragBar.cs
-
3com.unity.perception/Editor/Randomization/VisualElements/ParameterDragBar.cs.meta
-
3com.unity.perception/Editor/Randomization/VisualElements/ParameterDragManipulator.cs.meta
-
101com.unity.perception/Editor/Randomization/VisualElements/ParameterDragManipulator.cs
-
23com.unity.perception/Runtime/Randomization/ParameterBehaviours/RandomParametersAsset.cs
-
0/com.unity.perception/Editor/Randomization/Editors/ParametersAssetEditor.cs.meta
-
0/com.unity.perception/Editor/Randomization/Uss/ParameterAssetStyles.uss.meta
-
0/com.unity.perception/Editor/Randomization/Uxml/ParameterAssetEditor.uxml.meta
-
0/com.unity.perception/Runtime/Randomization/ParameterBehaviours/ParameterAsset.cs.meta
|
|||
using System; |
|||
using Randomization.ParameterBehaviours; |
|||
using UnityEditor; |
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
[CustomEditor(typeof(ParameterAsset), true)] |
|||
public class ParametersAssetEditor : UnityEditor.Editor |
|||
{ |
|||
VisualElement m_Root; |
|||
VisualElement m_ParameterContainer; |
|||
SerializedProperty m_Parameters; |
|||
|
|||
string m_FilterString = string.Empty; |
|||
string FilterString |
|||
{ |
|||
set |
|||
{ |
|||
m_FilterString = value; |
|||
var lowerFilter = m_FilterString.ToLower(); |
|||
foreach (var child in m_ParameterContainer.Children()) |
|||
{ |
|||
var param = (ParameterListItemElement)child; |
|||
param.filtered = param.displayName.ToLower().Contains(lowerFilter); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ParameterAssetEditor.uxml").CloneTree(); |
|||
|
|||
m_ParameterContainer = m_Root.Q<VisualElement>("parameters-container"); |
|||
|
|||
var filter = m_Root.Q<TextField>("filter-parameters"); |
|||
filter.RegisterValueChangedCallback((e) => { FilterString = e.newValue; }); |
|||
|
|||
var collapseAllButton = m_Root.Q<Button>("collapse-all"); |
|||
collapseAllButton.clicked += () => CollapseParameters(true); |
|||
|
|||
var expandAllButton = m_Root.Q<Button>("expand-all"); |
|||
expandAllButton.clicked += () => CollapseParameters(false); |
|||
|
|||
RefreshParameterElements(); |
|||
|
|||
return m_Root; |
|||
} |
|||
|
|||
void RefreshParameterElements() |
|||
{ |
|||
m_ParameterContainer.Clear(); |
|||
var properties = serializedObject.GetIterator(); |
|||
if (properties.NextVisible(true)) |
|||
{ |
|||
do |
|||
{ |
|||
var propertyValue = StaticData.GetManagedReferenceValue(properties); |
|||
if (propertyValue != null && propertyValue.GetType().IsSubclassOf(typeof(Parameter))) |
|||
m_ParameterContainer.Add(new ParameterListItemElement(properties.Copy())); |
|||
} while (properties.NextVisible(false)); |
|||
} |
|||
} |
|||
|
|||
void CollapseParameters(bool collapsed) |
|||
{ |
|||
foreach (var child in m_ParameterContainer.Children()) |
|||
((ParameterListItemElement)child).collapsed = collapsed; |
|||
} |
|||
} |
|||
} |
|
|||
.dark-viewport { |
|||
border-radius: 5px; |
|||
background-color: #191919; |
|||
padding: 2px; |
|||
} |
|||
|
|||
.unity-toggle { |
|||
margin-left: 0; |
|||
} |
|||
|
|||
.remove-parameter-button { |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/X.png"); |
|||
width: 16px; |
|||
height: 16px; |
|||
} |
|||
|
|||
.move-buttons-container { |
|||
width: auto; |
|||
margin-right: 6px; |
|||
border-color: black; |
|||
border-top-left-radius: 3px; |
|||
border-bottom-left-radius: 3px; |
|||
background-color: #2A2A2A; |
|||
padding: 3px 2px; |
|||
justify-content: center; |
|||
} |
|||
|
|||
.drag-handle { |
|||
width: 16px; |
|||
height: 70%; |
|||
min-height: 20px; |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/DragHandle.png"); |
|||
} |
|||
|
|||
.unity-imgui-container { |
|||
margin-left: 1px; |
|||
margin-right: 3px; |
|||
} |
|||
|
|||
.search-icon { |
|||
width: 16px; |
|||
height: 16px; |
|||
margin-top: 2px; |
|||
flex-shrink: 0; |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/Search.png"); |
|||
} |
|
|||
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements"> |
|||
<VisualElement style="height: 100%;"> |
|||
<Style src="../Uss/ParameterAssetStyles.uss"/> |
|||
|
|||
<VisualElement style="flex-direction: row; align-items: center; margin-bottom: 2px; margin-top: 2px;"> |
|||
<VisualElement class="search-icon" style="margin-left: 3px; margin-right: 2px;"/> |
|||
<TextField name="filter-parameters" style="flex-grow: 1; flex-shrink: 1;"/> |
|||
</VisualElement> |
|||
|
|||
<VisualElement class="dark-viewport" style="min-height: 100px;"> |
|||
<VisualElement name="parameters-container" style="flex-shrink: 0;"/> |
|||
</VisualElement> |
|||
|
|||
<VisualElement style="flex-direction: row; justify-content: center;"> |
|||
<VisualElement style="flex-grow: 1"/> |
|||
<Button name="collapse-all" text="Collapse All" style="font-size: 13px; padding: 4px;"/> |
|||
<Button name="expand-all" text="Expand All" style="font-size: 13px; padding: 4px;"/> |
|||
<VisualElement style="flex-grow: 1"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.Perception.Randomization.Samplers; |
|||
|
|||
namespace Randomization.ParameterBehaviours |
|||
{ |
|||
public abstract class ParameterAsset : ScriptableObject |
|||
{ |
|||
public abstract IEnumerable<Parameter> parameters { get; } |
|||
|
|||
/// <summary>
|
|||
/// Reset to default values in the Editor
|
|||
/// </summary>
|
|||
void Reset() |
|||
{ |
|||
var fields = GetType().GetFields(); |
|||
foreach (var field in fields) |
|||
{ |
|||
if (!field.IsPublic || !field.FieldType.IsSubclassOf(typeof(Parameter))) |
|||
continue; |
|||
var parameter = (Parameter)field.GetValue(this); |
|||
if (parameter == null) |
|||
field.SetValue(this, Activator.CreateInstance(field.FieldType)); |
|||
} |
|||
|
|||
foreach (var parameter in parameters) |
|||
foreach (var sampler in parameter.samplers) |
|||
sampler.baseSeed = SamplerUtility.GenerateRandomSeed(); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using Randomization.ParameterBehaviours; |
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
[CustomEditor(typeof(ParameterBehaviour), true)] |
|||
class ParameterBehaviourEditor : UnityEditor.Editor |
|||
{ |
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
var root = new VisualElement(); |
|||
var iterator = serializedObject.GetIterator(); |
|||
|
|||
// Start iterating over properties
|
|||
iterator.NextVisible(true); |
|||
|
|||
// Skip m_Script property
|
|||
iterator.NextVisible(false); |
|||
|
|||
// Create property fields
|
|||
do { root.Add(new PropertyField(iterator.Copy())); } |
|||
while (iterator.NextVisible(false)); |
|||
|
|||
return root; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 305a421aca744ce49ced7056c1733f48 |
|||
timeCreated: 1598220645 |
|
|||
fileFormatVersion: 2 |
|||
guid: dd62abede5784c84f90495b367408ced |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine; |
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.Perception.Randomization.ParameterBehaviours; |
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
[CustomEditor(typeof(ParameterList))] |
|||
class ParameterListEditor : UnityEditor.Editor |
|||
{ |
|||
VisualElement m_Root; |
|||
VisualElement m_ParameterContainer; |
|||
SerializedProperty m_Parameters; |
|||
|
|||
public ParameterList config; |
|||
|
|||
string m_FilterString = string.Empty; |
|||
public string FilterString |
|||
{ |
|||
get => m_FilterString; |
|||
private set |
|||
{ |
|||
m_FilterString = value; |
|||
var lowerFilter = m_FilterString.ToLower(); |
|||
foreach (var child in m_ParameterContainer.Children()) |
|||
{ |
|||
var paramIndex = m_ParameterContainer.IndexOf(child); |
|||
var param = config.configuredParameters[paramIndex]; |
|||
((ParameterListItemElement)child).filtered = param.name.ToLower().Contains(lowerFilter); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
config = (ParameterList)target; |
|||
m_Parameters = serializedObject.FindProperty("configuredParameters"); |
|||
m_Root = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>( |
|||
$"{StaticData.uxmlDir}/ParameterListEditor.uxml").CloneTree(); |
|||
|
|||
m_ParameterContainer = m_Root.Q<VisualElement>("parameters-container"); |
|||
|
|||
var filter = m_Root.Q<TextField>("filter-parameters"); |
|||
filter.RegisterValueChangedCallback((e) => { FilterString = e.newValue; }); |
|||
|
|||
var collapseAllButton = m_Root.Q<Button>("collapse-all"); |
|||
collapseAllButton.clicked += () => CollapseParameters(true); |
|||
|
|||
var expandAllButton = m_Root.Q<Button>("expand-all"); |
|||
expandAllButton.clicked += () => CollapseParameters(false); |
|||
|
|||
var parameterTypeMenu = m_Root.Q<ToolbarMenu>("parameter-type-menu"); |
|||
foreach (var parameterType in StaticData.parameterTypes) |
|||
{ |
|||
parameterTypeMenu.menu.AppendAction( |
|||
Parameter.GetDisplayName(parameterType), |
|||
a => { AddParameter(parameterType); }, |
|||
a => DropdownMenuAction.Status.Normal); |
|||
} |
|||
|
|||
RefreshParameterElements(); |
|||
|
|||
return m_Root; |
|||
} |
|||
|
|||
void RefreshParameterElements() |
|||
{ |
|||
m_ParameterContainer.Clear(); |
|||
for (var i = 0; i < m_Parameters.arraySize; i++) |
|||
m_ParameterContainer.Add(new ParameterListItemElement(m_Parameters.GetArrayElementAtIndex(i), this)); |
|||
} |
|||
|
|||
void AddParameter(Type parameterType) |
|||
{ |
|||
var configuredParameter = config.AddParameter($"Parameter{m_Parameters.arraySize}", parameterType); |
|||
configuredParameter.parameter.RandomizeSamplers(); |
|||
serializedObject.Update(); |
|||
RefreshParameterElements(); |
|||
} |
|||
|
|||
public void RemoveParameter(VisualElement template) |
|||
{ |
|||
var paramIndex = m_ParameterContainer.IndexOf(template); |
|||
m_ParameterContainer.RemoveAt(paramIndex); |
|||
config.configuredParameters.RemoveAt(paramIndex); |
|||
serializedObject.Update(); |
|||
RefreshParameterElements(); |
|||
} |
|||
|
|||
public void ReorderParameter(int currentIndex, int nextIndex) |
|||
{ |
|||
if (currentIndex == nextIndex) |
|||
return; |
|||
|
|||
if (nextIndex > currentIndex) |
|||
nextIndex--; |
|||
|
|||
var parameterElement = m_ParameterContainer[currentIndex]; |
|||
var parameter = config.configuredParameters[currentIndex]; |
|||
|
|||
parameterElement.RemoveFromHierarchy(); |
|||
config.configuredParameters.RemoveAt(currentIndex); |
|||
|
|||
m_ParameterContainer.Insert(nextIndex, parameterElement); |
|||
config.configuredParameters.Insert(nextIndex, parameter); |
|||
|
|||
serializedObject.Update(); |
|||
|
|||
RefreshParameterElements(); |
|||
} |
|||
|
|||
void CollapseParameters(bool collapsed) |
|||
{ |
|||
foreach (var child in m_ParameterContainer.Children()) |
|||
((ParameterListItemElement)child).collapsed = collapsed; |
|||
} |
|||
} |
|||
} |
|
|||
using Randomization.ParameterBehaviours; |
|||
using UnityEditor; |
|||
using UnityEditor.UIElements; |
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
[CustomEditor(typeof(RandomParametersAsset), true)] |
|||
public class RandomParametersAssetEditor : UnityEditor.Editor |
|||
{ |
|||
public override VisualElement CreateInspectorGUI() |
|||
{ |
|||
var root = new VisualElement(); |
|||
var iterator = serializedObject.GetIterator(); |
|||
|
|||
// Start iterating over properties
|
|||
iterator.NextVisible(true); |
|||
|
|||
// Skip m_Script property
|
|||
iterator.NextVisible(false); |
|||
|
|||
// Create property fields
|
|||
do { root.Add(new PropertyField(iterator.Copy())); } |
|||
while (iterator.NextVisible(false)); |
|||
|
|||
return root; |
|||
} |
|||
} |
|||
} |
|
|||
.dark-viewport { |
|||
border-radius: 5px; |
|||
background-color: #191919; |
|||
padding: 2px; |
|||
} |
|||
|
|||
.unity-toggle { |
|||
margin-left: 0; |
|||
} |
|||
|
|||
.property-select-menu { |
|||
flex-grow: 1; |
|||
border-width: 1px; |
|||
padding-bottom: 1px; |
|||
border-radius: 3px; |
|||
margin-right: 1px; |
|||
} |
|||
|
|||
.remove-parameter-button { |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/X.png"); |
|||
width: 16px; |
|||
height: 16px; |
|||
} |
|||
|
|||
.move-buttons-container { |
|||
width: auto; |
|||
margin-right: 6px; |
|||
border-color: black; |
|||
border-top-left-radius: 3px; |
|||
border-bottom-left-radius: 3px; |
|||
background-color: #2A2A2A; |
|||
padding: 3px 2px; |
|||
justify-content: center; |
|||
} |
|||
|
|||
.drag-handle { |
|||
width: 16px; |
|||
height: 70%; |
|||
min-height: 20px; |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/DragHandle.png"); |
|||
} |
|||
|
|||
.move-button { |
|||
border-width: 0; |
|||
width: 42px; |
|||
height: 16px; |
|||
padding: 9px; |
|||
-unity-background-scale-mode: scale-to-fit; |
|||
} |
|||
|
|||
.unity-imgui-container { |
|||
margin-left: 1px; |
|||
margin-right: 3px; |
|||
} |
|||
|
|||
.search-icon { |
|||
width: 16px; |
|||
height: 16px; |
|||
margin-top: 2px; |
|||
flex-shrink: 0; |
|||
background-image: resource("Packages/com.unity.perception/Editor/Randomization/Icons/Search.png"); |
|||
} |
|||
|
|||
.parameter-drag-bar { |
|||
width: 100px; |
|||
height: 6px; |
|||
background-color: rgba(100,149,237,0.4); |
|||
position: absolute; |
|||
} |
|||
|
|||
.parameter-type-menu { |
|||
margin: 1px 3px; |
|||
border-width: 1px; |
|||
border-radius: 3px; |
|||
background-color: #585858; |
|||
} |
|||
|
|||
#parameter-type-menu .unity-toolbar-menu__text { |
|||
font-size: 13px; |
|||
padding: 3px; |
|||
} |
|
|||
<UXML xmlns="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements"> |
|||
<VisualElement> |
|||
<Style src="../Uss/ParameterListStyles.uss"/> |
|||
|
|||
<VisualElement style="flex-direction: row; align-items: center; margin-bottom: 2px; margin-top: 2px;"> |
|||
<VisualElement class="search-icon" style="margin-left: 3px; margin-right: 2px;"/> |
|||
<TextField name="filter-parameters" style="flex-grow: 1; flex-shrink: 1;"/> |
|||
</VisualElement> |
|||
<ScrollView name="parameter-scroll-view" class="dark-viewport" style="min-height: 100px; max-height: 600px;"> |
|||
<VisualElement name="parameters-container" style="flex-shrink: 0;"/> |
|||
</ScrollView> |
|||
|
|||
<VisualElement style="flex-direction: row; justify-content: space-between;"> |
|||
<VisualElement style="flex-grow: 1"/> |
|||
<editor:ToolbarMenu text="Add New Parameter" name="parameter-type-menu" class="parameter-type-menu"/> |
|||
<Button name="collapse-all" text="Collapse All" style="font-size: 13px; padding: 4px;"/> |
|||
<Button name="expand-all" text="Expand All" style="font-size: 13px; padding: 4px;"/> |
|||
<VisualElement style="flex-grow: 1"/> |
|||
</VisualElement> |
|||
</VisualElement> |
|||
</UXML> |
|
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class ParameterDragBar : VisualElement |
|||
{ |
|||
public ParameterDragBar() |
|||
{ |
|||
AddToClassList("parameter-drag-bar"); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7c1e08b02e5a4c55875f34baf32f8e76 |
|||
timeCreated: 1596143672 |
|
|||
fileFormatVersion: 2 |
|||
guid: f2b59fa8baf440f597257d8eb8219afa |
|||
timeCreated: 1596140810 |
|
|||
using UnityEngine.UIElements; |
|||
|
|||
namespace UnityEngine.Perception.Randomization.Editor |
|||
{ |
|||
class ParameterDragManipulator : MouseManipulator |
|||
{ |
|||
bool m_Active; |
|||
float m_Offset; |
|||
ParameterListItemElement m_ParameterListItemElement; |
|||
VisualElement m_DragHandle; |
|||
VisualElement m_DragBar; |
|||
VisualElement m_ParameterContainer; |
|||
|
|||
protected override void RegisterCallbacksOnTarget() |
|||
{ |
|||
m_ParameterListItemElement = (ParameterListItemElement)target; |
|||
m_DragHandle = m_ParameterListItemElement.Q<VisualElement>("drag-handle"); |
|||
m_DragHandle.RegisterCallback<MouseDownEvent>(OnMouseDown); |
|||
m_DragHandle.RegisterCallback<MouseMoveEvent>(OnMouseMove); |
|||
m_DragHandle.RegisterCallback<MouseUpEvent>(OnMouseUp); |
|||
} |
|||
|
|||
protected override void UnregisterCallbacksFromTarget() |
|||
{ |
|||
m_DragHandle.UnregisterCallback<MouseDownEvent>(OnMouseDown); |
|||
m_DragHandle.UnregisterCallback<MouseMoveEvent>(OnMouseMove); |
|||
m_DragHandle.UnregisterCallback<MouseUpEvent>(OnMouseUp); |
|||
} |
|||
|
|||
void OnMouseDown(MouseDownEvent evt) |
|||
{ |
|||
if (m_Active) |
|||
{ |
|||
evt.StopImmediatePropagation(); |
|||
return; |
|||
} |
|||
|
|||
if (m_ParameterListItemElement.configEditor.FilterString != string.Empty) |
|||
return; |
|||
|
|||
m_ParameterContainer = target.parent; |
|||
m_DragBar = new ParameterDragBar(); |
|||
m_DragBar.style.width = new StyleLength(m_ParameterContainer.resolvedStyle.width); |
|||
target.parent.Add(m_DragBar); |
|||
|
|||
m_Offset = m_DragHandle.worldBound.position.y - m_ParameterContainer.worldBound.position.y; |
|||
m_DragBar.style.top = evt.localMousePosition.y + m_Offset; |
|||
|
|||
m_Active = true; |
|||
m_DragHandle.CaptureMouse(); |
|||
evt.StopPropagation(); |
|||
} |
|||
|
|||
void OnMouseMove(MouseMoveEvent evt) |
|||
{ |
|||
if (!m_Active || !m_DragHandle.HasMouseCapture()) |
|||
return; |
|||
|
|||
m_DragBar.style.top = evt.localMousePosition.y + m_Offset; |
|||
|
|||
evt.StopPropagation(); |
|||
} |
|||
|
|||
void OnMouseUp(MouseUpEvent evt) |
|||
{ |
|||
if (!m_Active || !m_DragHandle.HasMouseCapture() || !CanStopManipulation(evt)) |
|||
return; |
|||
|
|||
var dragBarY = evt.localMousePosition.y + m_Offset; |
|||
m_DragBar.RemoveFromHierarchy(); |
|||
|
|||
m_Active = false; |
|||
m_DragHandle.ReleaseMouse(); |
|||
evt.StopPropagation(); |
|||
|
|||
var p = 0; |
|||
var middlePoints = new float[m_ParameterContainer.childCount]; |
|||
foreach (var parameterElement in m_ParameterContainer.Children()) |
|||
{ |
|||
var middleHeight = parameterElement.worldBound.height / 2; |
|||
var localY = parameterElement.worldBound.y - m_ParameterContainer.worldBound.position.y; |
|||
middlePoints[p++] = middleHeight + localY; |
|||
} |
|||
|
|||
for (var i = 0; i < middlePoints.Length; i++) |
|||
{ |
|||
if (dragBarY < middlePoints[i]) |
|||
{ |
|||
ReorderParameter(m_ParameterListItemElement.ParameterIndex, i); |
|||
return; |
|||
} |
|||
} |
|||
ReorderParameter(m_ParameterListItemElement.ParameterIndex, middlePoints.Length); |
|||
} |
|||
|
|||
void ReorderParameter(int currentIndex, int nextIndex) |
|||
{ |
|||
m_ParameterListItemElement.configEditor.ReorderParameter(currentIndex, nextIndex); |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.Randomization.Parameters; |
|||
using UnityEngine.Perception.Randomization.Samplers; |
|||
|
|||
namespace Randomization.ParameterBehaviours |
|||
{ |
|||
public abstract class RandomParametersAsset : ScriptableObject |
|||
{ |
|||
public abstract IEnumerable<Parameter> parameters { get; } |
|||
|
|||
/// <summary>
|
|||
/// Reset to default values in the Editor
|
|||
/// </summary>
|
|||
void Reset() |
|||
{ |
|||
foreach (var parameter in parameters) |
|||
foreach (var sampler in parameter.samplers) |
|||
sampler.baseSeed = SamplerUtility.GenerateRandomSeed(); |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue