Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,17 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(ControlInput))]
|
||||
public class
|
||||
ControlInputWidget : UnitInputPortWidget<ControlInput>
|
||||
{
|
||||
public ControlInputWidget(FlowCanvas canvas, ControlInput port) : base(canvas, port) { }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.controlPortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.controlPortUnconnected?[12];
|
||||
|
||||
protected override bool colorIfActive => !BoltFlow.Configuration.animateControlConnections || !BoltFlow.Configuration.animateValueConnections;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a608417e8e4b45678ccec3fec1ff1e7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,16 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(ControlOutput))]
|
||||
public class ControlOutputWidget : UnitOutputPortWidget<ControlOutput>
|
||||
{
|
||||
public ControlOutputWidget(FlowCanvas canvas, ControlOutput port) : base(canvas, port) { }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.controlPortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.controlPortUnconnected?[12];
|
||||
|
||||
protected override bool colorIfActive => !BoltFlow.Configuration.animateControlConnections || !BoltFlow.Configuration.animateValueConnections;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca12711a98bb548dc9eaa87d8d4d7263
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,14 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
public interface IUnitPortWidget : IWidget
|
||||
{
|
||||
IUnitPort port { get; }
|
||||
float y { set; }
|
||||
Rect handlePosition { get; }
|
||||
float GetInnerWidth();
|
||||
float GetHeight();
|
||||
bool willDisconnect { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1fd9d037384804ceb8ec4553867935cc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(InvalidInput))]
|
||||
public class InvalidInputWidget : UnitInputPortWidget<InvalidInput>
|
||||
{
|
||||
public InvalidInputWidget(FlowCanvas canvas, InvalidInput port) : base(canvas, port) { }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.invalidPortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.invalidPortUnconnected?[12];
|
||||
|
||||
protected override bool colorIfActive => false;
|
||||
|
||||
protected override bool canStartConnection => false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bfbd8ae9f1465463e947470757c476e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(InvalidOutput))]
|
||||
public class InvalidOutputWidget : UnitOutputPortWidget<InvalidOutput>
|
||||
{
|
||||
public InvalidOutputWidget(FlowCanvas canvas, InvalidOutput port) : base(canvas, port) { }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.invalidPortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.invalidPortUnconnected?[12];
|
||||
|
||||
protected override bool colorIfActive => false;
|
||||
|
||||
protected override bool canStartConnection => false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7306e68be1a5b48909d2c871e5eb5a00
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class UnitInputPortWidget<TPort> : UnitPortWidget<TPort> where TPort : class, IUnitInputPort
|
||||
{
|
||||
protected UnitInputPortWidget(FlowCanvas canvas, TPort port) : base(canvas, port) { }
|
||||
|
||||
protected override Edge edge => Edge.Left;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c54ce026372e84ba19e0a32de76dd6c6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
namespace Unity.VisualScripting
|
||||
{
|
||||
public abstract class UnitOutputPortWidget<TPort> : UnitPortWidget<TPort> where TPort : class, IUnitOutputPort
|
||||
{
|
||||
protected UnitOutputPortWidget(FlowCanvas canvas, TPort port) : base(canvas, port) { }
|
||||
|
||||
protected override Edge edge => Edge.Right;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f8e71549dfa4c490293edb249f48fccb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,110 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(IUnitPortDefinition))]
|
||||
public class UnitPortDefinitionInspector : Inspector
|
||||
{
|
||||
public UnitPortDefinitionInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
metadata.instantiate = true;
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
private Metadata keyMetadata => metadata[nameof(IUnitPortDefinition.key)];
|
||||
private Metadata labelMetadata => metadata[nameof(IUnitPortDefinition.label)];
|
||||
private Metadata descriptionMetadata => metadata[nameof(IUnitPortDefinition.summary)];
|
||||
private Metadata hideLabelMetadata => metadata[nameof(IUnitPortDefinition.hideLabel)];
|
||||
|
||||
protected float GetKeyHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, keyMetadata, width);
|
||||
}
|
||||
|
||||
protected float GetLabelHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, labelMetadata, width);
|
||||
}
|
||||
|
||||
protected float GetDescriptionHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, descriptionMetadata, width);
|
||||
}
|
||||
|
||||
protected float GetHideLabelHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, hideLabelMetadata, width);
|
||||
}
|
||||
|
||||
protected void OnKeyGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(keyMetadata, position);
|
||||
}
|
||||
|
||||
protected void OnLabelGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(labelMetadata, position);
|
||||
}
|
||||
|
||||
protected void OnDescriptionGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(descriptionMetadata, position);
|
||||
}
|
||||
|
||||
protected void OnHideLabelGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(hideLabelMetadata, position);
|
||||
}
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
var height = 0f;
|
||||
|
||||
height += GetKeyHeight(width);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetLabelHeight(width);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetDescriptionHeight(width);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetHideLabelHeight(width);
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected virtual void OnFieldsGUI(Rect position)
|
||||
{
|
||||
OnKeyGUI(position.VerticalSection(ref y, GetKeyHeight(position.width)));
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnLabelGUI(position.VerticalSection(ref y, GetLabelHeight(position.width)));
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnDescriptionGUI(position.VerticalSection(ref y, GetDescriptionHeight(position.width)));
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnHideLabelGUI(position.VerticalSection(ref y, GetHideLabelHeight(position.width)));
|
||||
}
|
||||
|
||||
protected sealed override void OnGUI(Rect position, GUIContent label)
|
||||
{
|
||||
BeginLabeledBlock(metadata, position, label);
|
||||
|
||||
OnFieldsGUI(position);
|
||||
|
||||
EndBlock(metadata);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa26083bb17a34b52b1fee6afd411506
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,923 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(IUnitPort))]
|
||||
public abstract class UnitPortWidget<TPort> : Widget<FlowCanvas, TPort>, IUnitPortWidget where TPort : class, IUnitPort
|
||||
{
|
||||
protected UnitPortWidget(FlowCanvas canvas, TPort port) : base(canvas, port) { }
|
||||
|
||||
|
||||
#region Model
|
||||
|
||||
public TPort port => item;
|
||||
|
||||
public IUnit unit => port.unit;
|
||||
|
||||
// Usually very efficient, but cached because it's used so often
|
||||
private IUnitWidget _unitWidget;
|
||||
|
||||
public IUnitWidget unitWidget
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_unitWidget == null)
|
||||
{
|
||||
_unitWidget = canvas.Widget<IUnitWidget>(unit);
|
||||
}
|
||||
|
||||
return _unitWidget;
|
||||
}
|
||||
}
|
||||
|
||||
IUnitPort IUnitPortWidget.port => port;
|
||||
|
||||
protected UnitPortDescription description { get; private set; }
|
||||
|
||||
public Metadata inspectorMetadata { get; private set; }
|
||||
|
||||
protected Inspector inspector { get; private set; }
|
||||
|
||||
public override Metadata FetchMetadata()
|
||||
{
|
||||
return description.getMetadata(unitWidget.metadata);
|
||||
}
|
||||
|
||||
public virtual Metadata FetchInspectorMetadata()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override void CacheDescription()
|
||||
{
|
||||
description = port.Description<UnitPortDescription>();
|
||||
|
||||
labelContent.text = description.label;
|
||||
|
||||
Reposition();
|
||||
}
|
||||
|
||||
protected override void CacheMetadata()
|
||||
{
|
||||
base.CacheMetadata();
|
||||
|
||||
inspectorMetadata = FetchInspectorMetadata();
|
||||
|
||||
if (inspectorMetadata != null)
|
||||
{
|
||||
inspector = unitWidget.GetPortInspector(port, inspectorMetadata);
|
||||
}
|
||||
else
|
||||
{
|
||||
inspector = null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Lifecycle
|
||||
|
||||
public override bool foregroundRequiresInput => showInspector;
|
||||
|
||||
public bool wouldDisconnect { get; private set; }
|
||||
|
||||
public bool willDisconnect => wouldDisconnect && isMouseOver;
|
||||
|
||||
protected virtual bool canStartConnection => true;
|
||||
|
||||
public override void HandleInput()
|
||||
{
|
||||
if (!canvas.isCreatingConnection)
|
||||
{
|
||||
if (e.IsMouseDown(MouseButton.Left))
|
||||
{
|
||||
if (canStartConnection)
|
||||
{
|
||||
StartConnection();
|
||||
}
|
||||
|
||||
e.Use();
|
||||
}
|
||||
else if (e.IsMouseDown(MouseButton.Right))
|
||||
{
|
||||
wouldDisconnect = true;
|
||||
}
|
||||
else if (e.IsMouseUp(MouseButton.Right))
|
||||
{
|
||||
if (isMouseOver)
|
||||
{
|
||||
RemoveConnections();
|
||||
}
|
||||
|
||||
wouldDisconnect = false;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var source = canvas.connectionSource;
|
||||
var isSource = source == port;
|
||||
|
||||
if (!isSource && e.IsMouseDown(MouseButton.Left))
|
||||
{
|
||||
var destination = port;
|
||||
FinishConnection(source, destination);
|
||||
e.Use();
|
||||
}
|
||||
else if (isSource && e.IsMouseUp(MouseButton.Left))
|
||||
{
|
||||
IUnitPort destination = null;
|
||||
|
||||
var hovered = canvas.hoveredWidget;
|
||||
|
||||
if (hovered is IUnitPortWidget)
|
||||
{
|
||||
destination = ((IUnitPortWidget)hovered).port;
|
||||
}
|
||||
else if (hovered is IUnitWidget)
|
||||
{
|
||||
destination = source.CompatiblePort(((IUnitWidget)hovered).unit);
|
||||
}
|
||||
|
||||
if (destination != null)
|
||||
{
|
||||
if (destination != source)
|
||||
{
|
||||
FinishConnection(source, destination);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (canvas.isMouseOverBackground)
|
||||
{
|
||||
canvas.NewUnitContextual();
|
||||
}
|
||||
else if (!canvas.isMouseOver)
|
||||
{
|
||||
canvas.CancelConnection();
|
||||
}
|
||||
}
|
||||
|
||||
e.Use();
|
||||
}
|
||||
else if (isSource && e.IsMouseDrag(MouseButton.Left))
|
||||
{
|
||||
e.Use();
|
||||
}
|
||||
else if (isSource && e.IsMouseDown(MouseButton.Right))
|
||||
{
|
||||
canvas.CancelConnection();
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void StartConnection()
|
||||
{
|
||||
canvas.connectionSource = port;
|
||||
window.Focus();
|
||||
}
|
||||
|
||||
private void RemoveConnections()
|
||||
{
|
||||
UndoUtility.RecordEditedObject("Disconnect Port");
|
||||
|
||||
foreach (var connectedPort in port.connectedPorts)
|
||||
{
|
||||
canvas.Widget(connectedPort.unit).Reposition();
|
||||
}
|
||||
|
||||
unitWidget.Reposition();
|
||||
|
||||
port.Disconnect();
|
||||
|
||||
e.Use();
|
||||
|
||||
GUI.changed = true;
|
||||
}
|
||||
|
||||
private void FinishConnection(IUnitPort source, IUnitPort destination)
|
||||
{
|
||||
if (source.CanValidlyConnectTo(destination))
|
||||
{
|
||||
UndoUtility.RecordEditedObject("Connect Units");
|
||||
source.ValidlyConnectTo(destination);
|
||||
canvas.connectionSource = null;
|
||||
canvas.Widget(source.unit).Reposition();
|
||||
canvas.Widget(destination.unit).Reposition();
|
||||
GUI.changed = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarningFormat
|
||||
(
|
||||
"Cannot connect this {0} to this {1}.\n",
|
||||
source.GetType().HumanName().ToLower(),
|
||||
destination.GetType().HumanName().ToLower()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Contents
|
||||
|
||||
private readonly GUIContent labelContent = new GUIContent();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Positioning
|
||||
|
||||
public override IEnumerable<IWidget> positionDependencies => ((IWidget)unitWidget).Yield();
|
||||
|
||||
public override IEnumerable<IWidget> positionDependers => port.connections.Select(connection => (IWidget)canvas.Widget(connection));
|
||||
|
||||
protected abstract Edge edge { get; }
|
||||
|
||||
public float y { get; set; }
|
||||
|
||||
private Rect _position;
|
||||
|
||||
public override Rect position
|
||||
{
|
||||
get { return _position; }
|
||||
set { }
|
||||
}
|
||||
|
||||
public Rect handlePosition { get; private set; }
|
||||
|
||||
public Rect labelPosition { get; private set; }
|
||||
|
||||
public Rect iconPosition { get; private set; }
|
||||
|
||||
public Rect inspectorPosition { get; private set; }
|
||||
|
||||
public Rect identifierPosition { get; private set; }
|
||||
|
||||
public Rect surroundPosition { get; private set; }
|
||||
|
||||
public override Rect hotArea
|
||||
{
|
||||
get
|
||||
{
|
||||
if (canvas.isCreatingConnection)
|
||||
{
|
||||
if (canvas.connectionSource == port || canvas.connectionSource.CanValidlyConnectTo(port))
|
||||
{
|
||||
return Styles.easierGrabOffset.Add(identifierPosition);
|
||||
}
|
||||
|
||||
return Rect.zero;
|
||||
}
|
||||
|
||||
return Styles.easierGrabOffset.Add(handlePosition);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CachePosition()
|
||||
{
|
||||
var unitPosition = unitWidget.position;
|
||||
|
||||
var x = unitPosition.GetEdgeCenter(edge).x;
|
||||
var outside = edge.Normal().x;
|
||||
var inside = -outside;
|
||||
var flip = inside < 0;
|
||||
|
||||
var handlePosition = new Rect
|
||||
(
|
||||
x + (Styles.handleSize.x + Styles.spaceBetweenEdgeAndHandle) * outside,
|
||||
y + (EditorGUIUtility.singleLineHeight - Styles.handleSize.y) / 2,
|
||||
Styles.handleSize.x,
|
||||
Styles.handleSize.y
|
||||
);
|
||||
|
||||
if (flip)
|
||||
{
|
||||
handlePosition.x -= handlePosition.width;
|
||||
}
|
||||
|
||||
this.handlePosition = handlePosition;
|
||||
|
||||
_position = handlePosition;
|
||||
identifierPosition = handlePosition;
|
||||
|
||||
x += Styles.spaceAfterEdge * inside;
|
||||
|
||||
if (showIcon)
|
||||
{
|
||||
var iconPosition = new Rect
|
||||
(
|
||||
x,
|
||||
y - 1,
|
||||
Styles.iconSize,
|
||||
Styles.iconSize
|
||||
).PixelPerfect();
|
||||
|
||||
if (flip)
|
||||
{
|
||||
iconPosition.x -= iconPosition.width;
|
||||
}
|
||||
|
||||
x += iconPosition.width * inside;
|
||||
|
||||
_position = _position.Encompass(iconPosition);
|
||||
identifierPosition = identifierPosition.Encompass(iconPosition);
|
||||
|
||||
this.iconPosition = iconPosition;
|
||||
}
|
||||
|
||||
if (showIcon && showLabel)
|
||||
{
|
||||
x += Styles.spaceBetweenIconAndLabel * inside;
|
||||
}
|
||||
|
||||
if (showIcon && !showLabel && showInspector)
|
||||
{
|
||||
x += Styles.spaceBetweenIconAndInspector * inside;
|
||||
}
|
||||
|
||||
if (showLabel)
|
||||
{
|
||||
var labelPosition = new Rect
|
||||
(
|
||||
x,
|
||||
y,
|
||||
GetLabelWidth(),
|
||||
GetLabelHeight()
|
||||
);
|
||||
|
||||
if (flip)
|
||||
{
|
||||
labelPosition.x -= labelPosition.width;
|
||||
}
|
||||
|
||||
x += labelPosition.width * inside;
|
||||
|
||||
_position = _position.Encompass(labelPosition);
|
||||
identifierPosition = identifierPosition.Encompass(labelPosition);
|
||||
|
||||
this.labelPosition = labelPosition;
|
||||
}
|
||||
|
||||
if (showLabel && showInspector)
|
||||
{
|
||||
x += Styles.spaceBetweenLabelAndInspector * inside;
|
||||
}
|
||||
|
||||
if (showInspector)
|
||||
{
|
||||
var inspectorPosition = new Rect
|
||||
(
|
||||
x,
|
||||
y,
|
||||
GetInspectorWidth(),
|
||||
GetInspectorHeight()
|
||||
);
|
||||
|
||||
if (flip)
|
||||
{
|
||||
inspectorPosition.x -= inspectorPosition.width;
|
||||
}
|
||||
|
||||
x += inspectorPosition.width * inside;
|
||||
|
||||
_position = _position.Encompass(inspectorPosition);
|
||||
|
||||
this.inspectorPosition = inspectorPosition;
|
||||
}
|
||||
|
||||
surroundPosition = Styles.surroundPadding.Add(identifierPosition);
|
||||
}
|
||||
|
||||
public float GetInnerWidth()
|
||||
{
|
||||
var width = 0f;
|
||||
|
||||
if (showIcon)
|
||||
{
|
||||
width += Styles.iconSize;
|
||||
}
|
||||
|
||||
if (showIcon && showLabel)
|
||||
{
|
||||
width += Styles.spaceBetweenIconAndLabel;
|
||||
}
|
||||
|
||||
if (showIcon && !showLabel && showInspector)
|
||||
{
|
||||
width += Styles.spaceBetweenIconAndInspector;
|
||||
}
|
||||
|
||||
if (showLabel)
|
||||
{
|
||||
width += GetLabelWidth();
|
||||
}
|
||||
|
||||
if (showLabel && showInspector)
|
||||
{
|
||||
width += Styles.spaceBetweenLabelAndInspector;
|
||||
}
|
||||
|
||||
if (showInspector)
|
||||
{
|
||||
width += GetInspectorWidth();
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
private float GetInspectorWidth()
|
||||
{
|
||||
var width = inspector.GetAdaptiveWidth();
|
||||
|
||||
width = Mathf.Min(width, Styles.maxInspectorWidth);
|
||||
|
||||
if (!showLabel)
|
||||
{
|
||||
width = Mathf.Max(width, Styles.labellessInspectorMinWidth);
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
private float GetLabelWidth()
|
||||
{
|
||||
return Mathf.Min(Styles.label.CalcSize(labelContent).x, Styles.maxLabelWidth);
|
||||
}
|
||||
|
||||
public float GetHeight()
|
||||
{
|
||||
var height = EditorGUIUtility.singleLineHeight;
|
||||
|
||||
if (showIcon)
|
||||
{
|
||||
height = Mathf.Max(height, Styles.iconSize);
|
||||
}
|
||||
|
||||
if (showLabel)
|
||||
{
|
||||
height = Mathf.Max(height, GetLabelHeight());
|
||||
}
|
||||
|
||||
if (showInspector)
|
||||
{
|
||||
height = Mathf.Max(height, GetInspectorHeight());
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
private float GetLabelHeight()
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight;
|
||||
}
|
||||
|
||||
private float GetInspectorHeight()
|
||||
{
|
||||
var width = GetInspectorWidth();
|
||||
|
||||
using (LudiqGUIUtility.currentInspectorWidth.Override(width))
|
||||
{
|
||||
return inspector.GetCachedHeight(width, GUIContent.none, null);
|
||||
}
|
||||
}
|
||||
|
||||
public override float zIndex
|
||||
{
|
||||
get { return unitWidget.zIndex + 0.5f; }
|
||||
set { }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Drawing
|
||||
|
||||
public override bool canClip => base.canClip && canvas.connectionSource != port;
|
||||
|
||||
protected virtual bool showInspector => false;
|
||||
|
||||
protected bool showIcon => description.icon != null;
|
||||
|
||||
protected bool showLabel => description.showLabel;
|
||||
|
||||
public virtual Color color => Color.white;
|
||||
|
||||
protected abstract Texture handleTextureConnected { get; }
|
||||
|
||||
protected abstract Texture handleTextureUnconnected { get; }
|
||||
|
||||
protected virtual bool colorIfActive => true;
|
||||
|
||||
protected override bool dim
|
||||
{
|
||||
get
|
||||
{
|
||||
var dim = BoltCore.Configuration.dimInactiveNodes && !unit.Analysis<UnitAnalysis>(context).isEntered;
|
||||
|
||||
if (unitWidget.isMouseOver || unitWidget.isSelected)
|
||||
{
|
||||
dim = false;
|
||||
}
|
||||
|
||||
if (BoltCore.Configuration.dimIncompatibleNodes && canvas.isCreatingConnection)
|
||||
{
|
||||
dim = canvas.connectionSource != port && !canvas.connectionSource.CanValidlyConnectTo(port);
|
||||
}
|
||||
|
||||
return dim;
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawBackground() { }
|
||||
|
||||
public override void DrawForeground()
|
||||
{
|
||||
if (BoltCore.Configuration.developerMode && BoltCore.Configuration.debug)
|
||||
{
|
||||
EditorGUI.DrawRect(clippingPosition, new Color(0, 0, 0, 0.1f));
|
||||
}
|
||||
|
||||
BeginDim();
|
||||
|
||||
DrawHandle();
|
||||
|
||||
if (showIcon)
|
||||
{
|
||||
DrawIcon();
|
||||
}
|
||||
|
||||
if (showLabel)
|
||||
{
|
||||
DrawLabel();
|
||||
}
|
||||
|
||||
if (showInspector && graph.zoom >= FlowCanvas.inspectorZoomThreshold)
|
||||
{
|
||||
DrawInspector();
|
||||
}
|
||||
|
||||
EndDim();
|
||||
}
|
||||
|
||||
public override void DrawOverlay()
|
||||
{
|
||||
base.DrawOverlay();
|
||||
|
||||
var surroundFromPort = canvas.isCreatingConnection &&
|
||||
isMouseOver &&
|
||||
canvas.connectionSource.CanValidlyConnectTo(port);
|
||||
|
||||
var surroundFromUnit = canvas.isCreatingConnection &&
|
||||
unitWidget.isMouseOver &&
|
||||
canvas.connectionSource.CompatiblePort(unit) == port;
|
||||
|
||||
if (surroundFromPort || surroundFromUnit)
|
||||
{
|
||||
DrawSurround();
|
||||
}
|
||||
|
||||
if (canvas.connectionSource == port)
|
||||
{
|
||||
DrawConnectionSource();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetConnectionsNoAlloc(HashSet<IUnitConnection> connections)
|
||||
{
|
||||
connections.Clear();
|
||||
|
||||
var graph = unit.graph;
|
||||
|
||||
// Unit might have been removed from graph, but still drawn this frame.
|
||||
if (graph == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var controlInput = port as ControlInput;
|
||||
var controlOutput = port as ControlOutput;
|
||||
var valueInput = port as ValueInput;
|
||||
var valueOutput = port as ValueOutput;
|
||||
var input = port as IUnitInputPort;
|
||||
var output = port as IUnitOutputPort;
|
||||
|
||||
if (controlInput != null)
|
||||
{
|
||||
foreach (var connection in graph.controlConnections.WithDestinationNoAlloc(controlInput))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (controlOutput != null)
|
||||
{
|
||||
foreach (var connection in graph.controlConnections.WithSourceNoAlloc(controlOutput))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (valueInput != null)
|
||||
{
|
||||
foreach (var connection in graph.valueConnections.WithDestinationNoAlloc(valueInput))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (valueOutput != null)
|
||||
{
|
||||
foreach (var connection in graph.valueConnections.WithSourceNoAlloc(valueOutput))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (input != null)
|
||||
{
|
||||
foreach (var connection in graph.invalidConnections.WithDestinationNoAlloc(input))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
|
||||
if (output != null)
|
||||
{
|
||||
foreach (var connection in graph.invalidConnections.WithSourceNoAlloc(output))
|
||||
{
|
||||
connections.Add(connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawHandle()
|
||||
{
|
||||
// Trying to be very speed / memory efficient in this method
|
||||
|
||||
if (!e.IsRepaint)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var color = Color.white;
|
||||
|
||||
var highlight = false;
|
||||
|
||||
var invalid = false;
|
||||
|
||||
var willDisconnect = false;
|
||||
|
||||
var connections = HashSetPool<IUnitConnection>.New();
|
||||
|
||||
GetConnectionsNoAlloc(connections);
|
||||
|
||||
var isConnected = connections.Count > 0;
|
||||
|
||||
if (isConnected)
|
||||
{
|
||||
foreach (var connection in connections)
|
||||
{
|
||||
if (connection is InvalidConnection)
|
||||
{
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
var sourceWidget = canvas.Widget<IUnitPortWidget>(connection.source);
|
||||
var destinationWidget = canvas.Widget<IUnitPortWidget>(connection.destination);
|
||||
|
||||
if (sourceWidget.isMouseOver || destinationWidget.isMouseOver)
|
||||
{
|
||||
highlight = true;
|
||||
}
|
||||
|
||||
if (sourceWidget.willDisconnect || destinationWidget.willDisconnect)
|
||||
{
|
||||
willDisconnect = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isMouseOver)
|
||||
{
|
||||
highlight = true;
|
||||
}
|
||||
|
||||
if (willDisconnect)
|
||||
{
|
||||
color = UnitConnectionStyles.disconnectColor;
|
||||
}
|
||||
else if (highlight)
|
||||
{
|
||||
color = UnitConnectionStyles.highlightColor;
|
||||
}
|
||||
else if (invalid)
|
||||
{
|
||||
color = UnitConnectionStyles.invalidColor;
|
||||
}
|
||||
else if (canvas.isCreatingConnection && (canvas.connectionSource == port || canvas.connectionSource.CanValidlyConnectTo(port)))
|
||||
{
|
||||
color = this.color;
|
||||
}
|
||||
else if (isConnected)
|
||||
{
|
||||
Color? resolvedColor = null;
|
||||
|
||||
foreach (var connection in connections)
|
||||
{
|
||||
var connectionColor = canvas.Widget<IUnitConnectionWidget>(connection).color;
|
||||
|
||||
if (resolvedColor == null)
|
||||
{
|
||||
resolvedColor = connectionColor;
|
||||
}
|
||||
else if (resolvedColor != connectionColor)
|
||||
{
|
||||
resolvedColor = this.color;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
color = resolvedColor.Value;
|
||||
}
|
||||
|
||||
if (colorIfActive)
|
||||
{
|
||||
foreach (var connection in connections)
|
||||
{
|
||||
var connectionEditorData = reference.GetElementDebugData<IUnitConnectionDebugData>(connection);
|
||||
|
||||
if (EditorApplication.isPaused)
|
||||
{
|
||||
if (EditorTimeBinding.frame == connectionEditorData.lastInvokeFrame)
|
||||
{
|
||||
color = UnitConnectionStyles.activeColor;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Color.Lerp(UnitConnectionStyles.activeColor, color, (EditorTimeBinding.time - connectionEditorData.lastInvokeTime) / UnitWidget<IUnit>.Styles.invokeFadeDuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var handlePosition = this.handlePosition;
|
||||
|
||||
if (highlight)
|
||||
{
|
||||
var widthExpansion = handlePosition.width * (Styles.highlightScaling - 1);
|
||||
var heightExpansion = handlePosition.height * (Styles.highlightScaling - 1);
|
||||
handlePosition.width += widthExpansion;
|
||||
handlePosition.height += heightExpansion;
|
||||
handlePosition.x -= widthExpansion / 2;
|
||||
handlePosition.y -= heightExpansion / 2;
|
||||
}
|
||||
|
||||
if (highlight ||
|
||||
isConnected ||
|
||||
canvas.connectionSource == port ||
|
||||
canvas.isCreatingConnection && canvas.connectionSource.CanValidlyConnectTo(port))
|
||||
{
|
||||
using (LudiqGUI.color.Override(color.WithAlphaMultiplied(LudiqGUI.color.value.a * 0.85f))) // Full color is a bit hard on the eyes
|
||||
{
|
||||
if (handleTextureConnected != null)
|
||||
{
|
||||
GUI.DrawTexture(handlePosition, handleTextureConnected);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (handleTextureUnconnected != null)
|
||||
{
|
||||
GUI.DrawTexture(handlePosition, handleTextureUnconnected);
|
||||
}
|
||||
}
|
||||
|
||||
HashSetPool<IUnitConnection>.Free(connections);
|
||||
}
|
||||
|
||||
private void DrawIcon()
|
||||
{
|
||||
GUI.DrawTexture(iconPosition, description.icon?[Styles.iconSize]);
|
||||
}
|
||||
|
||||
private void DrawLabel()
|
||||
{
|
||||
GUI.Label(labelPosition, description.label, Styles.label);
|
||||
}
|
||||
|
||||
private void DrawInspector()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
using (LudiqGUIUtility.currentInspectorWidth.Override(inspectorPosition.width))
|
||||
using (Inspector.adaptiveWidth.Override(true))
|
||||
{
|
||||
inspector.Draw(inspectorPosition, GUIContent.none);
|
||||
}
|
||||
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
unitWidget.Reposition();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawConnectionSource()
|
||||
{
|
||||
var start = handlePosition.GetEdgeCenter(edge);
|
||||
|
||||
if (window.IsFocused())
|
||||
{
|
||||
canvas.connectionEnd = mousePosition;
|
||||
}
|
||||
|
||||
GraphGUI.DrawConnection
|
||||
(
|
||||
color,
|
||||
start,
|
||||
canvas.connectionEnd,
|
||||
edge,
|
||||
null,
|
||||
handleTextureConnected,
|
||||
Styles.handleSize,
|
||||
UnitConnectionStyles.relativeBend,
|
||||
UnitConnectionStyles.minBend
|
||||
);
|
||||
}
|
||||
|
||||
private void DrawSurround()
|
||||
{
|
||||
if (e.controlType == EventType.Repaint)
|
||||
{
|
||||
Styles.surround.Draw(surroundPosition, false, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public static class Styles
|
||||
{
|
||||
private static byte[] t;
|
||||
private static Texture2D tx;
|
||||
static Styles()
|
||||
{
|
||||
label = new GUIStyle(EditorStyles.label);
|
||||
label.wordWrap = false;
|
||||
label.imagePosition = ImagePosition.TextOnly;
|
||||
label.padding = new RectOffset(0, 0, 0, 0);
|
||||
|
||||
TextureResolution[] textureResolution = { 2 };
|
||||
|
||||
surround = new GUIStyle
|
||||
{
|
||||
normal =
|
||||
{
|
||||
background = BoltCore.Resources.LoadTexture($"Nodes/Surround.png", textureResolution, CreateTextureOptions.Scalable).Single()
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public const float highlightScaling = 1f;
|
||||
|
||||
public static readonly Vector2 handleSize = new Vector2(9, 12);
|
||||
|
||||
public static readonly float spaceBetweenEdgeAndHandle = 5;
|
||||
|
||||
public static readonly float spaceAfterEdge = 5;
|
||||
|
||||
public static readonly float spaceBetweenIconAndLabel = 5;
|
||||
|
||||
public static readonly float spaceBetweenIconAndInspector = 5;
|
||||
|
||||
public static readonly float spaceBetweenLabelAndInspector = 5;
|
||||
|
||||
public static readonly float labellessInspectorMinWidth = 75;
|
||||
|
||||
public static readonly float maxInspectorWidth = 200;
|
||||
|
||||
public static readonly float maxLabelWidth = 150;
|
||||
|
||||
public static readonly int iconSize = IconSize.Small;
|
||||
|
||||
public static readonly GUIStyle label;
|
||||
|
||||
public static readonly GUIStyle surround;
|
||||
|
||||
public static readonly RectOffset easierGrabOffset = new RectOffset(5, 5, 4, 4);
|
||||
|
||||
public static readonly RectOffset surroundPadding = new RectOffset(3, 3, 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23c864f32645c4df8a6fedf99addeb77
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(ValueInputDefinition))]
|
||||
public sealed class ValueInputDefinitionInspector : ValuePortDefinitionInspector
|
||||
{
|
||||
public ValueInputDefinitionInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
private Metadata hasDefaultValueMetadata => metadata[nameof(ValueInputDefinition.hasDefaultValue)];
|
||||
private Metadata defaultValueMetadata => metadata[nameof(ValueInputDefinition.defaultValue)];
|
||||
private Metadata typedDefaultValueMetadata => defaultValueMetadata.Cast((Type)typeMetadata.value);
|
||||
|
||||
private float GetHasDefaultValueHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, hasDefaultValueMetadata, width);
|
||||
}
|
||||
|
||||
private float GetDefaultValueHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, typedDefaultValueMetadata, width);
|
||||
}
|
||||
|
||||
private void OnHasDefaultValueGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(hasDefaultValueMetadata, position);
|
||||
}
|
||||
|
||||
private void OnDefaultValueGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(typedDefaultValueMetadata, position);
|
||||
}
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
var height = base.GetHeight(width, label);
|
||||
|
||||
if (typeMetadata.value != null && ValueInput.SupportsDefaultValue((Type)typeMetadata.value))
|
||||
{
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetHasDefaultValueHeight(width);
|
||||
|
||||
if ((bool)hasDefaultValueMetadata.value)
|
||||
{
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetDefaultValueHeight(width);
|
||||
}
|
||||
}
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected override void OnFieldsGUI(Rect position)
|
||||
{
|
||||
base.OnFieldsGUI(position);
|
||||
|
||||
if (typeMetadata.value != null && ValueInput.SupportsDefaultValue((Type)typeMetadata.value))
|
||||
{
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnHasDefaultValueGUI(position.VerticalSection(ref y, GetHasDefaultValueHeight(position.width)));
|
||||
|
||||
if ((bool)hasDefaultValueMetadata.value)
|
||||
{
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnDefaultValueGUI(position.VerticalSection(ref y, GetDefaultValueHeight(position.width)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e60e3ab5ec4384a26a35ad03f991ab55
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,35 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(ValueInput))]
|
||||
public class ValueInputWidget : UnitInputPortWidget<ValueInput>
|
||||
{
|
||||
public ValueInputWidget(FlowCanvas canvas, ValueInput port) : base(canvas, port)
|
||||
{
|
||||
color = ValueConnectionWidget.DetermineColor(port.type);
|
||||
}
|
||||
|
||||
protected override bool showInspector => port.hasDefaultValue && !port.hasValidConnection;
|
||||
|
||||
protected override bool colorIfActive => !BoltFlow.Configuration.animateControlConnections || !BoltFlow.Configuration.animateValueConnections;
|
||||
|
||||
public override Color color { get; }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.valuePortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.valuePortUnconnected?[12];
|
||||
|
||||
public override Metadata FetchInspectorMetadata()
|
||||
{
|
||||
if (port.hasDefaultValue)
|
||||
{
|
||||
return metadata["_defaultValue"].Cast(port.type);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6de90288101284c5891d285c63d67c40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Widget(typeof(ValueOutput))]
|
||||
public class ValueOutputWidget : UnitOutputPortWidget<ValueOutput>
|
||||
{
|
||||
public ValueOutputWidget(FlowCanvas canvas, ValueOutput port) : base(canvas, port)
|
||||
{
|
||||
color = ValueConnectionWidget.DetermineColor(port.type);
|
||||
}
|
||||
|
||||
protected override bool colorIfActive => !BoltFlow.Configuration.animateControlConnections || !BoltFlow.Configuration.animateValueConnections;
|
||||
|
||||
public override Color color { get; }
|
||||
|
||||
protected override Texture handleTextureConnected => BoltFlow.Icons.valuePortConnected?[12];
|
||||
|
||||
protected override Texture handleTextureUnconnected => BoltFlow.Icons.valuePortUnconnected?[12];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6392d6c3118b84772bac990889aaa190
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,43 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Unity.VisualScripting
|
||||
{
|
||||
[Inspector(typeof(ValuePortDefinition))]
|
||||
public class ValuePortDefinitionInspector : UnitPortDefinitionInspector
|
||||
{
|
||||
public ValuePortDefinitionInspector(Metadata metadata) : base(metadata) { }
|
||||
|
||||
protected Metadata typeMetadata => metadata[nameof(ValueInputDefinition.type)];
|
||||
|
||||
protected float GetTypeHeight(float width)
|
||||
{
|
||||
return LudiqGUI.GetInspectorHeight(this, typeMetadata, width);
|
||||
}
|
||||
|
||||
private void OnTypeGUI(Rect position)
|
||||
{
|
||||
LudiqGUI.Inspector(typeMetadata, position);
|
||||
}
|
||||
|
||||
protected override float GetHeight(float width, GUIContent label)
|
||||
{
|
||||
var height = base.GetHeight(width, label);
|
||||
|
||||
height += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
height += GetTypeHeight(width);
|
||||
|
||||
return height;
|
||||
}
|
||||
|
||||
protected override void OnFieldsGUI(Rect position)
|
||||
{
|
||||
base.OnFieldsGUI(position);
|
||||
|
||||
y += EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
OnTypeGUI(position.VerticalSection(ref y, GetTypeHeight(position.width)));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8547e7db1fc234a80b57c9d30108abac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue