edit shader
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
@@ -13,15 +14,27 @@ public class GameSystem : MonoBehaviour
|
||||
public List<IGameComponent> gameComponents { get; private set; } = new List<IGameComponent>();
|
||||
|
||||
[SerializeField] GameObject[] sigletonComponents;
|
||||
[SerializeField] CanvasGroup loadingCanvas;
|
||||
|
||||
public event Action OnSceneLoaded;
|
||||
|
||||
|
||||
public async void LoadScene(string sceneName)
|
||||
public void LoadScene(string sceneName)
|
||||
{
|
||||
var sceneLoadingOperation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
|
||||
while(!sceneLoadingOperation.isDone) await Task.Yield();
|
||||
if(!loadingCanvas.gameObject.activeSelf)
|
||||
loadingCanvas.gameObject.SetActive(true);
|
||||
|
||||
loadingCanvas.DOFade(1, .5f).OnComplete(async() =>
|
||||
{
|
||||
var qrReader = FindObjectOfType<QRCodeReader>();
|
||||
qrReader.camTexture.Stop();
|
||||
|
||||
OnSceneLoaded?.Invoke();
|
||||
var sceneLoadingOperation = SceneManager.LoadSceneAsync(sceneName, LoadSceneMode.Single);
|
||||
while(!sceneLoadingOperation.isDone) await Task.Yield();
|
||||
|
||||
OnSceneLoaded?.Invoke();
|
||||
loadingCanvas.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -9,6 +10,28 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
private Controls inputSystem;
|
||||
private Transform cameraTransform;
|
||||
|
||||
private float X0;
|
||||
private float P0;
|
||||
private readonly float F = 1;
|
||||
private readonly float Q = 2;
|
||||
private readonly float H = 1;
|
||||
private readonly float R = 15;
|
||||
|
||||
private float Covariance = .1f;
|
||||
private float state = 0;
|
||||
|
||||
float GetValueAfterFilter(float value)
|
||||
{
|
||||
X0 = F * state;
|
||||
P0 = F * Covariance * F + Q;
|
||||
|
||||
var K = H *P0 / (H * P0 * H + R);
|
||||
state = X0 + K * (value - H * X0);
|
||||
Covariance = (1 - K * H) * P0;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
inputSystem = new Controls();
|
||||
@@ -39,7 +62,23 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
.Gyroscope
|
||||
.ReadValue<Quaternion>();
|
||||
|
||||
cameraTransform.rotation = phoneRotation;
|
||||
// phoneRotation = new Quaternion
|
||||
// (
|
||||
// GetValueAfterFilter(phoneRotation.x),
|
||||
// GetValueAfterFilter(phoneRotation.y),
|
||||
// GetValueAfterFilter(phoneRotation.z),
|
||||
// GetValueAfterFilter(phoneRotation.w)
|
||||
// );
|
||||
|
||||
Quaternion filtredRotation = new Quaternion
|
||||
(
|
||||
GetValueAfterFilter(phoneRotation.x),
|
||||
GetValueAfterFilter(phoneRotation.y),
|
||||
GetValueAfterFilter(phoneRotation.z),
|
||||
GetValueAfterFilter(phoneRotation.w)
|
||||
);
|
||||
|
||||
cameraTransform.rotation = filtredRotation;
|
||||
cameraTransform.Rotate(0, 0, 180, Space.Self);
|
||||
cameraTransform.Rotate(90, 180, 0, Space.World);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ public class QRCodeReader : MonoBehaviour
|
||||
public event Action<string> OnQRCodeRead;
|
||||
|
||||
[SerializeField] AspectRatioFitter aspectRatioFitter;
|
||||
[SerializeField] RawImage rawImage;
|
||||
[SerializeField] GameObject scanFrame;
|
||||
public RawImage rawImage;
|
||||
public GameObject scanFrame;
|
||||
|
||||
private WebCamTexture camTexture;
|
||||
public WebCamTexture camTexture;
|
||||
private Coroutine c_QRScanningRoutine;
|
||||
|
||||
void Start()
|
||||
@@ -98,12 +98,10 @@ public class QRCodeReader : MonoBehaviour
|
||||
}
|
||||
catch { }
|
||||
|
||||
yield return new WaitForSeconds(1f);
|
||||
yield return new WaitForSeconds(.5f);
|
||||
}
|
||||
|
||||
camTexture.Stop();
|
||||
gameObject.SetActive(false);
|
||||
scanFrame.SetActive(false);
|
||||
yield return new WaitForSeconds(1);
|
||||
|
||||
OnQRCodeRead?.Invoke(result.Text);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class SceneHandler : MonoBehaviour
|
||||
|
||||
async Task Start()
|
||||
{
|
||||
var skyboxExposure = skyboxMaterial.GetFloat("_Exposure");
|
||||
var skyboxExposure = 1;
|
||||
float currentExposure = 0;
|
||||
skyboxMaterial.SetFloat("_Exposure", 0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user