Version: Unity 6.6 Alpha (6000.6)
LanguageEnglish
  • C#

RectTransform.IsCoplanarWith

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Declaration

public bool IsCoplanarWith(RectTransform target);

Parameters

Parameter Description
target The RectTransform to test for coplanarity.

Returns

bool true if this RectTransform is considered coplanar with target; false otherwise.

Description

Determines whether this RectTransform is coplanar with the given RectTransform.

Two RectTransforms are considered coplanar when their forward vectors are parallel and they share the same world-space Z position. Use this method to check coplanarity before performing custom logic that requires both RectTransforms to be on the same plane.

using System.Collections.Generic;
using UnityEngine;

// Manages which world-space canvas surface is currently active. // Call SetActiveSurface when the player focuses on a different surface — // for example, when a controller ray hits a new canvas. public class SurfaceFocusManager : MonoBehaviour { [SerializeField] List<RectTransform> m_AllPanels;

public void SetActiveSurface(RectTransform focusedPanel) { foreach (RectTransform panel in m_AllPanels) { CanvasGroup group = panel.GetComponent<CanvasGroup>(); bool onActiveSurface = panel.IsCoplanarWith(focusedPanel);

// Enable interaction only for panels on the focused surface. group.interactable = onActiveSurface; group.alpha = onActiveSurface ? 1f : 0.5f; } } }