protected void OnGUI() { var e = Event.current; if (e.type != EventType.Repaint || !Visible) { return; } if (!_activeActionPanel) { if (_objectImage.enabled) { _objectImage.enabled = false; } return; } var objectAction = GetHotkeyActionForPanel <HotkeyObjectAction>(_activeActionPanel); if (objectAction == null || !objectAction.AppearanceType) { if (_objectImage.enabled) { _objectImage.enabled = false; } return; } if (s_renderTexture == null) { s_renderTexture = new RenderTexture(Constants.FieldSize, Constants.FieldSize, 0, RenderTextureFormat.ARGB32); s_renderTexture.filterMode = FilterMode.Bilinear; s_renderTexture.Create(); _objectImage.texture = s_renderTexture; } var commandBuffer = new CommandBuffer(); commandBuffer.SetRenderTarget(s_renderTexture); commandBuffer.ClearRenderTarget(false, true, Core.Utils.GraphicsUtility.TransparentColor); var zoom = new Vector2(Screen.width / (float)s_renderTexture.width, Screen.height / (float)s_renderTexture.height); commandBuffer.SetViewMatrix(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, zoom) * OpenTibiaUnity.GameManager.MainCamera.worldToCameraMatrix); _objectInstance.Draw(commandBuffer, new Vector2Int(0, 0), 0, 0, 0); Graphics.ExecuteCommandBuffer(commandBuffer); commandBuffer.Dispose(); if (!_objectImage.enabled) { _objectImage.enabled = true; } }
protected void OnGUI() { var e = Event.current; if (e.type != EventType.Repaint) { return; } if (!_activeActionPanel) { if (_objectImage.enabled) { _objectImage.enabled = false; } return; } var objectAction = GetHotkeyActionForPanel <HotkeyObjectAction>(_activeActionPanel); if (objectAction == null || !objectAction.AppearanceType) { if (_objectImage.enabled) { _objectImage.enabled = false; } return; } if (s_RenderTexture == null) { s_RenderTexture = new RenderTexture(Constants.FieldSize, Constants.FieldSize, 0, RenderTextureFormat.ARGB32); s_RenderTexture.filterMode = FilterMode.Point; _objectImage.texture = s_RenderTexture; } RenderTexture.active = s_RenderTexture; Core.Utils.GraphicsUtility.ClearWithTransparency(); var zoom = new Vector2(Screen.width / (float)s_RenderTexture.width, Screen.height / (float)s_RenderTexture.height); _objectInstance.Draw(new Vector2(0, 0), zoom, 0, 0, 0); RenderTexture.active = null; if (!_objectImage.enabled) { _objectImage.enabled = true; } }