浏览代码

add controls for test script to toggle settings

/main
Filip Iliescu 7 年前
当前提交
495e902b
共有 2 个文件被更改,包括 94 次插入3 次删除
  1. 6
      Assets/TestScenes/MobileDeferredTest/2DirLightTest/2DirLightTest.unity
  2. 91
      Assets/TestScenes/MobileDeferredTest/TestSceneScript/MobileTestSceneManager.cs

6
Assets/TestScenes/MobileDeferredTest/2DirLightTest/2DirLightTest.unity


propertyPath: m_RootOrder
value: 8
objectReference: {fileID: 0}
- target: {fileID: 114150254131087770, guid: 73dfbb376901b4b7b98b292ba7c203e5,
type: 2}
propertyPath: pipeline
value:
objectReference: {fileID: 11400000, guid: 33d9927db5e524331aa1c00a95f2e96b,
type: 2}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 73dfbb376901b4b7b98b292ba7c203e5, type: 2}
m_IsPrefabParent: 0

91
Assets/TestScenes/MobileDeferredTest/TestSceneScript/MobileTestSceneManager.cs


using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.Rendering;
private Vector2 startPosition;
private float startTime;
public UnityEngine.Experimental.Rendering.OnTileDeferredRenderPipeline.OnTileDeferredRenderPipeline pipeline;
void Start () {
if (Instance != null) {

}
}
// bool processRightSwipe()
// {
// if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) {
// Vector2 touchDeltaPosition = Input.GetTouch(0).position;
// if (touchDeltaPosition.x > Screen.width/2)
// return true;
// }
// return false;
// }
//
// bool processLeftSwipe()
// {
// if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) {
// Vector2 touchDeltaPosition = Input.GetTouch(0).position;
// if (touchDeltaPosition.x < Screen.width/2)
// return true;
// }
// return false;
// }
int detectSwipe() {
if (Input.touchCount == 1 && Input.GetTouch (0).phase == TouchPhase.Ended) {
Vector2 endPosition = Input.GetTouch (0).position;
Vector2 delta = endPosition - startPosition;
// float dist = Mathf.Sqrt(Mathf.Pow(delta.x, 2) + Mathf.Pow (delta.y, 2));
// float angle = Mathf.Atan (delta.y/delta.x) * (180.0f/Mathf.PI);
// float duration = Time.time - startTime;
// float speed = dist/duration;
if (startPosition.x < endPosition.x)
return 1;
else if (startPosition.x > endPosition.x)
return -1;
}
return 0;
}
void detectTouchBegan() {
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) {
startPosition = Input.GetTouch(0).position;
startTime = Time.time;
}
}
#if UNITY_EDITOR
#if (UNITY_EDITOR || UNITY_STANDALONE)
if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began) {
if (Input.touchCount == 3 && Input.GetTouch(0).phase == TouchPhase.Began) {
}
#if (UNITY_EDITOR || UNITY_STANDALONE)
if (Input.GetKeyDown(KeyCode.S)) {
#else
if (detectSwipe() == 1) {
#endif
pipeline.TransparencyShadows = !pipeline.TransparencyShadows;
}
#if (UNITY_EDITOR || UNITY_STANDALONE)
if (Input.GetKeyDown(KeyCode.C)) {
#else
if (detectSwipe() == -1) {
#endif
pipeline.UseLegacyCookies = !pipeline.UseLegacyCookies;
}
#if (UNITY_EDITOR || UNITY_STANDALONE)
if (Input.GetKeyDown(KeyCode.Return)) {
#else
if (Input.touchCount == 2 && Input.GetTouch(0).phase == TouchPhase.Ended) {
#endif
if (GraphicsSettings.renderPipelineAsset == null)
GraphicsSettings.renderPipelineAsset = pipeline;
else
GraphicsSettings.renderPipelineAsset = null;
}
#if !(UNITY_EDITOR || UNITY_STANDALONE)
detectTouchBegan();
#endif
}
}
正在加载...
取消
保存