Expression Preview plus Challenge

I have here a visualizer to show what expression you have put together in the “click this, click that, click everything” conditional expression building system we have now. It uses OnValidate from the DialogNode script. It stores the expression in an editable “Expression Preview” field in the inspector, but if you edit it, it will revert immediately to the actual expression you built. With more work, you could make a “read only field” attribute (there are examples on the web) but I didn’t bother.

Here is the revised “Condition” script: (which you might need to modify according to your own code).

Add these lines to DialogNode.cs after the block of SerializeField lines:

Now, I might do this myself later. But, if you know how, you can go the other way: type in an expression and it gets “compiled” in an editor script to the (cumbersome) Condition hierarchy.

Basically, it’s easy (though it takes some time to put together and test the code) if you’ve done it before, hard if you haven’t. My intro to CS course in college covered it, but many schools it is covered in “Compiler Writing” or some other class. Essentially, you need to implement the Interpreter pattern.

Privacy & Terms