Here in the Main class that I defined the fields in two ways. The first case is serialized class inside a main that looks neat. This is especially good when a bunch of field are used in other classes that aren't polymorphic for some reason..
public class Main
{
[Serializable]
public class Tree
{
public float height;
public int leavesCount;
public Vector3 rootPosition;
}
private Tree tree = new Tree();
}
But I think we have another easy way to define them inside the main class like this we all ever do:
public class Main
{
public float treeHeight;
public int leavesCount;
public Vector3 rootPosition;
}
the main question is, do code processing less pressure on the cpu in second way or not? Is this true or do I misunderstood the concept correctly? I hope you can help me.
public void GrowTree()
{
tree.height += 1; // inside class definition..
treeHeight += 1; // Does it have more performance?
}