public void TestSetup() { // Camera | Canvas (Image) | Event System m_Canvas = new GameObject("Canvas").AddComponent <Canvas>(); m_Canvas.renderMode = RenderMode.ScreenSpaceOverlay; m_Canvas.gameObject.AddComponent <GraphicRaycaster>(); m_Image = new GameObject("Image").AddComponent <Image>(); m_Image.gameObject.transform.SetParent(m_Canvas.transform); RectTransform imageRectTransform = m_Image.GetComponent <RectTransform>(); imageRectTransform.sizeDelta = new Vector2(400f, 400f); imageRectTransform.localPosition = Vector3.zero; m_NestedImage = new GameObject("NestedImage").AddComponent <Image>(); m_NestedImage.gameObject.transform.SetParent(m_Image.transform); RectTransform nestedImageRectTransform = m_NestedImage.GetComponent <RectTransform>(); nestedImageRectTransform.sizeDelta = new Vector2(200f, 200f); nestedImageRectTransform.localPosition = Vector3.zero; GameObject go = new GameObject("Event System"); m_EventSystem = go.AddComponent <EventSystem>(); m_EventSystem.pixelDragThreshold = 1; m_StandaloneInputModule = go.AddComponent <StandaloneInputModule>(); m_FakeBaseInput = go.AddComponent <FakeBaseInput>(); // Override input with FakeBaseInput so we can send fake mouse/keyboards button presses and touches m_StandaloneInputModule.inputOverride = m_FakeBaseInput; Cursor.lockState = CursorLockMode.None; }
void Awake() { m_FakeBaseInput = GetComponent <FakeBaseInput>(); }