-
Notifications
You must be signed in to change notification settings - Fork 417
Open
Description
I'm trying to create a system where I can ensure that certain graph types always expose the correct properties.
My base node with helper:
using GraphProcessor;
using System.Linq;
using UnityEngine;
namespace EffortStar {
public class ESBaseGraph : BaseGraph {
protected void EnsureParameter<T>(string name, object value = default) where T : ExposedParameter {
var existing = exposedParameters.Find(p => p.name == name);
if (existing != null) {
if (existing.GetType() != typeof(T)) {
RemoveExposedParameter(name);
}
}
if (existing == null) {
AddExposedParameter(name, typeof(T), value);
}
}
}
}Example graph:
using GraphProcessor;
using System.Linq;
using UnityEngine;
using System;
namespace EffortStar {
using Events;
[Serializable]
public class ActorEventParameter : ExposedParameter {
[SerializeField] ActorEvent _value;
public override object value {
get => _value;
set => _value = (ActorEvent) value;
}
}
[Serializable]
public class EventContextExposedParameter : ExposedParameter {
[SerializeField] EventContext _value;
public override object value {
get => _value;
set => _value = (EventContext) value;
}
}
[CreateAssetMenu(menuName = "EffortStar/Graph/ActorEventGraph")]
public class ActorEventGraph : ESBaseGraph {
#if UNITY_EDITOR
protected override void OnEnable() {
EnsureParameter<ActorEventParameter>(nameof(ActorEvent));
EnsureParameter<EventContextExposedParameter>(nameof(EventContext));
}
#endif
}
}New graph created with correct exposed parameters:

Adding some nodes:
Close and reopen graph editor:

Possibly related to #155
Metadata
Metadata
Assignees
Labels
No labels
