private void OpenState() { MyFader.GetComponent <Renderer>().enabled = true; // Gets collider 2D if (MyFader.GetComponent <Collider2D>()) { MyFader.GetComponent <Collider2D>().enabled = true; } // Or try to get collider 3D else if (MyFader.GetComponent <Collider>()) { MyFader.GetComponent <Collider>().enabled = true; } IsOpen = true; }
private void CloseState() { FadeSpriteRenderer.color = Color.clear; MyFader.GetComponent <Renderer>().enabled = false; // Gets collider 2D if (MyFader.GetComponent <Collider2D>()) { MyFader.GetComponent <Collider2D>().enabled = false; } // Or try to get collider 3D else if (MyFader.GetComponent <Collider>()) { MyFader.GetComponent <Collider>().enabled = false; } IsOpen = false; }