public virtual void ActivateWindow(RuntimeWindowType windowType) { RuntimeWindow window = GetWindow(windowType); if (window != null) { ActivateWindow(window); } }
private void Awake() { m_window = GetComponent <RuntimeWindow>(); m_window.IOCContainer.RegisterFallback <IRTEGraphicsLayer>(this); m_window.CameraResized += OnCameraResized; m_graphics = IOC.Resolve <IRTEGraphics>(); PrepareGraphicsLayerCamera(); }
public void ActivateWindow(RuntimeWindow window) { if (m_activeWindow != window) { m_activeWindow = window; if (ActiveWindowChanged != null) { ActiveWindowChanged(); } } }
private void OnActiveWindowChanging(RuntimeWindow activatedWindow) { if (activatedWindow == Window) { OnWindowActivating(); } else { OnWindowDeactivating(); } }
protected virtual void OnActiveWindowChanged(RuntimeWindow deactivatedWindow) { if (m_editor.ActiveWindow == Window) { OnWindowActivated(); } else { OnWindowDeactivated(); } }
protected virtual void OnActiveWindowChanging(RuntimeWindow activatedWindow) { if (activatedWindow == Window) { OnWindowActivating(); } else { OnWindowDeactivating(); } }
public virtual void ActivateWindow(RuntimeWindow window) { if (window != null && m_activeWindow != window && window.CanActivate) { RuntimeWindow deactivatedWindow = m_activeWindow; m_activeWindow = window; if (ActiveWindowChanged != null) { ActiveWindowChanged(deactivatedWindow); } } }
protected virtual void Update() { UpdateCurrentInputField(); bool mwheel = false; if (m_zAxis != Mathf.CeilToInt(Mathf.Abs(Input.GetAxis(InputAxis.Z)))) { mwheel = m_zAxis == 0; m_zAxis = Mathf.CeilToInt(Mathf.Abs(Input.GetAxis(InputAxis.Z))); } bool pointerDownOrUp = Input.GetPointerDown(0) || Input.GetPointerDown(1) || Input.GetPointerDown(2) || Input.GetPointerUp(0); if (pointerDownOrUp || mwheel || Input.IsAnyKeyDown() && !IsInputFieldFocused) { PointerEventData pointerEventData = new PointerEventData(m_eventSystem); pointerEventData.position = Input.GetPointerXY(0); List <RaycastResult> results = new List <RaycastResult>(); m_raycaster.Raycast(pointerEventData, results); IEnumerable <Selectable> selectables = results.Select(r => r.gameObject.GetComponent <Selectable>()).Where(s => s != null); if (selectables.Count() == 1) { Selectable selectable = selectables.First() as Selectable; if (selectable != null) { selectable.Select(); } } foreach (RaycastResult result in results) { if (m_windows.Contains(result.gameObject)) { RuntimeWindow editorWindow = result.gameObject.GetComponent <RuntimeWindow>(); if (pointerDownOrUp || editorWindow.ActivateOnAnyKey) { ActivateWindow(editorWindow); break; } } } } }
private void Init() { if (m_window == null) { m_window = GetComponent <RuntimeWindow>(); } if (m_window.Camera != null) { m_renderTextureCamera = m_window.Camera.GetComponent <RenderTextureCamera>(); if (m_renderTextureCamera != null) { m_canvasScaler = GetComponentInParent <CanvasScaler>(); } } }
public void RegisterWindow(RuntimeWindow window) { if (!m_windows.Contains(window.gameObject)) { m_windows.Add(window.gameObject); } if (WindowRegistered != null) { WindowRegistered(window); } if (m_windows.Count == 1) { ActivateWindow(window); } }
public virtual void ActivateWindow(RuntimeWindow window) { if (m_activeWindow != window && (window == null || window.CanActivate)) { RuntimeWindow deactivatedWindow = m_activeWindow; if (ActiveWindowChanging != null) { ActiveWindowChanging(window); } m_activeWindow = window; if (ActiveWindowChanged != null) { ActiveWindowChanged(deactivatedWindow); } } }
protected virtual void Init() { if (m_window == null) { m_window = GetComponent <RuntimeWindow>(); } m_canvas = GetComponentInParent <Canvas>(); if (m_window.Camera != null) { m_renderTextureCamera = m_window.Camera.GetComponent <RenderTextureCamera>(); if (m_renderTextureCamera != null) { m_canvasScaler = GetComponentInParent <CanvasScaler>(); } } }
public void RegisterWindow(RuntimeWindow window) { if (!m_windows.Contains(window.gameObject)) { m_windows.Add(window.gameObject); } if (WindowRegistered != null) { WindowRegistered(window); } m_windowsArray = m_windows.Select(w => w.GetComponent <RuntimeWindow>()).ToArray(); if (m_windows.Count == 1) { ActivateWindow(window); } }
public void UnregisterWindow(RuntimeWindow window) { m_windows.Remove(window.gameObject); if (WindowUnregistered != null) { WindowUnregistered(window); } if (m_activeWindow == window) { RuntimeWindow activeWindow = m_windows.Select(w => w.GetComponent <RuntimeWindow>()).Where(w => w.WindowType == window.WindowType).FirstOrDefault(); if (activeWindow == null) { activeWindow = m_windows.Select(w => w.GetComponent <RuntimeWindow>()).FirstOrDefault(); } ActivateWindow(activeWindow); } }
private void OnActiveWindowChanged(RuntimeWindow deactivatedWindow) { if (!m_editor.IsPlaying) { return; } if (m_editor.ActiveWindow != null && m_editor.ActiveWindow.WindowType == RuntimeWindowType.Game) { foreach (ExposeToEditor playObj in m_playModeCache) { playObj.SendMessage("OnRuntimeActivate", SendMessageOptions.DontRequireReceiver); } } else { foreach (ExposeToEditor playObj in m_playModeCache) { playObj.SendMessage("OnRuntimeDeactivate", SendMessageOptions.DontRequireReceiver); } } }
private void CreateRenderTextureCamera() { bool wasActive = m_camera.gameObject.activeSelf; m_camera.gameObject.SetActive(false); m_renderTextureCamera = m_camera.gameObject.AddComponent <RenderTextureCamera>(); if (m_output != null) { m_renderTextureCamera.OutputRoot = m_output; } else { IRTE rte = IOC.Resolve <IRTE>(); RuntimeWindow sceneWindow = rte.GetWindow(RuntimeWindowType.Scene); m_renderTextureCamera.OutputRoot = (RectTransform)sceneWindow.transform; } m_renderTextureCamera.OverlayMaterial = new Material(Shader.Find("Battlehub/RTCommon/RenderTextureOverlay")); m_camera.clearFlags = CameraClearFlags.SolidColor; m_camera.backgroundColor = new Color(0, 0, 0, 0); m_camera.gameObject.SetActive(wasActive); }
private void OnEndFrameRendering(UnityEngine.Rendering.ScriptableRenderContext arg1, Camera[] arg2) { UnityEngine.Rendering.RenderPipelineManager.endFrameRendering -= OnEndFrameRendering; //LWRP OR HDRP; bool wasActive = m_graphicsLayerCamera.gameObject.activeSelf; m_graphicsLayerCamera.gameObject.SetActive(false); m_renderTextureCamera = m_graphicsLayerCamera.gameObject.AddComponent <RenderTextureCamera>(); //m_renderTextureCamera.Fullscreen = false; IRTE rte = IOC.Resolve <IRTE>(); RuntimeWindow sceneWindow = rte.GetWindow(RuntimeWindowType.Scene); m_renderTextureCamera.OutputRoot = (RectTransform)sceneWindow.transform; m_renderTextureCamera.OverlayMaterial = new Material(Shader.Find("Battlehub/RTCommon/RenderTextureOverlay")); m_graphicsLayerCamera.clearFlags = CameraClearFlags.SolidColor; m_graphicsLayerCamera.backgroundColor = new Color(0, 0, 0, 0); m_graphicsLayerCamera.gameObject.SetActive(wasActive); }
protected virtual void OnActiveWindowChanged(RuntimeWindow deactivatedWindow) { if (Editor.ActiveWindow == this) { if (!m_isActivated) { m_isActivated = true; if (WindowType == RuntimeWindowType.Game) { m_background.raycastTarget = false; // allow to interact with world space ui } OnActivated(); } } else { if (m_isActivated) { m_isActivated = false; m_background.raycastTarget = true; OnDeactivated(); } } }
private void Awake() { m_editorWindow = GetComponent <RuntimeWindow>(); PrepareGraphicsLayerCamera(); }
protected virtual void BuildUp(GameObject editor) { editor.AddComponent <GLRenderer>(); GameObject ui = new GameObject("UI"); ui.transform.SetParent(editor.transform); Canvas canvas = ui.AddComponent <Canvas>(); if (IsVR) { canvas.renderMode = RenderMode.WorldSpace; canvas.worldCamera = Camera.main; } else { canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = Camera.main; canvas.planeDistance = Camera.main.nearClipPlane + 0.01f; } canvas.sortingOrder = short.MinValue; GameObject scene = new GameObject("SceneWindow"); scene.transform.SetParent(ui.transform, false); RuntimeWindow sceneView = scene.AddComponent <RuntimeWindow>(); sceneView.IsPointerOver = true; sceneView.WindowType = RuntimeWindowType.Scene; if (Camera.main == null) { GameObject camera = new GameObject(); camera.name = "RTE SceneView Camera"; sceneView.Camera = camera.AddComponent <Camera>(); } else { sceneView.Camera = Camera.main; } EventSystem eventSystem = FindObjectOfType <EventSystem>(); if (eventSystem == null) { eventSystem = editor.AddComponent <EventSystem>(); if (IsVR) { // } else { editor.AddComponent <StandaloneInputModule>(); } } RectTransform rectTransform = sceneView.GetComponent <RectTransform>(); if (rectTransform != null) { RectTransform parentTransform = rectTransform.parent as RectTransform; if (parentTransform != null) { rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.offsetMax = new Vector2(0, 0); rectTransform.offsetMin = new Vector2(0, 0); } } if (IsVR) { gameObject.AddComponent <VRTracker>(); } else { m_raycaster = ui.AddComponent <GraphicRaycaster>(); } m_eventSystem = eventSystem; }
public bool Contains(RuntimeWindow window) { return(m_windows.Contains(window.gameObject)); }
public virtual void SetPointerOverWindow(RuntimeWindow window) { m_pointerOverWindow = window; }
protected virtual void BuildUp(GameObject editor) { editor.AddComponent <GLRenderer>(); GameObject ui = new GameObject("UI"); ui.transform.SetParent(editor.transform); Canvas canvas = ui.AddComponent <Canvas>(); if (m_instance.IsVR) { canvas.renderMode = RenderMode.WorldSpace; canvas.worldCamera = Camera.main; } else { canvas.renderMode = RenderMode.ScreenSpaceCamera; canvas.worldCamera = Camera.main; } canvas.sortingOrder = short.MinValue; GameObject scene = new GameObject("SceneWindow"); scene.transform.SetParent(ui.transform, false); RuntimeWindow sceneView = scene.AddComponent <RuntimeWindow>(); sceneView.WindowType = RuntimeWindowType.SceneView; sceneView.Camera = Camera.main; EventSystem eventSystem = FindObjectOfType <EventSystem>(); if (eventSystem == null) { eventSystem = editor.AddComponent <EventSystem>(); if (m_instance.IsVR) { RTEVRInputModule inputModule = editor.AddComponent <RTEVRInputModule>(); inputModule.rayTransform = sceneView.Camera.transform; inputModule.Editor = this; } else { editor.AddComponent <StandaloneInputModule>(); } } RectTransform rectTransform = sceneView.GetComponent <RectTransform>(); if (rectTransform != null) { RectTransform parentTransform = rectTransform.parent as RectTransform; if (parentTransform != null) { rectTransform.anchorMin = new Vector2(0, 0); rectTransform.anchorMax = new Vector2(1, 1); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.offsetMax = new Vector2(0, 0); rectTransform.offsetMin = new Vector2(0, 0); } } if (m_instance.IsVR) { RTEVRGraphicsRaycaster raycaster = ui.AddComponent <RTEVRGraphicsRaycaster>(); raycaster.SceneWindow = sceneView; m_instance.m_raycaster = raycaster; } else { m_instance.m_raycaster = ui.AddComponent <GraphicRaycaster>(); } m_instance.m_eventSystem = eventSystem; }