You are confusing the terms "field" and "property". Properties can implement additional behavior in the getter and setter.
First of all: Unity does not serialize properties!
This limits the purposes of properties in Unity to the runtime.
So most of the time will want to go for a pattern like
[SerializeField] private int a;
public int A => a;
This e.g. serves the purpose that you can assign a value via the editor, edit it by the class itself but allow others only readonly access => Encapsulation.
And of course for completeness it can perform additional sanity checks like e.g.
private const int min = -3;
private const int max = 17;
private bool allowSet;
[SerializeField] private int a;
public int A
{
get => a;
set
{
if(allowSet) a = Mathf.Clamp(a, min, max);
}
}
An auto-property (in my eyes) is barely needed except you want to directly limit the access like
public int b { get; private set;}
This allows only this class to write but everyone else to read this value
So when something is useful is mostly subjective and depends on the situation.
Now looking at your code there is absolutely no relationship between Speed
- speed
and FireRate
-fireRate
! They are completely independent fields and properties.
The confusion here is probably due to the display names that the Inspector creates. It automatically makes all field names capitalized so
[SerializeField] private int _example;
will be displayed as Example
.
You most probably would simply go for
[SerializeField] protected float Speed;
[SerializeField] protected float FireRate;