1
0
mirror of https://github.com/Siccity/xNode.git synced 2025-12-20 01:06:01 +08:00

Removed GetValue

This commit is contained in:
Thor Brigsted 2018-10-08 00:53:52 +02:00
parent 147dc639e8
commit 6e000c20b2
3 changed files with 9 additions and 21 deletions

View File

@ -454,7 +454,8 @@ namespace XNodeEditor {
GUIContent content = new GUIContent();
content.text = type.PrettyName();
if (hoveredPort.IsOutput) {
object obj = hoveredPort.node.GetValue(hoveredPort);
if (hoveredPort.targetDelegate == null) hoveredPort.Initialize(hoveredPort.node.GetDelegate);
object obj = hoveredPort.targetDelegate.DynamicInvoke();
content.text += " = " + (obj != null ? obj.ToString() : "null");
}
Vector2 size = NodeEditorResources.styles.tooltip.CalcSize(content);

View File

@ -182,25 +182,6 @@ namespace XNode {
else return fallback;
}
/// <summary> Returns a value based on requested port output. Should be overridden in all derived nodes with outputs. </summary>
/// <param name="port">The requested port.</param>
public object GetValue(NodePort port) {
if (port.targetDelegate == null) port.Initialize(GetDelegate);
return port.targetDelegate.DynamicInvoke();
}
/// <summary> Returns a value based on requested port output. Should be overridden in all derived nodes with outputs. </summary>
/// <param name="port">The requested port.</param>
public T GetValue<T>(NodePort port) {
if (port.targetDelegate == null) port.Initialize(GetDelegate);
Func<T> func = port.targetDelegate as Func<T>;
if (func != null)
return func();
return default(T); //default
}
public abstract Delegate GetDelegate(string fieldName);
#endregion

View File

@ -110,7 +110,13 @@ namespace XNode {
/// <returns> <see cref="Node.GetValue(NodePort)"/> </returns>
public T GetOutputValue<T>() {
if (direction == IO.Input) return default(T);
return node.GetValue<T>(this);
if (targetDelegate == null) Initialize(node.GetDelegate);
Func<T> func = targetDelegate as Func<T>;
if (func != null)
return func();
return default(T); //default
}
/// <summary> Return the output value of the first connected port. Returns null if none found or invalid.</summary>