So i have this class:
class ActorKnowledge {
var state : boolean;
function ActorKnowledge (state : boolean) {
this.state = state;
}
function ActorKnowledge (state : boolean, selectedList : List.<ActorKnowledge>) {
this.state = state;
selectedList.Add(this);
}
}
And its used in several Lists. I need to have them display in the editor from reading the Lists that contain them but I can’t convert the class name to string. This is what i have so far:
for (var playerKnowledge : ActorKnowledge in scriptPlayer.playerKnowledgeList){
var knowledgeName = playerKnowledge.ToString();
if (!playerKnowledge.state){
if ( GUI.Button (Rect (leftPadding, row01PositionY, position.width - buttonPaddingRight, buttonHeigth), (knowledgeName)) ){
if(EditorApplication.isPlaying){
knowledgeManager.GetKnowledge (playerKnowledge);
}
}
row01PositionY += buttonPadding;
}
else {
EditorGUI.LabelField(Rect(entryLeftPadding,row01PositionY,position.width,buttonHeigth), knowledgeName);
row01PositionY += buttonPadding;
}
}
What I really want to figure out is the variable knowledgeName! In the current example where I do a ToString() I just end up getting the button/label called ActorKnowledge.
Any help would be amazing!
UPDATE:
SO I think I phrased this incorrectly.
What I meant is, I want the name of the variable that was created using this class, so for example I have these:
knowsAboutPocketWatch = new ActorKnowledge(false, playerKnowledgeList);
knowsAboutJournal = new ActorKnowledge(false, playerKnowledgeList);
canProveSarahInnocence = new ActorKnowledge(false, playerKnowledgeList);
and I would like them to show in the editor with their names rather than as “ActorKnowledge”