メインコンテンツまでスキップ

Creating Custom Class

Create Custom Class derived from Kassets Core classes are pretty straight forward. Simply inherit the necessary class and optionally add your class to the context menu. Even if not added to context menu, you can create your custom instance from the inspector.

namespace Custom.Variable
{
[CreateAssetMenu(fileName = "HealthVariable", menuName = MenuHelper.DefaultVariableMenu + "HealthVariable", order = 100)]
public class HealthVariable : VariableCore<Health>
{
}

[Serializable]
public struct Health
{
public float current;
public float max;
}
}

Creating custom class is encouraged as you can setup the namespace in accordance to your projects. This is beneficial if you try to track references, so that you don't ended up in a general Kassets' namespace.

Serializable It is important to note that your custom struct or class needs to have the Serializable attribute. Otherwise you will see null reference exceptions as the editor inspector cannot find the value of the class.