浏览代码

Added utility to debug in game view SSR

/main
Frédéric Vauchelles 7 年前
当前提交
d228ca21
共有 1 个文件被更改,包括 45 次插入0 次删除
  1. 45
      ScriptableRenderPipeline/Core/CoreRP/Debugging/MousePositionDebug.cs

45
ScriptableRenderPipeline/Core/CoreRP/Debugging/MousePositionDebug.cs


using System;
using UnityEditor;
namespace UnityEngine.Experimental.Rendering
{

}
}
[ExecuteInEditMode]
class GameViewEventCatcher : MonoBehaviour
{
public static GameViewEventCatcher s_Instance = null;
public static void Cleanup()
{
if (s_Instance != null)
DestroyImmediate(s_Instance.gameObject);
}
public static void Build()
{
Cleanup();
var go = new GameObject("__GameViewEventCatcher");
go.hideFlags = HideFlags.HideAndDontSave;
s_Instance = go.AddComponent<GameViewEventCatcher>();
}
void Update()
{
Debug.Log(Input.mousePosition);
Debug.Log(Screen.width);
Debug.Log(Screen.height);
if (Input.mousePosition.x < 0
|| Input.mousePosition.y < 0
|| Input.mousePosition.x > Screen.width
|| Input.mousePosition.y > Screen.height)
return;
instance.m_mousePosition = Input.mousePosition;
if (Input.GetMouseButtonDown(0))
instance.m_MouseClickPosition = Input.mousePosition;
if (Input.GetKeyDown(KeyCode.PageUp))
++instance.m_DebugStep;
if (Input.GetKeyDown(KeyCode.PageDown))
instance.m_DebugStep = Mathf.Max(0, instance.m_DebugStep - 1);
if (Input.GetKey(KeyCode.End))
instance.m_MouseClickPosition = instance.m_mousePosition;
}
}
public int debugStep
{
get

#if UNITY_EDITOR
UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI;
UnityEditor.SceneView.onSceneGUIDelegate += OnSceneGUI;
GameViewEventCatcher.Build();
#endif
}

UnityEditor.SceneView.onSceneGUIDelegate -= OnSceneGUI;
GameViewEventCatcher.Cleanup();
#endif
}

正在加载...
取消
保存