Variable search

slipyfrog

Member
Hello Justin,

Just a quick feature request:

Would it be possible to add the following support to 'find' feature that search for variables usage within Tasks to include:

1. support for nested (at least one layer)
  • I group SharedVariables into custom classes. These custom classes are then members of my custom Tasks. the Find variable features only search tasks and no custom classes within them. It would be a simple externs on my end but editor code is bundled as a binary.
  • In the Example provided here, anything that is bound to m_Variable1 or m_Variable2 will not be found by the Find Variable functionality of the BehaviorDesignerWindow:
class A
{
public SharedVariable m_Variable1;
public SharedVariable m_Variable2;
}

class MyTaskThatUsesA
{
public A m_Member;
}

2. dynamic variables?
  • In large trees, this can increase adoption of dynamic variables as it increase the ability to maintain BT leveraging the dynamic variables.

if it matters, #1 is more important to my workflow. Thanks for considering the feature request and for the great assets.

W
 
Also, I was able to implement the nested search by adding something like the following to the Find method in the GraphDesigner class. in my implementation, I repeated the find functionality in the GraphDesigner class and added the following to the find method/ so every time I move the mouse on the BT editor, the node coloring from my custom search reverts (the BT Window is invoking its internal Find implementation and resetting the node color). I would be great to add something similar into the next patch (it's not super performant but with some adjustments it could easy be).
Also collections, etc are not supported in my naive impelmeation but it could easy be added. etc.

if (findSharedVariable != null && typeof (SharedVariable).IsAssignableFrom(fieldType))
{
....
}
else if (BehaviorDesignerUtility.HasAttribute(serializableFields[index1], typeof (InspectTaskAttribute)))
{
...
}
else
{
//-- regular reflection
Type customType = fieldType;
FieldInfo[] customFields = customType.GetFields ( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance );
foreach ( FieldInfo customField in customFields )
{
if (findSharedVariable != null && typeof (SharedVariable).IsAssignableFrom(customField.FieldType))
{
object obj = serializableFields[ index1 ].GetValue ( (object)nodeDesigner.Task );

if ( obj != null && customField.GetValue ( obj ) is SharedVariable sharedVariable )
{
if ( sharedVariable.Name == findSharedVariable.Name && sharedVariable.IsGlobal == findSharedVariable.IsGlobal)
{
found = true;
break;
}
}
}
}
}
 
1. support for nested (at least one layer)
  • I group SharedVariables into custom classes. These custom classes are then members of my custom Tasks. the Find variable features only search tasks and no custom classes within them. It would be a simple externs on my end but editor code is bundled as a binary.
  • In the Example provided here, anything that is bound to m_Variable1 or m_Variable2 will not be found by the Find Variable functionality of the BehaviorDesignerWindow:
Yes, this should be pretty easy to add. I am not adding any new major features to BD1 but this should be minor enough. I'll also make sure it is in BD2 when I add the find feature.

2. dynamic variables?
  • In large trees, this can increase adoption of dynamic variables as it increase the ability to maintain BT leveraging the dynamic variables.
Are you wanting to just search at runtime for dynamic variables, or at design time as well?
 
Thanks Justin! I really appreciate this. I'm pretty far along in the dev of my game so I probably won't switch over to BD2 unless migration is relatively easy. Having said that I will be definitely be purchasing BD2 on Day 1 just to support Opsive and just to check it out.

Also, related but maybe a stretch, it would be nice to support the visualization of bad variable references to these nested custom classes. It's not high priority request by a means as it is easy enough to writhe a scanner to look for these but I thought I would mention it for BD2, etc..

Regarding dynamic variables, searching at editor time is what I'm looking for. it makes it easier to manage big trees and makes them more maintainable.
 
Last edited:
I just wanted to give you a heads up that I've implemented both of these and they'll be in the next update. I should be able to release this update today.
 
Back
Top