How do you search for a field with a specific value?
How do you search for a field with a specific value?
I see the search/replace section in the database but I don't know how to use it for this. I have this custom field named "energyCost". It's on every node. I want to find every node where it has a value > 0. How would I find every node like that?
Re: How do you search for a field with a specific value?
There's nothing built into the editor that handles conditional searching like that. But you could write a short editor script like this:
Then open a scene with a Dialogue Manager, and select menu item Tools > Find energyCost.
Code: Select all
using UnityEngine;
using UnityEditor;
using PixelCrushers.DialogueSystem;
public class FindNode : MonoBehaviour
{
[MenuItem("Tools/Find energyCost")]
public static void FindEnergyCost()
{
var database = EditorTools.FindInitialDatabase();
if (database == null)
{
Debug.LogWarning("First open a scene with a Dialogue Manager that points to the database.");
}
else
{
foreach (var conversation in database.conversations)
{
foreach (var entry in conversation.dialogueEntries)
{
var energyCost = Field.LookupInt(entry.fields, "energyCost");
if (energyCost > 0)
{
Debug.Log("Conversation " + conversation.Title +
" Entry " + entry.id + " (" + entry.subtitleText + "): " +
" energyCost = " + energyCost);
}
}
}
}
}
}
Re: How do you search for a field with a specific value?
OK, thanks for the help.