Idle Time Camera Switch
I keep finding all kinds of stuff on player character idle animations but what I'm looking for is a way to switch cameras when there has been no U.I. interactivity for a period of time elapsed.
Then switch cameras to another U.I. where I have an animated logo.
How can I do that. C# preferably
Comment
Found a way to do it.
using UnityEngine;
using System.Collections;
public class SpinLogoScrnSaver : $$anonymous$$onoBehaviour {
float timeOut = 20.0f; // Time Out Setting in Secounds
private float timeOutTimer = 0.0f;
void Update()
{
timeOutTimer += Time.deltaTime;
if (Input.Get$$anonymous$$eyUp($$anonymous$$eyCode.$$anonymous$$ouse0))
{
//$$anonymous$$ouse moved, reset timer
timeOutTimer = 0.0f;
}
if (timeOutTimer > timeOut)
{
//$$anonymous$$ouse inactivity period has occured
$$anonymous$$ainCanvasPanel.SetActive(false);
ClockCanvasPanel.SetActive(false);
LogoCanvasPanel.SetActive(true);
CameraSwitcher cs = FindObjectOfType<CameraSwitcher>();
cs.EnableCamera3();
}
}
//public GameObject TripTimerPanel;
//public GameObject CountDownTimerPanel;
public GameObject LogoCanvasPanel;
public GameObject ClockCanvasPanel;
public GameObject $$anonymous$$ainCanvasPanel;
}
Best Answer
Answer by KnightRiderGuy · Dec 06, 2015 at 09:50 PM
using UnityEngine;
using System.Collections;
public class SpinLogoScrnSaver : MonoBehaviour {
float timeOut = 20.0f; // Time Out Setting in Secounds
private float timeOutTimer = 0.0f;
void Update()
{
timeOutTimer += Time.deltaTime;
if (Input.GetKeyUp(KeyCode.Mouse0))
{
//Mouse moved, reset timer
timeOutTimer = 0.0f;
}
if (timeOutTimer > timeOut)
{
//Mouse inactivity period has occured
MainCanvasPanel.SetActive(false);
ClockCanvasPanel.SetActive(false);
LogoCanvasPanel.SetActive(true);
CameraSwitcher cs = FindObjectOfType<CameraSwitcher>();
cs.EnableCamera3();
}
}
//public GameObject TripTimerPanel;
//public GameObject CountDownTimerPanel;
public GameObject LogoCanvasPanel;
public GameObject ClockCanvasPanel;
public GameObject MainCanvasPanel;
}