time.unscaleTime on One Component when all in Time.scaleTime = 0
Need to make ma camera component working unscaled time while every thing is on time.timescale = 0 Please help, tried many thing 1st script is on Pause menu. 2nd on camera.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using VideoGlitches;
public class PauseMenu : MonoBehaviour {
public static bool GameIsPaused = false;
public GameObject pauseMenuUI;
public VHS_Pause other;
void Start()
{
}
void Update () {
if (Input.GetKeyDown (KeyCode.Escape))
{
if (GameIsPaused) {
Resume ();
} else
{
Pause ();
}
}
}
public void Resume()
{
other.TurnOff ();
pauseMenuUI.SetActive (false);
Time.timeScale = 1f;
GameIsPaused = false;
}
void Pause()
{
other.TurnOn ();
pauseMenuUI.SetActive (true);
Time.timeScale = 0f;
GameIsPaused = true;
}
public void LoadMenu()
{
Time.timeScale = 1f;
SceneManager.LoadScene ("MainMenu");
}
}
Second script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VideoGlitches;
public class VHS_Pause : MonoBehaviour {
private VideoGlitchVHSPause vhsCamPause;
void Start () {
vhsCamPause = GetComponent<VideoGlitchVHSPause> ();
}
public void TurnOn()
{
vhsCamPause.enabled = true;
}
public void TurnOff()
{
vhsCamPause.enabled = false;
}
}
Answer by theterrificjd · Dec 25, 2017 at 06:12 AM
How are you filling your "other" variable (public VHS_Pause other)?
If it's on the main camera, shouldn't you have something like:
other = Camera.main.GetComponent<VHS_Pause>();
located somewhere in your start function. If it's not the main camera, you can add a Camera variable to the global declarations, and drag and drop the camera into the slot in the Editor, then find component on that gameobject.
Hardly any different:
public Camera cam;
public VHS_Pause other;
void Start () [
other = cam.GetComponent<VHSPause>();
}
Not sure if that is your issue, but I hope it helps.
I thought about it a $$anonymous$$ute, and no i think Because my component is turning on and off. Its just not updating like usual when Time.timeScale is on 1. Right now Time.timeScale is on 0 and its freeze, i need just to make it work while everything is on pause
$$anonymous$$y best guess is that somewhere in the VideoGlitches scripts there's probably a step that's based in deltaTime. You need to find it and replace it with unscaledDeltaTime.
You should be safe to just find and replace any 'delaTime' to 'unscaledDeltaTime' in any of those files, Unless, of course, there are any times you'd want them scaled by the Time.timescale as well.
Beyond that you could consider looking to help from the asset's creator (http://www.ibuprogames.com/ if those are the assets you're using, seems to be the most popular)
Taking a longer look, I'm guessing the effects are applied with shaders?
If that's the case it may not be as simple. I'm not well versed in shader coding, but I know you can open them up and edit them. Then something like this post here: https://answers.unity.com/questions/573512/possible-to-pause-a-shader.html might be more helpful than anything i could really say.
Best of luck!
So I checked my scripts that connected with the effect, and im not find something connected with time or time. The link below is to look the images that i took from my screen :) sorry notebook is not connected to the inthernet right now
I would check the camera component on the 10 $$anonymous$$utes
Okay, i added the camera.main I think thats better than $$anonymous$$e first line
What about effect - yes, i found shader of this script and i searched for something like time, and i did not found it except "_Time"
Check it please here https://cloud.mail.ru/public/$$anonymous$$LuN/NdjtdikkQ
I think the problem in this one, that I dont know exactly how to add time.unscaledTime / time.fixedunscaledTime to my script!
Can u show the example of doing that?
Okay, I haven't found a way to test this, but I think you may be able to cahnge the '_Time' in the shader to '_Time.y', and that is in unscaledTime.
Found that very vague answer here: https://forum.unity.com/threads/unscaled-time-in-shader.293647/ the documentation he links is 404 unfortunately
I will try my best, thanks for you help!