❔ Is it possible to define a struct inline ?

NNukadelic2/13/2023
instead of doing this
    [System.Serializable]
    public struct Properties
    {
        public float clipDistance;
        public float clipHeight;
        public float scale;
        public float3 rotation;
        public float rotationSpeed;
        public float floatDistance;
        public float floatSpeed;
    }

    public Properties properties = new Properties
    {
        clipDistance = 100,
        clipHeight = 10,
        scale = 0.4f,
        rotation = new float3(90, 0, 0),
        rotationSpeed = 1,
        floatDistance = 0.2f,
        floatSpeed = 0.2f,
    };

i want something like this :
public properties = new [System.Serializable] public struct Properties
{
        public float clipDistance = 100,
        public float clipHeight = 10,
        public float scale = 0.4f,
        public float3 rotation = new float3(90, 0, 0),
        public float rotationSpeed = 1,
        public float floatDistance = 0.2f,
        public float floatSpeed = 0.2f,
};
AAngius2/13/2023
No
AAngius2/13/2023
You can try using a record struct to shorten the declaration of it, though, get a constructor for free and all that
AAkseli2/13/2023
^ record struct or use something like ValueTuple

public (float clipDistance, float clipHeight, ...and friends) properties = (100, 10, ...);
AAccord2/14/2023
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.