Created
November 19, 2020 15:06
-
-
Save omundy/cd5865ef5a6fa5161807768f7dc4f6a3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
public class CameraSETUP: MonoBehaviour { | |
private Camera m_Camera; | |
private CanvasGroup myCanvas; | |
private GameObject myTexty; | |
public GameObject CamParent; | |
private GameObject myDot; | |
// Start is called before the first frame update | |
void Awake() { | |
DontDestroyOnLoad(this); | |
m_Camera = Camera.main; | |
Instantiate(CamParent); | |
CamParent.transform.SetPositionAndRotation(new Vector3( - 4.5f, 1.6f, 0), Quaternion.Euler(new Vector3(0, 180.0f, 0))); | |
int currentScene = SceneManager.GetActiveScene().buildIndex; | |
// myTexty = GameObject.FindWithTag("cam_stuff"); | |
// myDot = GameObject.FindWithTag("dot"); | |
myCanvas = transform.GetChild(0).GetComponent < CanvasGroup > (); | |
StartCoroutine(faderCoroutine.FadeCanvas(myCanvas, 1f, 0f, 2f)); | |
CamParent.GetComponent < playVideo > ().enabled = true; | |
CamParent.GetComponent < MouseRayv2 > ().enabled = false; | |
} | |
// Update is called once per frame | |
void Update() { | |
SceneManager.sceneLoaded += OnSceneLoaded; | |
} | |
void OnSceneLoaded(Scene scene, LoadSceneMode mode) { | |
myDot = GameObject.FindWithTag("dot"); | |
myTexty = GameObject.FindWithTag("cam_stuff"); | |
int currentScene = SceneManager.GetActiveScene().buildIndex; | |
switch (currentScene) { | |
case 0: | |
Instantiate(CamParent); | |
CamParent.GetComponent < playVideo > ().enabled = true; | |
CamParent.GetComponent < MouseRayv2 > ().enabled = false; | |
myTexty.SetActive(false); | |
myDot.SetActive(false); | |
CamParent.transform.SetPositionAndRotation(new Vector3( - 4.5f, 1.6f, 0), Quaternion.Euler(new Vector3(0, 180.0f, 0))); | |
break; | |
case 1: | |
Debug.Log("caseDone"); | |
Instantiate(CamParent); | |
CamParent.transform.position = new Vector3( - 0.49f, 1.6f, -2.714f); | |
//CamParent.transform.SetPositionAndRotation(new Vector3(-0.45f, 1.8f, -2.75f), Quaternion.Euler(new Vector3(0, 90.0f, 0))); | |
myCanvas = transform.GetChild(0).GetComponent < CanvasGroup > (); | |
StartCoroutine(faderCoroutine.FadeCanvas(myCanvas, 1f, 0f, 2f)); | |
Debug.Log(CamParent.transform.position); | |
// CamParent.transform.rotation = Quaternion.Euler(0, 90.0f, 0); | |
CamParent.GetComponent < playVideo > ().enabled = false; | |
CamParent.GetComponent < MouseRayv2 > ().enabled = true; | |
// myTexty = GameObject.FindWithTag("cam_stuff"); | |
// myDot = GameObject.FindWithTag("dot"); | |
myTexty.SetActive(true); | |
myDot.SetActive(true); | |
break; | |
case 2: | |
CamParent.GetComponent < playVideo > ().enabled = false; | |
CamParent.GetComponent < MouseRayv2 > ().enabled = false; | |
myTexty.SetActive(false); | |
myDot.SetActive(false); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment