An "IS / AS" unit for comparing B2 classes

CSmith 2 years ago updated by Lazlo Bonin (Lead Developer) 1 year ago 3

And like a nullcheck unit, allows for Bolt to get a list of random game objects and only invoke events / call functions etc if they exist on the class so there are no errors when they don't.

Lazlo's feature notes:

- Any object as input
- Any type (including bolt types) as a dropdown setting in the header
- Boolean output of whether it is of that type
- Typed output of the casted type, if it is (otherwise the value of that port is undefined/null)

Added req:

That if it's a bolt type, it automatically does the GetComponent<ClassComponent> internally then checks for bolt class def type.  So a Game Object can be piped straight in without having to get the class component first.

So basically a "It Has" for just Bolt Classes.

OR maybe make a more specific second unit that is simply to see if Bolt classes are attached to game objects?

Bolt Version:
Unity Version:
Scripting Backend:
.NET Version (API Compatibility Level):
Bolt 2

I would love to have this for class variables and Class Asset types especially. 

EDIT: I want to get all children with ItemSlot class on them but there's no way to check for that. I can retrieve a Class Component but it'll grab any children with Class Component even if it's the wrong class. Furthermore, get components in children also looks at itself so if the parent object has a class component it'll grab it as well.

Another use case would be using empty Class Assets as enum types so you're not constrained with traditional enum downsides such as not being able to change enum order. With C# scriptable objects, you can check for equality. Right now it's not possible with Class Assets.

Turns out you can check for class asset equality. I'm used to type specific units that Bolt 1 generates for C# scriptable objects but NeedsLoomis enlightened me. 

EDIT: Currently Class Assets don't like other Class Assets used as pseudo enums inside them. They throw variable binding errors.

[At 23.39]


(Sorry for the bump/necro, I'm doing some roadmap grooming following the Unity acquisition!)

This is now supported in Bolt 2 Alpha with the new Is unit.