void Awake() { camera.targetTexture = new RenderTexture(camera.targetTexture); camera.targetTexture.filterMode = FilterMode.Point; renderTextureCamera = GetComponent <RenderTextureCamera>(); renderTextureCamera.ResizeRenderTexture(); }
public void UpdateLayout() { m_screenHeight = Screen.height; m_screenWidth = Screen.width; m_cameraPixelRect = Window.Camera.pixelRect; m_scale = Appearance.SceneGizmoScale; if (m_camera == null) { return; } m_aspect = m_camera.aspect; if (Window.Camera != null) { bool initColliders = false; if (m_renderTextureCamera == null) { Vector2 size = Size * Appearance.SceneGizmoScale; Vector2 offset = Offset * Appearance.SceneGizmoScale; m_camera.pixelRect = new Rect(Window.Camera.pixelRect.min.x + Window.Camera.pixelWidth - size.x + offset.x, Window.Camera.pixelRect.min.y + Window.Camera.pixelHeight - size.y + offset.y, size.x, size.y); } else { if (m_output != null) { m_output.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Size.x); m_output.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, Size.y); } } if (m_camera.pixelRect.height == 0 || m_camera.pixelRect.width == 0) { // enabled = false; return; } else { if (!enabled) { initColliders = true; } // enabled = true; } m_camera.depth = Window.Camera.depth + 1; m_aspect = m_camera.aspect; if (m_renderTextureCamera == null) { Vector2 size = Size * Appearance.SceneGizmoScale; Vector2 offset = Offset * Appearance.SceneGizmoScale; m_buttonRect = new Rect(Window.Camera.pixelRect.min.x + Window.Camera.pixelWidth - size.x / 2 - 17 + offset.x, (Screen.height - Window.Camera.pixelRect.yMax) + size.y - offset.y - 3, 35, 14); } m_buttonStyle = new GUIStyle(); m_buttonStyle.alignment = TextAnchor.MiddleCenter; m_buttonStyle.normal.textColor = new Color(0.8f, 0.8f, 0.8f, 0.8f); m_buttonStyle.fontSize = 12; if (initColliders) { InitColliders(); } if (m_renderTextureCamera != null) { m_renderTextureCamera.ResizeRenderTexture(); } } }