- Home /
call a coroutine in properity get/set?
I need to call a coroutine MoveCameras() when I enable my camera from my CameraManger script.
So I stumbled upon get/set of properities:
public bool enableCamera = true;
public bool EnableCamera
{
get
{
return this.enableCamera;
}
set
{
this.enableCamera = value;
//Call coroutine on camera disable enable
StartCoroutine(CameraManager.instance.MoveCameras());
}
}
My CameraManger script is "static", I'm taking it with me even when changing scenes.
public class CameraManager : MonoBehaviour {
public static CameraManager instance;
public Camera CameraPlayerOne;
public Camera CameraPlayerTwo;
public IEnumerator MoveCameras()
{/*Move Cameras stuff*/}
}
I get an error saying that I cannot acces non-static member of outer type 'UnityEngine.MonoBehaviour' via nested type 'PlayerCamera.CameraOptions'.
Any hints how I could tackle this problem?
Comment
Best Answer
Answer by jenci1990 · Dec 04, 2014 at 12:30 AM
StartCoroutine(CameraManager.instance.MoveCameras());
Replace to it:
CameraManager.instance.StartCoroutine(CameraManager.instance.MoveCameras());
Your answer
Follow this Question
Related Questions
Get/set vector 3 causing problems 0 Answers
Instead of "new" for accessing properties? 1 Answer
Loading a sprite from resource folder 2 Answers
Getter/Setter throwing missing reference on scene change 0 Answers
What are these things doing in C#? 3 Answers