Indicate Custom Class Pair in Unity

Indicate Custom Class Pair in Unity

In Unity, you can use a KeyValuePair<TKey, TValue> to represent a pair of values, where TKey is the type of the key and TValue is the type of the value. Here is an example of how you can use a KeyValuePair to represent a pair of a custom class and an enum:

public class MyClass
{
    public enum MyEnum
    {
        Value1,
        Value2,
        Value3
    }

    public class MyCustomClass
    {
        // Class members and methods go here.
    }

    public KeyValuePair<MyCustomClass, MyEnum> myPair;

    void Start()
    {
        MyCustomClass customClass = new MyCustomClass();
        myPair = new KeyValuePair<MyCustomClass, MyEnum>(customClass, MyEnum.Value2);
    }
}

Alternatively, you can define your own custom class or struct to represent the pair. For example:

public class MyClass
{
    public enum MyEnum
    {
        Value1,
        Value2,
        Value3
    }

    public class MyCustomClass
    {
        // Class members and methods go here.
    }

    public struct MyPair
    {
        public MyCustomClass Key;
        public MyEnum Value;
    }

    public MyPair myPair;

    void Start()
    {
        MyCustomClass customClass = new MyCustomClass();
        myPair = new MyPair { Key = customClass, Value = MyEnum.Value2 };
    }
}

Either way, you can access the key and value of the pair using the Key and Value properties, respectively. For example:

MyCustomClass key = myPair.Key;
MyEnum value = myPair.Value;