Hello there
I’ve been trying to get used to enums; my plan was to have a GameManager with several states in a turn per turn game (PlayerMoving, SomethingHappening…). For that I wanted to use an enum, whose state could change for instane when my player moves
However when I try to access the GameManager state enum from my player class to change it, it appears that it does not exist…
I’ve found info (Learn, uunity forums, stack overflow) about putting the enum on a different class (which a did), changing my class names, making sure the enum is public, and so on, but still no way to access it…
I tried on some new scripts, looking like that:
My separate enum class :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestEnums : MonoBehaviour {
public enum Letter
{
A,
B,
C,
D,
E
}
}
My “game manager” :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestGameManager : MonoBehaviour {
// Use this for initialization
public Letter _letter; //tried both in public & private
//'The type or namespace name 'Letter' could not be found (are you missing a using directive or an assembly reference?)
}
As stated in comment I can’t access the Letter enum, no matter what I try… so my plan which was to do this, from a player class, can’t possibly work
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FalseMatchActor : MonoBehaviour {
void Start(){
TestGameManager tgm = GameObject.Find("something").GetComponent<TestGameManager>();
}
void PlayerDoesSomethingLikeMove(){
//move action
tgm._letter = Letter.A;
}
}
Could anyone help me change the enum state of an A class, by calling a function on a B class ?
And just to be clear, I did search quite a lot, but every example or explanation I found resulted in the same thing : OP saying “Thanks, works”, but the result ended up giving me the very same error that I get here when I repeat the process (even through raw copy/paste)… So i’m probably doing a conceptual mistake but I can’t see where
Thanks in advance
Aes