I am creating an editor script for a certain type of component script, I'd like to access the specific component script referenced by that instance of the editor script. For example, target returns the game object the editor is attached to but I would like to get the actual script component inside it. The game object may have multiple components of this type and so needs to get the specific one.
[CustomEditor(typeof(CameraCutscene))] //Attaches to the CameraCutscene script
public class CutsceneEditor : Editor
{
private CameraCutscene cameraCutscene;
private void OnEnable()
{
Debug.Log(target.name);
cameraCutscene = (CameraCutscene)target; //Attempt to cast to the script type but target returns the actual game object
}
}