I want to pass the gameobject, and the current component into the error logger and have it print out some debug.log.
Here’s what I currently have for the error logger:
public class ErrorLog : MonoBehaviour {
public ErrorLog(){
}
public ErrorLog(GameObject relevantObject, objectrelevantComponent, string methodName, string additionalInfo){
Debug.Log ("<----------- ERROR MESSAGE ----------->");
string gOName = relevantObject.name.ToString();
string cOName = relevantComponent.GetType().Name;
string timeStamp = Time.time.ToString();
Debug.Log ("At " + timeStamp);
Debug.Log ("GameObject " + gOName + " has encountered an error");
Debug.Log ("inside the " + cOName + " component while using the " + methodName + " function");
Debug.Log (additionalInfo);
Debug.Log ("<----------- END MESSAGE ----------->");
}
}
and heres how I’m trying to call it:
ErrorLog(gameObject, WhateverClass, "GetKeyCode", "NONE");
The problem is that it returns this in the editor:
Expression denotes a `type', where a `variable', `value' or `method group' was expected
I’ve tried using typeOf on the class name. but it didnt seem to change anything. Does anybody know how I can make this work?