I am learning Unity and C# at the same time and so far so good. However, I have a doubt related accessing a script from another. The issue I have is, the script I want to access is going to be attached to my player object. So, some variables will be public and other private. Those public variables can be access from the editor and from external scripts and that is ok. But, I want to access also the private variables from an external script.
For instance, this is the script attached to the player object and the one to be accessed from another script
public class AnimationHandler : MonoBehaviour
{
private int currentFrame;
public int finalFrame;
enum AnimationStates {Stand, Walk, Melee}
}
But I cannot do the same with currentFrame because it is private and I do not want to make it public because I do not want to change it from the editor
I have the same problem with enum. How I can access enum from the external script?
Well, I solved it but I do not know if it is the right way to do it. I just put enum declaration out of the class and now I can access it directly from any script.
Is this approach correct?