void UpdateFullscreenState(bool newState) { if (fullscreenOn == newState) { return; } fullscreenOn = newState; // Toggle buttons. fullscreenButton.gameObject.SetActive(!newState); exitFullscreenButton.gameObject.SetActive(newState); // Change sibling index. if (fullscreenBehaviour != FullscreenBehaviour.DoNothing) { if (newState) { if (fullscreenBehaviour == FullscreenBehaviour.BottomOfHierarchy) { transform.SetSiblingIndex(transform.parent.childCount - 1); } else if (fullscreenBehaviour == FullscreenBehaviour.BottomOfHierarchyMinusIndex) { transform.SetSiblingIndex(Mathf.Max(transform.parent.childCount - 1 - hierarchyMinusIndex, 0)); } } else { transform.SetSiblingIndex(startSiblingIndex); } } // Update the blocker. if (!blocker) { blocker = UIUtilities.CreateBlocker(transform.parent, Color.black, transform.GetSiblingIndex()); } blocker.enabled = newState; // Resize. if (newState) { ratioFitter.aspectMode = AspectRatioFitter.AspectMode.FitInParent; } else { ratioFitter.aspectMode = AspectRatioFitter.AspectMode.None; // Reset our rectTransform. ((RectTransform)transform).anchorMin = startAnchorMin; ((RectTransform)transform).anchorMax = startAnchorMax; ((RectTransform)transform).sizeDelta = startSizeDelta; transform.localPosition = startLocalPos; } // Resize the render texture. if (newState) { image.texture = UIUtilities.SetRenderTextureResolution(renderCamera, new Vector2(Screen.width, Screen.height)); } else { image.texture = UIUtilities.SetRenderTextureResolution(renderCamera, startTextureResolution); } }