how to create custom class ?

hello, i’m just wondering how to create a custom class to use it on Bolt FlowGraph.

i want to create a class to make it a list from it.

public class item
{
    string itemDescription;
    int itemPrice;
    int itemWeight;
}

on c# i did it this way and then i use that class to make a list

how can i make it on Bolt ?

you don’t need to do anything special if you use it by reflection.

  • You will need to change the class name to be able to see it in the fuzzy finder. Rename your class to something like myitem as item collide with another class.
  • Make your variables public if you want to interact with them.
public class Myitem
{
    public string itemDescription;
    public int itemPrice;
    public int itemWeight;
}

You should now be able to use your class.

1 Like

thanks for the answer @ericb_unity , i did that, but when i try to declare a list variable from my custom class i got this

6929590--813343--upload_2021-3-12_19-17-50.png

Sorry, I forgot to use it as a variable, you will need to add
[Inspectable] attribute on top of your class and also on top of variables.
6930115--813427--upload_2021-3-12_21-4-51.png

Bolt 1.43
```csharp
**using Ludiq;
using UnityEngine;

[Inspectable]
public class Myitem
{
[Inspectable]
public string itemDescription;
[Inspectable]
public int itemPrice;
[Inspectable]
public int itemWeight;
[Inspectable]
public GameObject NewAnswerList;
}**
** **UnityVS** **csharp
**using Unity.VisualScripting;
using UnityEngine;

[Inspectable]
public class Myitem
{
[Inspectable]
public string itemDescription;
[Inspectable]
public int itemPrice;
[Inspectable]
public int itemWeight;
[Inspectable]
public GameObject NewAnswerList;
}**
```

2 Likes

hi @ericb_unity thanks for all the help, this is how i declared my class with the [inspectable] on top of my class and variables like this:

6931267--813754--upload_2021-3-13_12-35-42.png

then i had generated the type options

6931267--813748--upload_2021-3-13_12-35-2.png

but i’m getting this
6931267--813757--upload_2021-3-13_12-36-53.png

i’m doing something wrong ? i don’t see my variables exposed in the inspector.

thanks in advance for all the help.

6931267--813742--upload_2021-3-13_12-29-4.png

got it working, removing the MonoBehavior inheritance

thank you for all the help @ericb_unity

2 Likes

Quick questions. The variable name is always cut off. is there any way to change this so i can see the entire name?